var Om=Object.defineProperty;var Uo=s=>{throw TypeError(s)};var Dm=(s,t,r)=>t in s?Om(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var vs=(s,t,r)=>Dm(s,typeof t!="symbol"?t+"":t,r),Gn=(s,t,r)=>t.has(s)||Uo("Cannot "+r);var w=(s,t,r)=>(Gn(s,t,"read from private field"),r?r.call(s):t.get(s)),he=(s,t,r)=>t.has(s)?Uo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),Y=(s,t,r,a)=>(Gn(s,t,"write to private field"),a?a.call(s,r):t.set(s,r),r),Ae=(s,t,r)=>(Gn(s,t,"access private method"),r);var Qa=(s,t,r,a)=>({set _(n){Y(s,t,n,r)},get _(){return w(s,t,a)}});import{j as e,V as vc,R as jc,A as wc,C as Nc,T as _c,D as Sc,P as Lm,c as pa,b as fa,d as Pn,e as kc,f as Cc,g as Fm,u as rt,h as Ec,i as Xe,k as De,l as Tc,m as Pc,O as Ac,n as qm,o as Rc,p as zm,q as Mc,r as Ic,s as $m,t as Bm,v as Oc,w as lo,x as un,y as Um,I as Hm,z as Dc,L as Lc,B as Fc,E as qc,F as Vm,G as Wm,H as $t,J as Km,K as co,M as Es,N as Gm,Q as Ym,S as Qm,U as Zm,W as Jm,X as Xm}from"./ui-Br_UQYRm.js";import{f as eh,a as d,R as H,c as th,u as An,d as sh,L as Oe,h as ns,g as uo,i as zc,j as rh,b as $c,r as ah,B as nh,k as ih,l as tt}from"./vendor-AojMz-9-.js";import{c as Bc,R as mn,A as gi,C as yi,X as bi,Y as vi,T as hn,a as ji,b as oh,d as lh,e as ch}from"./charts-BBtnqFpA.js";import{c as dh}from"./supabase-CtTUqvr6.js";import{l as uh,E as mh,u as hh,a as ph,A as fh,P as xh}from"./stripe-BWBzBY7w.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))a(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function r(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(n){if(n.ep)return;n.ep=!0;const i=r(n);fetch(n.href,i)}})();var Za={},Ho;function gh(){if(Ho)return Za;Ho=1;var s=eh();return Za.createRoot=s.createRoot,Za.hydrateRoot=s.hydrateRoot,Za}var yh=gh();const bh=1,vh=1e6;let Yn=0;function jh(){return Yn=(Yn+1)%Number.MAX_SAFE_INTEGER,Yn.toString()}const Qn=new Map,Vo=s=>{if(Qn.has(s))return;const t=setTimeout(()=>{Qn.delete(s),Aa({type:"REMOVE_TOAST",toastId:s})},vh);Qn.set(s,t)},wh=(s,t)=>{switch(t.type){case"ADD_TOAST":return{...s,toasts:[t.toast,...s.toasts].slice(0,bh)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(r=>r.id===t.toast.id?{...r,...t.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=t;return r?Vo(r):s.toasts.forEach(a=>{Vo(a.id)}),{...s,toasts:s.toasts.map(a=>a.id===r||r===void 0?{...a,open:!1}:a)}}case"REMOVE_TOAST":return t.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(r=>r.id!==t.toastId)}}},an=[];let nn={toasts:[]};function Aa(s){nn=wh(nn,s),an.forEach(t=>{t(nn)})}function Nh({...s}){const t=jh(),r=n=>Aa({type:"UPDATE_TOAST",toast:{...n,id:t}}),a=()=>Aa({type:"DISMISS_TOAST",toastId:t});return Aa({type:"ADD_TOAST",toast:{...s,id:t,open:!0,onOpenChange:n=>{n||a()}}}),{id:t,dismiss:a,update:r}}function mo(){const[s,t]=d.useState(nn);return d.useEffect(()=>(an.push(t),()=>{const r=an.indexOf(t);r>-1&&an.splice(r,1)}),[s]),{...s,toast:Nh,dismiss:r=>Aa({type:"DISMISS_TOAST",toastId:r})}}const Wo=s=>typeof s=="boolean"?`${s}`:s===0?"0":s,Ko=Bc,Wa=(s,t)=>r=>{var a;if((t==null?void 0:t.variants)==null)return Ko(s,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:n,defaultVariants:i}=t,o=Object.keys(n).map(m=>{const p=r==null?void 0:r[m],x=i==null?void 0:i[m];if(p===null)return null;const g=Wo(p)||Wo(x);return n[m][g]}),l=r&&Object.entries(r).reduce((m,p)=>{let[x,g]=p;return g===void 0||(m[x]=g),m},{}),c=t==null||(a=t.compoundVariants)===null||a===void 0?void 0:a.reduce((m,p)=>{let{class:x,className:g,...u}=p;return Object.entries(u).every(y=>{let[h,f]=y;return Array.isArray(f)?f.includes({...i,...l}[h]):{...i,...l}[h]===f})?[...m,x,g]:m},[]);return Ko(s,o,c,r==null?void 0:r.class,r==null?void 0:r.className)};/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _h=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Uc=(...s)=>s.filter((t,r,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===r).join(" ").trim();/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */var Sh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const kh=d.forwardRef(({color:s="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:a,className:n="",children:i,iconNode:o,...l},c)=>d.createElement("svg",{ref:c,...Sh,width:t,height:t,stroke:s,strokeWidth:a?Number(r)*24/Number(t):r,className:Uc("lucide",n),...l},[...o.map(([m,p])=>d.createElement(m,p)),...Array.isArray(i)?i:[i]]));/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const z=(s,t)=>{const r=d.forwardRef(({className:a,...n},i)=>d.createElement(kh,{ref:i,iconNode:t,className:Uc(`lucide-${_h(s)}`,a),...n}));return r.displayName=`${s}`,r};/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Rn=z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ss=z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ch=z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Hc=z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Eh=z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Th=z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vc=z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Wc=z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ho=z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Go=z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pn=z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Kc=z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ph=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ah=z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Rh=z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const po=z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Gc=z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const wt=z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fo=z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Mh=z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xo=z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Yc=z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ih=z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fn=z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ka=z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Oh=z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qc=z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Zc=z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Jc=z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const hs=z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const go=z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ga=z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Dh=z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const yo=z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Xc=z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Zn=z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const bo=z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xa=z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Lh=z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ra=z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Fh=z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qh=z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const zh=z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $h=z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ft=z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xn=z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Bh=z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ue=z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Yo=z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Uh=z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const zt=z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rs=z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Hh=z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vh=z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ra=z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ed=z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Wh=z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Kh=z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Et=z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const td=z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Mn=z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sd=z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Gh=z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fs=z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Yh=z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const wr=z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qh=z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const aa=z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Zh=z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const vo=z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const In=z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Jh=z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Jn=z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Xh=z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Nr=z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const wi=z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const As=z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gn=z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ep=z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const tp=z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sp=z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rp=z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rd=z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ap=z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xs=z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _r=z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const np=z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const On=z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ip=z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const op=z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ad=z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ni=z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rr=z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Dn=z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lp=z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const nd=z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),jo="-",cp=s=>{const t=up(s),{conflictingClassGroups:r,conflictingClassGroupModifiers:a}=s;return{getClassGroupId:o=>{const l=o.split(jo);return l[0]===""&&l.length!==1&&l.shift(),id(l,t)||dp(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&a[o]?[...c,...a[o]]:c}}},id=(s,t)=>{var o;if(s.length===0)return t.classGroupId;const r=s[0],a=t.nextPart.get(r),n=a?id(s.slice(1),a):void 0;if(n)return n;if(t.validators.length===0)return;const i=s.join(jo);return(o=t.validators.find(({validator:l})=>l(i)))==null?void 0:o.classGroupId},Qo=/^\[(.+)\]$/,dp=s=>{if(Qo.test(s)){const t=Qo.exec(s)[1],r=t==null?void 0:t.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},up=s=>{const{theme:t,prefix:r}=s,a={nextPart:new Map,validators:[]};return hp(Object.entries(s.classGroups),r).forEach(([i,o])=>{_i(o,a,i,t)}),a},_i=(s,t,r,a)=>{s.forEach(n=>{if(typeof n=="string"){const i=n===""?t:Zo(t,n);i.classGroupId=r;return}if(typeof n=="function"){if(mp(n)){_i(n(a),t,r,a);return}t.validators.push({validator:n,classGroupId:r});return}Object.entries(n).forEach(([i,o])=>{_i(o,Zo(t,i),r,a)})})},Zo=(s,t)=>{let r=s;return t.split(jo).forEach(a=>{r.nextPart.has(a)||r.nextPart.set(a,{nextPart:new Map,validators:[]}),r=r.nextPart.get(a)}),r},mp=s=>s.isThemeGetter,hp=(s,t)=>t?s.map(([r,a])=>{const n=a.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[t+o,l])):i);return[r,n]}):s,pp=s=>{if(s<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,a=new Map;const n=(i,o)=>{r.set(i,o),t++,t>s&&(t=0,a=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=a.get(i))!==void 0)return n(i,o),o},set(i,o){r.has(i)?r.set(i,o):n(i,o)}}},od="!",fp=s=>{const{separator:t,experimentalParseClassName:r}=s,a=t.length===1,n=t[0],i=t.length,o=l=>{const c=[];let m=0,p=0,x;for(let f=0;f<l.length;f++){let b=l[f];if(m===0){if(b===n&&(a||l.slice(f,f+i)===t)){c.push(l.slice(p,f)),p=f+i;continue}if(b==="/"){x=f;continue}}b==="["?m++:b==="]"&&m--}const g=c.length===0?l:l.substring(p),u=g.startsWith(od),y=u?g.substring(1):g,h=x&&x>p?x-p:void 0;return{modifiers:c,hasImportantModifier:u,baseClassName:y,maybePostfixModifierPosition:h}};return r?l=>r({className:l,parseClassName:o}):o},xp=s=>{if(s.length<=1)return s;const t=[];let r=[];return s.forEach(a=>{a[0]==="["?(t.push(...r.sort(),a),r=[]):r.push(a)}),t.push(...r.sort()),t},gp=s=>({cache:pp(s.cacheSize),parseClassName:fp(s),...cp(s)}),yp=/\s+/,bp=(s,t)=>{const{parseClassName:r,getClassGroupId:a,getConflictingClassGroupIds:n}=t,i=[],o=s.trim().split(yp);let l="";for(let c=o.length-1;c>=0;c-=1){const m=o[c],{modifiers:p,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:u}=r(m);let y=!!u,h=a(y?g.substring(0,u):g);if(!h){if(!y){l=m+(l.length>0?" "+l:l);continue}if(h=a(g),!h){l=m+(l.length>0?" "+l:l);continue}y=!1}const f=xp(p).join(":"),b=x?f+od:f,v=b+h;if(i.includes(v))continue;i.push(v);const j=n(h,y);for(let _=0;_<j.length;++_){const I=j[_];i.push(b+I)}l=m+(l.length>0?" "+l:l)}return l};function vp(){let s=0,t,r,a="";for(;s<arguments.length;)(t=arguments[s++])&&(r=ld(t))&&(a&&(a+=" "),a+=r);return a}const ld=s=>{if(typeof s=="string")return s;let t,r="";for(let a=0;a<s.length;a++)s[a]&&(t=ld(s[a]))&&(r&&(r+=" "),r+=t);return r};function jp(s,...t){let r,a,n,i=o;function o(c){const m=t.reduce((p,x)=>x(p),s());return r=gp(m),a=r.cache.get,n=r.cache.set,i=l,l(c)}function l(c){const m=a(c);if(m)return m;const p=bp(c,r);return n(c,p),p}return function(){return i(vp.apply(null,arguments))}}const Je=s=>{const t=r=>r[s]||[];return t.isThemeGetter=!0,t},cd=/^\[(?:([a-z-]+):)?(.+)\]$/i,wp=/^\d+\/\d+$/,Np=new Set(["px","full","screen"]),_p=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Sp=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,kp=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Cp=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ep=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,js=s=>zr(s)||Np.has(s)||wp.test(s),Fs=s=>ga(s,"length",Dp),zr=s=>!!s&&!Number.isNaN(Number(s)),Xn=s=>ga(s,"number",zr),ja=s=>!!s&&Number.isInteger(Number(s)),Tp=s=>s.endsWith("%")&&zr(s.slice(0,-1)),Ee=s=>cd.test(s),qs=s=>_p.test(s),Pp=new Set(["length","size","percentage"]),Ap=s=>ga(s,Pp,dd),Rp=s=>ga(s,"position",dd),Mp=new Set(["image","url"]),Ip=s=>ga(s,Mp,Fp),Op=s=>ga(s,"",Lp),wa=()=>!0,ga=(s,t,r)=>{const a=cd.exec(s);return a?a[1]?typeof t=="string"?a[1]===t:t.has(a[1]):r(a[2]):!1},Dp=s=>Sp.test(s)&&!kp.test(s),dd=()=>!1,Lp=s=>Cp.test(s),Fp=s=>Ep.test(s),qp=()=>{const s=Je("colors"),t=Je("spacing"),r=Je("blur"),a=Je("brightness"),n=Je("borderColor"),i=Je("borderRadius"),o=Je("borderSpacing"),l=Je("borderWidth"),c=Je("contrast"),m=Je("grayscale"),p=Je("hueRotate"),x=Je("invert"),g=Je("gap"),u=Je("gradientColorStops"),y=Je("gradientColorStopPositions"),h=Je("inset"),f=Je("margin"),b=Je("opacity"),v=Je("padding"),j=Je("saturate"),_=Je("scale"),I=Je("sepia"),E=Je("skew"),O=Je("space"),D=Je("translate"),N=()=>["auto","contain","none"],T=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",Ee,t],S=()=>[Ee,t],W=()=>["",js,Fs],K=()=>["auto",zr,Ee],F=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],k=()=>["solid","dashed","dotted","double","none"],A=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],q=()=>["start","end","center","between","around","evenly","stretch"],re=()=>["","0",Ee],$=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Te=()=>[zr,Ee];return{cacheSize:500,separator:":",theme:{colors:[wa],spacing:[js,Fs],blur:["none","",qs,Ee],brightness:Te(),borderColor:[s],borderRadius:["none","","full",qs,Ee],borderSpacing:S(),borderWidth:W(),contrast:Te(),grayscale:re(),hueRotate:Te(),invert:re(),gap:S(),gradientColorStops:[s],gradientColorStopPositions:[Tp,Fs],inset:P(),margin:P(),opacity:Te(),padding:S(),saturate:Te(),scale:Te(),sepia:re(),skew:Te(),space:S(),translate:S()},classGroups:{aspect:[{aspect:["auto","square","video",Ee]}],container:["container"],columns:[{columns:[qs]}],"break-after":[{"break-after":$()}],"break-before":[{"break-before":$()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...F(),Ee]}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[h]}],"inset-x":[{"inset-x":[h]}],"inset-y":[{"inset-y":[h]}],start:[{start:[h]}],end:[{end:[h]}],top:[{top:[h]}],right:[{right:[h]}],bottom:[{bottom:[h]}],left:[{left:[h]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ja,Ee]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ee]}],grow:[{grow:re()}],shrink:[{shrink:re()}],order:[{order:["first","last","none",ja,Ee]}],"grid-cols":[{"grid-cols":[wa]}],"col-start-end":[{col:["auto",{span:["full",ja,Ee]},Ee]}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":[wa]}],"row-start-end":[{row:["auto",{span:[ja,Ee]},Ee]}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ee]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...q()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...q(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...q(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[f]}],mx:[{mx:[f]}],my:[{my:[f]}],ms:[{ms:[f]}],me:[{me:[f]}],mt:[{mt:[f]}],mr:[{mr:[f]}],mb:[{mb:[f]}],ml:[{ml:[f]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ee,t]}],"min-w":[{"min-w":[Ee,t,"min","max","fit"]}],"max-w":[{"max-w":[Ee,t,"none","full","min","max","fit","prose",{screen:[qs]},qs]}],h:[{h:[Ee,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ee,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ee,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ee,t,"auto","min","max","fit"]}],"font-size":[{text:["base",qs,Fs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Xn]}],"font-family":[{font:[wa]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ee]}],"line-clamp":[{"line-clamp":["none",zr,Xn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",js,Ee]}],"list-image":[{"list-image":["none",Ee]}],"list-style-type":[{list:["none","disc","decimal",Ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[s]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[s]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...k(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",js,Fs]}],"underline-offset":[{"underline-offset":["auto",js,Ee]}],"text-decoration-color":[{decoration:[s]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),Rp]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Ap]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Ip]}],"bg-color":[{bg:[s]}],"gradient-from-pos":[{from:[y]}],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...k(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:k()}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["",...k()]}],"outline-offset":[{"outline-offset":[js,Ee]}],"outline-w":[{outline:[js,Fs]}],"outline-color":[{outline:[s]}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[s]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[js,Fs]}],"ring-offset-color":[{"ring-offset":[s]}],shadow:[{shadow:["","inner","none",qs,Op]}],"shadow-color":[{shadow:[wa]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...A(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":A()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[a]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",qs,Ee]}],grayscale:[{grayscale:[m]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[x]}],saturate:[{saturate:[j]}],sepia:[{sepia:[I]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[a]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[m]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[x]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[j]}],"backdrop-sepia":[{"backdrop-sepia":[I]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ee]}],duration:[{duration:Te()}],ease:[{ease:["linear","in","out","in-out",Ee]}],delay:[{delay:Te()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[ja,Ee]}],"translate-x":[{"translate-x":[D]}],"translate-y":[{"translate-y":[D]}],"skew-x":[{"skew-x":[E]}],"skew-y":[{"skew-y":[E]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ee]}],accent:[{accent:["auto",s]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ee]}],"caret-color":[{caret:[s]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ee]}],fill:[{fill:[s,"none"]}],"stroke-w":[{stroke:[js,Fs,Xn]}],stroke:[{stroke:[s,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},zp=jp(qp);function me(...s){return zp(Bc(s))}const $p=Lm,ud=d.forwardRef(({className:s,...t},r)=>e.jsx(vc,{ref:r,className:me("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",s),...t}));ud.displayName=vc.displayName;const Bp=Wa("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),md=d.forwardRef(({className:s,variant:t,...r},a)=>e.jsx(jc,{ref:a,className:me(Bp({variant:t}),s),...r}));md.displayName=jc.displayName;const Up=d.forwardRef(({className:s,...t},r)=>e.jsx(wc,{ref:r,className:me("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",s),...t}));Up.displayName=wc.displayName;const hd=d.forwardRef(({className:s,...t},r)=>e.jsx(Nc,{ref:r,className:me("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",s),"toast-close":"",...t,children:e.jsx(Dn,{className:"h-4 w-4"})}));hd.displayName=Nc.displayName;const pd=d.forwardRef(({className:s,...t},r)=>e.jsx(_c,{ref:r,className:me("text-sm font-semibold",s),...t}));pd.displayName=_c.displayName;const fd=d.forwardRef(({className:s,...t},r)=>e.jsx(Sc,{ref:r,className:me("text-sm opacity-90",s),...t}));fd.displayName=Sc.displayName;function Hp(){const{toasts:s}=mo();return e.jsxs($p,{children:[s.map(function({id:t,title:r,description:a,action:n,...i}){return e.jsxs(md,{...i,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(pd,{children:r}),a&&e.jsx(fd,{children:a})]}),n,e.jsx(hd,{})]},t)}),e.jsx(ud,{})]})}var Jo=["light","dark"],Vp="(prefers-color-scheme: dark)",Wp=d.createContext(void 0),Kp={setTheme:s=>{},themes:[]},Gp=()=>{var s;return(s=d.useContext(Wp))!=null?s:Kp};d.memo(({forcedTheme:s,storageKey:t,attribute:r,enableSystem:a,enableColorScheme:n,defaultTheme:i,value:o,attrs:l,nonce:c})=>{let m=i==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(y=>`'${y}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,x=n?Jo.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(y,h=!1,f=!0)=>{let b=o?o[y]:y,v=h?y+"|| ''":`'${b}'`,j="";return n&&f&&!h&&Jo.includes(y)&&(j+=`d.style.colorScheme = '${y}';`),r==="class"?h||b?j+=`c.add(${v})`:j+="null":b&&(j+=`d[s](n,${v})`),j},u=s?`!function(){${p}${g(s)}}()`:a?`!function(){try{${p}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${m})){var t='${Vp}',m=window.matchMedia(t);if(m.media!==t||m.matches){${g("dark")}}else{${g("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${g(o?"x[e]":"e",!0)}}${m?"":"else{"+g(i,!1,!1)+"}"}${x}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${g(o?"x[e]":"e",!0)}}else{${g(i,!1,!1)};}${x}}catch(t){}}();`;return d.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:u}})});var Yp=s=>{switch(s){case"success":return Jp;case"info":return ef;case"warning":return Xp;case"error":return tf;default:return null}},Qp=Array(12).fill(0),Zp=({visible:s,className:t})=>H.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":s},H.createElement("div",{className:"sonner-spinner"},Qp.map((r,a)=>H.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),Jp=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Xp=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),ef=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),tf=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),sf=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},H.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),rf=()=>{let[s,t]=H.useState(document.hidden);return H.useEffect(()=>{let r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),s},Si=1,af=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let t=this.subscribers.indexOf(s);this.subscribers.splice(t,1)}),this.publish=s=>{this.subscribers.forEach(t=>t(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var t;let{message:r,...a}=s,n=typeof(s==null?void 0:s.id)=="number"||((t=s.id)==null?void 0:t.length)>0?s.id:Si++,i=this.toasts.find(l=>l.id===n),o=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),i?this.toasts=this.toasts.map(l=>l.id===n?(this.publish({...l,...s,id:n,title:r}),{...l,...s,id:n,dismissible:o,title:r}):l):this.addToast({title:r,...a,dismissible:o,id:n}),n},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(t=>{this.subscribers.forEach(r=>r({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:s,dismiss:!0})),s),this.message=(s,t)=>this.create({...t,message:s}),this.error=(s,t)=>this.create({...t,message:s,type:"error"}),this.success=(s,t)=>this.create({...t,type:"success",message:s}),this.info=(s,t)=>this.create({...t,type:"info",message:s}),this.warning=(s,t)=>this.create({...t,type:"warning",message:s}),this.loading=(s,t)=>this.create({...t,type:"loading",message:s}),this.promise=(s,t)=>{if(!t)return;let r;t.loading!==void 0&&(r=this.create({...t,promise:s,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let a=s instanceof Promise?s:s(),n=r!==void 0,i,o=a.then(async c=>{if(i=["resolve",c],H.isValidElement(c))n=!1,this.create({id:r,type:"default",message:c});else if(of(c)&&!c.ok){n=!1;let m=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,p=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:r,type:"error",message:m,description:p})}else if(t.success!==void 0){n=!1;let m=typeof t.success=="function"?await t.success(c):t.success,p=typeof t.description=="function"?await t.description(c):t.description;this.create({id:r,type:"success",message:m,description:p})}}).catch(async c=>{if(i=["reject",c],t.error!==void 0){n=!1;let m=typeof t.error=="function"?await t.error(c):t.error,p=typeof t.description=="function"?await t.description(c):t.description;this.create({id:r,type:"error",message:m,description:p})}}).finally(()=>{var c;n&&(this.dismiss(r),r=void 0),(c=t.finally)==null||c.call(t)}),l=()=>new Promise((c,m)=>o.then(()=>i[0]==="reject"?m(i[1]):c(i[1])).catch(m));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(s,t)=>{let r=(t==null?void 0:t.id)||Si++;return this.create({jsx:s(r),id:r,...t}),r},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ct=new af,nf=(s,t)=>{let r=(t==null?void 0:t.id)||Si++;return Ct.addToast({title:s,...t,id:r}),r},of=s=>s&&typeof s=="object"&&"ok"in s&&typeof s.ok=="boolean"&&"status"in s&&typeof s.status=="number",lf=nf,cf=()=>Ct.toasts,df=()=>Ct.getActiveToasts(),C=Object.assign(lf,{success:Ct.success,info:Ct.info,warning:Ct.warning,error:Ct.error,custom:Ct.custom,message:Ct.message,promise:Ct.promise,dismiss:Ct.dismiss,loading:Ct.loading},{getHistory:cf,getToasts:df});function uf(s,{insertAt:t}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",t==="top"&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=s:a.appendChild(document.createTextNode(s))}uf(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
`);function Ja(s){return s.label!==void 0}var mf=3,hf="32px",pf="16px",Xo=4e3,ff=356,xf=14,gf=20,yf=200;function Zt(...s){return s.filter(Boolean).join(" ")}function bf(s){let[t,r]=s.split("-"),a=[];return t&&a.push(t),r&&a.push(r),a}var vf=s=>{var t,r,a,n,i,o,l,c,m,p,x;let{invert:g,toast:u,unstyled:y,interacting:h,setHeights:f,visibleToasts:b,heights:v,index:j,toasts:_,expanded:I,removeToast:E,defaultRichColors:O,closeButton:D,style:N,cancelButtonStyle:T,actionButtonStyle:P,className:S="",descriptionClassName:W="",duration:K,position:F,gap:k,loadingIcon:A,expandByDefault:q,classNames:re,icons:$,closeButtonAriaLabel:Te="Close toast",pauseWhenPageIsHidden:fe}=s,[we,ke]=H.useState(null),[Ze,st]=H.useState(null),[Z,ze]=H.useState(!1),[V,je]=H.useState(!1),[xe,Ce]=H.useState(!1),[xt,ut]=H.useState(!1),[Wt,L]=H.useState(!1),[ge,ne]=H.useState(0),[de,Ie]=H.useState(0),Pe=H.useRef(u.duration||K||Xo),ie=H.useRef(null),le=H.useRef(null),pe=j===0,G=j+1<=b,J=u.type,ve=u.dismissible!==!1,Ke=u.className||"",lt=u.descriptionClassName||"",ct=H.useMemo(()=>v.findIndex(Ne=>Ne.toastId===u.id)||0,[v,u.id]),Nt=H.useMemo(()=>{var Ne;return(Ne=u.closeButton)!=null?Ne:D},[u.closeButton,D]),pt=H.useMemo(()=>u.duration||K||Xo,[u.duration,K]),_t=H.useRef(0),It=H.useRef(0),Kt=H.useRef(0),cs=H.useRef(null),[or,va]=F.split("-"),Or=H.useMemo(()=>v.reduce((Ne,Ge,et)=>et>=ct?Ne:Ne+Ge.height,0),[v,ct]),Tt=rf(),yt=u.invert||g,gt=J==="loading";It.current=H.useMemo(()=>ct*k+Or,[ct,Or]),H.useEffect(()=>{Pe.current=pt},[pt]),H.useEffect(()=>{ze(!0)},[]),H.useEffect(()=>{let Ne=le.current;if(Ne){let Ge=Ne.getBoundingClientRect().height;return Ie(Ge),f(et=>[{toastId:u.id,height:Ge,position:u.position},...et]),()=>f(et=>et.filter(Gt=>Gt.toastId!==u.id))}},[f,u.id]),H.useLayoutEffect(()=>{if(!Z)return;let Ne=le.current,Ge=Ne.style.height;Ne.style.height="auto";let et=Ne.getBoundingClientRect().height;Ne.style.height=Ge,Ie(et),f(Gt=>Gt.find(Yt=>Yt.toastId===u.id)?Gt.map(Yt=>Yt.toastId===u.id?{...Yt,height:et}:Yt):[{toastId:u.id,height:et,position:u.position},...Gt])},[Z,u.title,u.description,f,u.id]);let bs=H.useCallback(()=>{je(!0),ne(It.current),f(Ne=>Ne.filter(Ge=>Ge.toastId!==u.id)),setTimeout(()=>{E(u)},yf)},[u,E,f,It]);H.useEffect(()=>{if(u.promise&&J==="loading"||u.duration===1/0||u.type==="loading")return;let Ne;return I||h||fe&&Tt?(()=>{if(Kt.current<_t.current){let Ge=new Date().getTime()-_t.current;Pe.current=Pe.current-Ge}Kt.current=new Date().getTime()})():Pe.current!==1/0&&(_t.current=new Date().getTime(),Ne=setTimeout(()=>{var Ge;(Ge=u.onAutoClose)==null||Ge.call(u,u),bs()},Pe.current)),()=>clearTimeout(Ne)},[I,h,u,J,fe,Tt,bs]),H.useEffect(()=>{u.delete&&bs()},[bs,u.delete]);function Bo(){var Ne,Ge,et;return $!=null&&$.loading?H.createElement("div",{className:Zt(re==null?void 0:re.loader,(Ne=u==null?void 0:u.classNames)==null?void 0:Ne.loader,"sonner-loader"),"data-visible":J==="loading"},$.loading):A?H.createElement("div",{className:Zt(re==null?void 0:re.loader,(Ge=u==null?void 0:u.classNames)==null?void 0:Ge.loader,"sonner-loader"),"data-visible":J==="loading"},A):H.createElement(Zp,{className:Zt(re==null?void 0:re.loader,(et=u==null?void 0:u.classNames)==null?void 0:et.loader),visible:J==="loading"})}return H.createElement("li",{tabIndex:0,ref:le,className:Zt(S,Ke,re==null?void 0:re.toast,(t=u==null?void 0:u.classNames)==null?void 0:t.toast,re==null?void 0:re.default,re==null?void 0:re[J],(r=u==null?void 0:u.classNames)==null?void 0:r[J]),"data-sonner-toast":"","data-rich-colors":(a=u.richColors)!=null?a:O,"data-styled":!(u.jsx||u.unstyled||y),"data-mounted":Z,"data-promise":!!u.promise,"data-swiped":Wt,"data-removed":V,"data-visible":G,"data-y-position":or,"data-x-position":va,"data-index":j,"data-front":pe,"data-swiping":xe,"data-dismissible":ve,"data-type":J,"data-invert":yt,"data-swipe-out":xt,"data-swipe-direction":Ze,"data-expanded":!!(I||q&&Z),style:{"--index":j,"--toasts-before":j,"--z-index":_.length-j,"--offset":`${V?ge:It.current}px`,"--initial-height":q?"auto":`${de}px`,...N,...u.style},onDragEnd:()=>{Ce(!1),ke(null),cs.current=null},onPointerDown:Ne=>{gt||!ve||(ie.current=new Date,ne(It.current),Ne.target.setPointerCapture(Ne.pointerId),Ne.target.tagName!=="BUTTON"&&(Ce(!0),cs.current={x:Ne.clientX,y:Ne.clientY}))},onPointerUp:()=>{var Ne,Ge,et,Gt;if(xt||!ve)return;cs.current=null;let Yt=Number(((Ne=le.current)==null?void 0:Ne.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ds=Number(((Ge=le.current)==null?void 0:Ge.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),lr=new Date().getTime()-((et=ie.current)==null?void 0:et.getTime()),Qt=we==="x"?Yt:Ds,Ls=Math.abs(Qt)/lr;if(Math.abs(Qt)>=gf||Ls>.11){ne(It.current),(Gt=u.onDismiss)==null||Gt.call(u,u),st(we==="x"?Yt>0?"right":"left":Ds>0?"down":"up"),bs(),ut(!0),L(!1);return}Ce(!1),ke(null)},onPointerMove:Ne=>{var Ge,et,Gt,Yt;if(!cs.current||!ve||((Ge=window.getSelection())==null?void 0:Ge.toString().length)>0)return;let Ds=Ne.clientY-cs.current.y,lr=Ne.clientX-cs.current.x,Qt=(et=s.swipeDirections)!=null?et:bf(F);!we&&(Math.abs(lr)>1||Math.abs(Ds)>1)&&ke(Math.abs(lr)>Math.abs(Ds)?"x":"y");let Ls={x:0,y:0};we==="y"?(Qt.includes("top")||Qt.includes("bottom"))&&(Qt.includes("top")&&Ds<0||Qt.includes("bottom")&&Ds>0)&&(Ls.y=Ds):we==="x"&&(Qt.includes("left")||Qt.includes("right"))&&(Qt.includes("left")&&lr<0||Qt.includes("right")&&lr>0)&&(Ls.x=lr),(Math.abs(Ls.x)>0||Math.abs(Ls.y)>0)&&L(!0),(Gt=le.current)==null||Gt.style.setProperty("--swipe-amount-x",`${Ls.x}px`),(Yt=le.current)==null||Yt.style.setProperty("--swipe-amount-y",`${Ls.y}px`)}},Nt&&!u.jsx?H.createElement("button",{"aria-label":Te,"data-disabled":gt,"data-close-button":!0,onClick:gt||!ve?()=>{}:()=>{var Ne;bs(),(Ne=u.onDismiss)==null||Ne.call(u,u)},className:Zt(re==null?void 0:re.closeButton,(n=u==null?void 0:u.classNames)==null?void 0:n.closeButton)},(i=$==null?void 0:$.close)!=null?i:sf):null,u.jsx||d.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:H.createElement(H.Fragment,null,J||u.icon||u.promise?H.createElement("div",{"data-icon":"",className:Zt(re==null?void 0:re.icon,(o=u==null?void 0:u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Bo():null,u.type!=="loading"?u.icon||($==null?void 0:$[J])||Yp(J):null):null,H.createElement("div",{"data-content":"",className:Zt(re==null?void 0:re.content,(l=u==null?void 0:u.classNames)==null?void 0:l.content)},H.createElement("div",{"data-title":"",className:Zt(re==null?void 0:re.title,(c=u==null?void 0:u.classNames)==null?void 0:c.title)},typeof u.title=="function"?u.title():u.title),u.description?H.createElement("div",{"data-description":"",className:Zt(W,lt,re==null?void 0:re.description,(m=u==null?void 0:u.classNames)==null?void 0:m.description)},typeof u.description=="function"?u.description():u.description):null),d.isValidElement(u.cancel)?u.cancel:u.cancel&&Ja(u.cancel)?H.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||T,onClick:Ne=>{var Ge,et;Ja(u.cancel)&&ve&&((et=(Ge=u.cancel).onClick)==null||et.call(Ge,Ne),bs())},className:Zt(re==null?void 0:re.cancelButton,(p=u==null?void 0:u.classNames)==null?void 0:p.cancelButton)},u.cancel.label):null,d.isValidElement(u.action)?u.action:u.action&&Ja(u.action)?H.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||P,onClick:Ne=>{var Ge,et;Ja(u.action)&&((et=(Ge=u.action).onClick)==null||et.call(Ge,Ne),!Ne.defaultPrevented&&bs())},className:Zt(re==null?void 0:re.actionButton,(x=u==null?void 0:u.classNames)==null?void 0:x.actionButton)},u.action.label):null))};function el(){if(typeof window>"u"||typeof document>"u")return"ltr";let s=document.documentElement.getAttribute("dir");return s==="auto"||!s?window.getComputedStyle(document.documentElement).direction:s}function jf(s,t){let r={};return[s,t].forEach((a,n)=>{let i=n===1,o=i?"--mobile-offset":"--offset",l=i?pf:hf;function c(m){["top","right","bottom","left"].forEach(p=>{r[`${o}-${p}`]=typeof m=="number"?`${m}px`:m})}typeof a=="number"||typeof a=="string"?c(a):typeof a=="object"?["top","right","bottom","left"].forEach(m=>{a[m]===void 0?r[`${o}-${m}`]=l:r[`${o}-${m}`]=typeof a[m]=="number"?`${a[m]}px`:a[m]}):c(l)}),r}var wf=d.forwardRef(function(s,t){let{invert:r,position:a="bottom-right",hotkey:n=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:m,theme:p="light",richColors:x,duration:g,style:u,visibleToasts:y=mf,toastOptions:h,dir:f=el(),gap:b=xf,loadingIcon:v,icons:j,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:I}=s,[E,O]=H.useState([]),D=H.useMemo(()=>Array.from(new Set([a].concat(E.filter(fe=>fe.position).map(fe=>fe.position)))),[E,a]),[N,T]=H.useState([]),[P,S]=H.useState(!1),[W,K]=H.useState(!1),[F,k]=H.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),A=H.useRef(null),q=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),re=H.useRef(null),$=H.useRef(!1),Te=H.useCallback(fe=>{O(we=>{var ke;return(ke=we.find(Ze=>Ze.id===fe.id))!=null&&ke.delete||Ct.dismiss(fe.id),we.filter(({id:Ze})=>Ze!==fe.id)})},[]);return H.useEffect(()=>Ct.subscribe(fe=>{if(fe.dismiss){O(we=>we.map(ke=>ke.id===fe.id?{...ke,delete:!0}:ke));return}setTimeout(()=>{th.flushSync(()=>{O(we=>{let ke=we.findIndex(Ze=>Ze.id===fe.id);return ke!==-1?[...we.slice(0,ke),{...we[ke],...fe},...we.slice(ke+1)]:[fe,...we]})})})}),[]),H.useEffect(()=>{if(p!=="system"){k(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?k("dark"):k("light")),typeof window>"u")return;let fe=window.matchMedia("(prefers-color-scheme: dark)");try{fe.addEventListener("change",({matches:we})=>{k(we?"dark":"light")})}catch{fe.addListener(({matches:ke})=>{try{k(ke?"dark":"light")}catch(Ze){console.error(Ze)}})}},[p]),H.useEffect(()=>{E.length<=1&&S(!1)},[E]),H.useEffect(()=>{let fe=we=>{var ke,Ze;n.every(st=>we[st]||we.code===st)&&(S(!0),(ke=A.current)==null||ke.focus()),we.code==="Escape"&&(document.activeElement===A.current||(Ze=A.current)!=null&&Ze.contains(document.activeElement))&&S(!1)};return document.addEventListener("keydown",fe),()=>document.removeEventListener("keydown",fe)},[n]),H.useEffect(()=>{if(A.current)return()=>{re.current&&(re.current.focus({preventScroll:!0}),re.current=null,$.current=!1)}},[A.current]),H.createElement("section",{ref:t,"aria-label":`${_} ${q}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},D.map((fe,we)=>{var ke;let[Ze,st]=fe.split("-");return E.length?H.createElement("ol",{key:fe,dir:f==="auto"?el():f,tabIndex:-1,ref:A,className:l,"data-sonner-toaster":!0,"data-theme":F,"data-y-position":Ze,"data-lifted":P&&E.length>1&&!i,"data-x-position":st,style:{"--front-toast-height":`${((ke=N[0])==null?void 0:ke.height)||0}px`,"--width":`${ff}px`,"--gap":`${b}px`,...u,...jf(c,m)},onBlur:Z=>{$.current&&!Z.currentTarget.contains(Z.relatedTarget)&&($.current=!1,re.current&&(re.current.focus({preventScroll:!0}),re.current=null))},onFocus:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||$.current||($.current=!0,re.current=Z.relatedTarget)},onMouseEnter:()=>S(!0),onMouseMove:()=>S(!0),onMouseLeave:()=>{W||S(!1)},onDragEnd:()=>S(!1),onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||K(!0)},onPointerUp:()=>K(!1)},E.filter(Z=>!Z.position&&we===0||Z.position===fe).map((Z,ze)=>{var V,je;return H.createElement(vf,{key:Z.id,icons:j,index:ze,toast:Z,defaultRichColors:x,duration:(V=h==null?void 0:h.duration)!=null?V:g,className:h==null?void 0:h.className,descriptionClassName:h==null?void 0:h.descriptionClassName,invert:r,visibleToasts:y,closeButton:(je=h==null?void 0:h.closeButton)!=null?je:o,interacting:W,position:fe,style:h==null?void 0:h.style,unstyled:h==null?void 0:h.unstyled,classNames:h==null?void 0:h.classNames,cancelButtonStyle:h==null?void 0:h.cancelButtonStyle,actionButtonStyle:h==null?void 0:h.actionButtonStyle,removeToast:Te,toasts:E.filter(xe=>xe.position==Z.position),heights:N.filter(xe=>xe.position==Z.position),setHeights:T,expandByDefault:i,gap:b,loadingIcon:v,expanded:P,pauseWhenPageIsHidden:I,swipeDirections:s.swipeDirections})})):null}))});const Nf=({...s})=>{const{theme:t="system"}=Gp();return e.jsx(wf,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...s})};var _f=Symbol("radix.slottable");function Sf(s){const t=({children:r})=>e.jsx(e.Fragment,{children:r});return t.displayName=`${s}.Slottable`,t.__radixId=_f,t}var[Ln]=pa("Tooltip",[Pn]),wo=Pn(),xd="TooltipProvider",kf=700,tl="tooltip.open",[Cf,gd]=Ln(xd),yd=s=>{const{__scopeTooltip:t,delayDuration:r=kf,skipDelayDuration:a=300,disableHoverableContent:n=!1,children:i}=s,o=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const m=c.current;return()=>window.clearTimeout(m)},[]),e.jsx(Cf,{scope:t,isOpenDelayedRef:o,delayDuration:r,onOpen:d.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:d.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,a)},[a]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(m=>{l.current=m},[]),disableHoverableContent:n,children:i})};yd.displayName=xd;var bd="Tooltip",[mj,Fn]=Ln(bd),ki="TooltipTrigger",Ef=d.forwardRef((s,t)=>{const{__scopeTooltip:r,...a}=s,n=Fn(ki,r),i=gd(ki,r),o=wo(r),l=d.useRef(null),c=rt(t,l,n.onTriggerChange),m=d.useRef(!1),p=d.useRef(!1),x=d.useCallback(()=>m.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",x),[x]),e.jsx(Ec,{asChild:!0,...o,children:e.jsx(Xe.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...a,ref:c,onPointerMove:De(s.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),p.current=!0)}),onPointerLeave:De(s.onPointerLeave,()=>{n.onTriggerLeave(),p.current=!1}),onPointerDown:De(s.onPointerDown,()=>{n.open&&n.onClose(),m.current=!0,document.addEventListener("pointerup",x,{once:!0})}),onFocus:De(s.onFocus,()=>{m.current||n.onOpen()}),onBlur:De(s.onBlur,n.onClose),onClick:De(s.onClick,n.onClose)})})});Ef.displayName=ki;var Tf="TooltipPortal",[hj,Pf]=Ln(Tf,{forceMount:void 0}),na="TooltipContent",vd=d.forwardRef((s,t)=>{const r=Pf(na,s.__scopeTooltip),{forceMount:a=r.forceMount,side:n="top",...i}=s,o=Fn(na,s.__scopeTooltip);return e.jsx(fa,{present:a||o.open,children:o.disableHoverableContent?e.jsx(jd,{side:n,...i,ref:t}):e.jsx(Af,{side:n,...i,ref:t})})}),Af=d.forwardRef((s,t)=>{const r=Fn(na,s.__scopeTooltip),a=gd(na,s.__scopeTooltip),n=d.useRef(null),i=rt(t,n),[o,l]=d.useState(null),{trigger:c,onClose:m}=r,p=n.current,{onPointerInTransitChange:x}=a,g=d.useCallback(()=>{l(null),x(!1)},[x]),u=d.useCallback((y,h)=>{const f=y.currentTarget,b={x:y.clientX,y:y.clientY},v=Df(b,f.getBoundingClientRect()),j=Lf(b,v),_=Ff(h.getBoundingClientRect()),I=zf([...j,..._]);l(I),x(!0)},[x]);return d.useEffect(()=>()=>g(),[g]),d.useEffect(()=>{if(c&&p){const y=f=>u(f,p),h=f=>u(f,c);return c.addEventListener("pointerleave",y),p.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",h)}}},[c,p,u,g]),d.useEffect(()=>{if(o){const y=h=>{const f=h.target,b={x:h.clientX,y:h.clientY},v=(c==null?void 0:c.contains(f))||(p==null?void 0:p.contains(f)),j=!qf(b,o);v?g():j&&(g(),m())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[c,p,o,m,g]),e.jsx(jd,{...s,ref:i})}),[Rf,Mf]=Ln(bd,{isInside:!1}),If=Sf("TooltipContent"),jd=d.forwardRef((s,t)=>{const{__scopeTooltip:r,children:a,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=s,c=Fn(na,r),m=wo(r),{onClose:p}=c;return d.useEffect(()=>(document.addEventListener(tl,p),()=>document.removeEventListener(tl,p)),[p]),d.useEffect(()=>{if(c.trigger){const x=g=>{const u=g.target;u!=null&&u.contains(c.trigger)&&p()};return window.addEventListener("scroll",x,{capture:!0}),()=>window.removeEventListener("scroll",x,{capture:!0})}},[c.trigger,p]),e.jsx(kc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:x=>x.preventDefault(),onDismiss:p,children:e.jsxs(Cc,{"data-state":c.stateAttribute,...m,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(If,{children:a}),e.jsx(Rf,{scope:r,isInside:!0,children:e.jsx(Fm,{id:c.contentId,role:"tooltip",children:n||a})})]})})});vd.displayName=na;var wd="TooltipArrow",Of=d.forwardRef((s,t)=>{const{__scopeTooltip:r,...a}=s,n=wo(r);return Mf(wd,r).isInside?null:e.jsx(Tc,{...n,...a,ref:t})});Of.displayName=wd;function Df(s,t){const r=Math.abs(t.top-s.y),a=Math.abs(t.bottom-s.y),n=Math.abs(t.right-s.x),i=Math.abs(t.left-s.x);switch(Math.min(r,a,n,i)){case i:return"left";case n:return"right";case r:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Lf(s,t,r=5){const a=[];switch(t){case"top":a.push({x:s.x-r,y:s.y+r},{x:s.x+r,y:s.y+r});break;case"bottom":a.push({x:s.x-r,y:s.y-r},{x:s.x+r,y:s.y-r});break;case"left":a.push({x:s.x+r,y:s.y-r},{x:s.x+r,y:s.y+r});break;case"right":a.push({x:s.x-r,y:s.y-r},{x:s.x-r,y:s.y+r});break}return a}function Ff(s){const{top:t,right:r,bottom:a,left:n}=s;return[{x:n,y:t},{x:r,y:t},{x:r,y:a},{x:n,y:a}]}function qf(s,t){const{x:r,y:a}=s;let n=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],c=t[o],m=l.x,p=l.y,x=c.x,g=c.y;p>a!=g>a&&r<(x-m)*(a-p)/(g-p)+m&&(n=!n)}return n}function zf(s){const t=s.slice();return t.sort((r,a)=>r.x<a.x?-1:r.x>a.x?1:r.y<a.y?-1:r.y>a.y?1:0),$f(t)}function $f(s){if(s.length<=1)return s.slice();const t=[];for(let a=0;a<s.length;a++){const n=s[a];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(n.y-o.y)>=(i.y-o.y)*(n.x-o.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let a=s.length-1;a>=0;a--){const n=s[a];for(;r.length>=2;){const i=r[r.length-1],o=r[r.length-2];if((i.x-o.x)*(n.y-o.y)>=(i.y-o.y)*(n.x-o.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var Bf=yd,Nd=vd;const Uf=Bf,Hf=d.forwardRef(({className:s,sideOffset:t=4,...r},a)=>e.jsx(Nd,{ref:a,sideOffset:t,className:me("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r}));Hf.displayName=Nd.displayName;const Vf="https://fnlyuabpiqwqaohztdbn.supabase.co",Wf="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZubHl1YWJwaXF3cWFvaHp0ZGJuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njk2ODcxODMsImV4cCI6MjA4NTI2MzE4M30.OPATC_t7FgwoC7f_mA5TVLpiylh-l9nbC8vWrlMt8Q4",M=dh(Vf,Wf,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),sl="moenv_geo_data",Kf=1440*60*1e3;let cr=null,Xa=null;function Gf(){if(cr)return cr;try{const s=sessionStorage.getItem("moenv_session_id");if(s)return cr=s,s;cr=crypto.randomUUID(),sessionStorage.setItem("moenv_session_id",cr)}catch{cr=crypto.randomUUID()}return cr}async function Yf(){if(Xa)return Xa;try{const s=sessionStorage.getItem(sl);if(s){const{data:t,timestamp:r}=JSON.parse(s);if(Date.now()-r<Kf)return Xa=t,t}}catch{}try{const s=new AbortController,t=setTimeout(()=>s.abort(),3e3),r=await fetch("https://ipapi.co/json/",{signal:s.signal,mode:"cors"});if(clearTimeout(t),r.ok){const a=await r.json();if(!a.error&&a.country_name){const n={country:a.country_name,city:a.city,region:a.region,latitude:a.latitude,longitude:a.longitude};Xa=n;try{sessionStorage.setItem(sl,JSON.stringify({data:n,timestamp:Date.now()}))}catch{}return n}}}catch{}return{}}function Qf(){const s=navigator.userAgent.toLowerCase();return/tablet|ipad|playbook|silk/i.test(s)?"tablet":/mobile|iphone|ipod|android|blackberry|opera mini|opera mobi|iemobile/i.test(s)?"mobile":"desktop"}async function Zf(s){try{const t=Gf(),r=navigator.userAgent,a=document.referrer||null,n=Qf(),i=await Yf(),{error:o}=await M.from("page_views").insert({page_path:s,session_id:t,user_agent:r,referrer:a,device_type:n,country:i.country||null,city:i.city||null});o&&console.error("Error tracking page view:",o)}catch(t){console.debug("Analytics tracking skipped:",t)}}function Jf(){const s=An();d.useEffect(()=>{Zf(s.pathname)},[s.pathname])}function Xf(){return Jf(),null}const ex=()=>{const{pathname:s}=An();return d.useEffect(()=>{window.scrollTo({top:0,left:0,behavior:"instant"});const t=setTimeout(()=>{window.scrollTo({top:0,left:0,behavior:"instant"})},0);return()=>clearTimeout(t)},[s]),null},tx=()=>e.jsx("div",{className:"fixed bottom-8 right-8 z-50 sm:bottom-10 sm:right-10 flex items-center gap-3",children:e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 animate-ping rounded-full bg-[#25D366] opacity-30 pointer-events-none"}),e.jsx("div",{className:"absolute inset-0 animate-pulse-scale rounded-full bg-[#25D366] opacity-20 scale-150 pointer-events-none"}),e.jsx("a",{href:"https://wa.me/447394382060",target:"_blank",rel:"noopener noreferrer",className:me("relative z-10 flex h-14 w-14 items-center justify-center rounded-full bg-[#25D366] text-white shadow-[0_8px_30px_rgb(37,211,102,0.4)] transition-all duration-500 hover:scale-110 active:scale-95 border-2 border-white/20"),"aria-label":"Contact us on WhatsApp",children:e.jsx("svg",{viewBox:"0 0 24 24",className:"h-8 w-8 fill-current",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"})})})]})});var sx=Symbol.for("react.lazy"),yn=sh[" use ".trim().toString()];function rx(s){return typeof s=="object"&&s!==null&&"then"in s}function _d(s){return s!=null&&typeof s=="object"&&"$$typeof"in s&&s.$$typeof===sx&&"_payload"in s&&rx(s._payload)}function qn(s){const t=nx(s),r=d.forwardRef((a,n)=>{let{children:i,...o}=a;_d(i)&&typeof yn=="function"&&(i=yn(i._payload));const l=d.Children.toArray(i),c=l.find(ox);if(c){const m=c.props.children,p=l.map(x=>x===c?d.Children.count(m)>1?d.Children.only(null):d.isValidElement(m)?m.props.children:null:x);return e.jsx(t,{...o,ref:n,children:d.isValidElement(m)?d.cloneElement(m,void 0,p):null})}return e.jsx(t,{...o,ref:n,children:i})});return r.displayName=`${s}.Slot`,r}var ax=qn("Slot");function nx(s){const t=d.forwardRef((r,a)=>{let{children:n,...i}=r;if(_d(n)&&typeof yn=="function"&&(n=yn(n._payload)),d.isValidElement(n)){const o=cx(n),l=lx(i,n.props);return n.type!==d.Fragment&&(l.ref=a?Pc(a,o):o),d.cloneElement(n,l)}return d.Children.count(n)>1?d.Children.only(null):null});return t.displayName=`${s}.SlotClone`,t}var ix=Symbol("radix.slottable");function ox(s){return d.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===ix}function lx(s,t){const r={...t};for(const a in t){const n=s[a],i=t[a];/^on[A-Z]/.test(a)?n&&i?r[a]=(...l)=>{const c=i(...l);return n(...l),c}:n&&(r[a]=n):a==="style"?r[a]={...n,...i}:a==="className"&&(r[a]=[n,i].filter(Boolean).join(" "))}return{...s,...r}}function cx(s){var a,n;let t=(a=Object.getOwnPropertyDescriptor(s.props,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?s.ref:(t=(n=Object.getOwnPropertyDescriptor(s,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?s.props.ref:s.props.ref||s.ref)}const dx=Wa("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),R=d.forwardRef(({className:s,variant:t,size:r,asChild:a=!1,...n},i)=>{const o=a?ax:"button";return e.jsx(o,{className:me(dx({variant:t,size:r,className:s})),ref:i,...n})});R.displayName="Button";const Sd=d.createContext(void 0);function ux({children:s}){const[t,r]=d.useState(null),[a,n]=d.useState(null),[i,o]=d.useState(!0),[l,c]=d.useState(!1),[m,p]=d.useState(null),x=d.useCallback(async b=>{var _,I;const{data:v,error:j}=await M.from("profiles").select("id").eq("user_id",b.id).maybeSingle();j||v||await M.from("profiles").insert({user_id:b.id,email:b.email??null,full_name:((_=b.user_metadata)==null?void 0:_.full_name)??((I=b.user_metadata)==null?void 0:I.name)??null})},[]),g=d.useCallback(async b=>{const{data:v,error:j}=await M.from("user_roles").select("role").eq("user_id",b).maybeSingle();if(!j&&v){const _=v.role;p(_),c(_==="admin"||["marketing","shipping","support","content"].includes(_))}else p("user"),c(!1)},[]),u=d.useCallback(async()=>{t&&await g(t.id)},[t,g]);d.useEffect(()=>{const{data:{subscription:b}}=M.auth.onAuthStateChange((v,j)=>{n(j),r((j==null?void 0:j.user)??null),j!=null&&j.user?setTimeout(()=>{x(j.user),g(j.user.id)},0):(c(!1),p(null))});return M.auth.getSession().then(({data:{session:v}})=>{n(v),r((v==null?void 0:v.user)??null),v!=null&&v.user&&setTimeout(()=>{x(v.user),g(v.user.id)},0),o(!1)}),()=>b.unsubscribe()},[g,x]);const y=async(b,v)=>{const{error:j}=await M.auth.signInWithPassword({email:b,password:v});return{error:j}},h=async(b,v)=>{const j=`${window.location.origin}/`,{error:_}=await M.auth.signUp({email:b,password:v,options:{emailRedirectTo:j}});return{error:_}},f=async()=>{await M.auth.signOut(),c(!1),p(null)};return e.jsx(Sd.Provider,{value:{user:t,session:a,isLoading:i,isAdmin:l,userRole:m,signIn:y,signUp:h,signOut:f,refreshAdminStatus:u},children:s})}function Bt(){const s=d.useContext(Sd);if(s===void 0)throw new Error("useAuth must be used within an AuthProvider");return s}const ei="moenviron-cart";function mx(){const[s,t]=d.useState([]),[r,a]=d.useState(0),n=d.useCallback(()=>{const o=localStorage.getItem(ei),l=o?JSON.parse(o):[];t(l),a(l.reduce((c,m)=>c+m.quantity,0))},[]);return d.useEffect(()=>{n();const o=c=>{c.key===ei&&n()},l=()=>n();return window.addEventListener("storage",o),window.addEventListener("cart-updated",l),()=>{window.removeEventListener("storage",o),window.removeEventListener("cart-updated",l)}},[n]),{items:s,itemCount:r,updateCart:o=>{localStorage.setItem(ei,JSON.stringify(o)),t(o),a(o.reduce((l,c)=>l+c.quantity,0)),window.dispatchEvent(new CustomEvent("cart-updated"))},loadCart:n}}var ya=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(s){return this.listeners.add(s),this.onSubscribe(),()=>{this.listeners.delete(s),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},hx={setTimeout:(s,t)=>setTimeout(s,t),clearTimeout:s=>clearTimeout(s),setInterval:(s,t)=>setInterval(s,t),clearInterval:s=>clearInterval(s)},Us,oo,cc,px=(cc=class{constructor(){he(this,Us,hx);he(this,oo,!1)}setTimeoutProvider(s){Y(this,Us,s)}setTimeout(s,t){return w(this,Us).setTimeout(s,t)}clearTimeout(s){w(this,Us).clearTimeout(s)}setInterval(s,t){return w(this,Us).setInterval(s,t)}clearInterval(s){w(this,Us).clearInterval(s)}},Us=new WeakMap,oo=new WeakMap,cc),ur=new px;function fx(s){setTimeout(s,0)}var Sr=typeof window>"u"||"Deno"in globalThis;function jt(){}function xx(s,t){return typeof s=="function"?s(t):s}function Ci(s){return typeof s=="number"&&s>=0&&s!==1/0}function kd(s,t){return Math.max(s+(t||0)-Date.now(),0)}function Xs(s,t){return typeof s=="function"?s(t):s}function Ft(s,t){return typeof s=="function"?s(t):s}function rl(s,t){const{type:r="all",exact:a,fetchStatus:n,predicate:i,queryKey:o,stale:l}=s;if(o){if(a){if(t.queryHash!==No(o,t.options))return!1}else if(!Ma(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||n&&n!==t.state.fetchStatus||i&&!i(t))}function al(s,t){const{exact:r,status:a,predicate:n,mutationKey:i}=s;if(i){if(!t.options.mutationKey)return!1;if(r){if(kr(t.options.mutationKey)!==kr(i))return!1}else if(!Ma(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||n&&!n(t))}function No(s,t){return((t==null?void 0:t.queryKeyHashFn)||kr)(s)}function kr(s){return JSON.stringify(s,(t,r)=>Ei(r)?Object.keys(r).sort().reduce((a,n)=>(a[n]=r[n],a),{}):r)}function Ma(s,t){return s===t?!0:typeof s!=typeof t?!1:s&&t&&typeof s=="object"&&typeof t=="object"?Object.keys(t).every(r=>Ma(s[r],t[r])):!1}var gx=Object.prototype.hasOwnProperty;function Cd(s,t,r=0){if(s===t)return s;if(r>500)return t;const a=nl(s)&&nl(t);if(!a&&!(Ei(s)&&Ei(t)))return t;const i=(a?s:Object.keys(s)).length,o=a?t:Object.keys(t),l=o.length,c=a?new Array(l):{};let m=0;for(let p=0;p<l;p++){const x=a?p:o[p],g=s[x],u=t[x];if(g===u){c[x]=g,(a?p<i:gx.call(s,x))&&m++;continue}if(g===null||u===null||typeof g!="object"||typeof u!="object"){c[x]=u;continue}const y=Cd(g,u,r+1);c[x]=y,y===g&&m++}return i===l&&m===i?s:c}function bn(s,t){if(!t||Object.keys(s).length!==Object.keys(t).length)return!1;for(const r in s)if(s[r]!==t[r])return!1;return!0}function nl(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function Ei(s){if(!il(s))return!1;const t=s.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!il(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(s)!==Object.prototype)}function il(s){return Object.prototype.toString.call(s)==="[object Object]"}function yx(s){return new Promise(t=>{ur.setTimeout(t,s)})}function Ti(s,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(s,t):r.structuralSharing!==!1?Cd(s,t):t}function bx(s,t,r=0){const a=[...s,t];return r&&a.length>r?a.slice(1):a}function vx(s,t,r=0){const a=[t,...s];return r&&a.length>r?a.slice(0,-1):a}var _o=Symbol();function Ed(s,t){return!s.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!s.queryFn||s.queryFn===_o?()=>Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)):s.queryFn}function So(s,t){return typeof s=="function"?s(...t):!!s}function jx(s,t,r){let a=!1,n;return Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(n??(n=t()),a||(a=!0,n.aborted?r():n.addEventListener("abort",r,{once:!0})),n)}),s}var mr,Hs,Vr,dc,wx=(dc=class extends ya{constructor(){super();he(this,mr);he(this,Hs);he(this,Vr);Y(this,Vr,t=>{if(!Sr&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){w(this,Hs)||this.setEventListener(w(this,Vr))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,Hs))==null||t.call(this),Y(this,Hs,void 0))}setEventListener(t){var r;Y(this,Vr,t),(r=w(this,Hs))==null||r.call(this),Y(this,Hs,t(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()}))}setFocused(t){w(this,mr)!==t&&(Y(this,mr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof w(this,mr)=="boolean"?w(this,mr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},mr=new WeakMap,Hs=new WeakMap,Vr=new WeakMap,dc),ko=new wx;function Pi(){let s,t;const r=new Promise((n,i)=>{s=n,t=i});r.status="pending",r.catch(()=>{});function a(n){Object.assign(r,n),delete r.resolve,delete r.reject}return r.resolve=n=>{a({status:"fulfilled",value:n}),s(n)},r.reject=n=>{a({status:"rejected",reason:n}),t(n)},r}var Nx=fx;function _x(){let s=[],t=0,r=l=>{l()},a=l=>{l()},n=Nx;const i=l=>{t?s.push(l):n(()=>{r(l)})},o=()=>{const l=s;s=[],l.length&&n(()=>{a(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{a=l},setScheduler:l=>{n=l}}}var dt=_x(),Wr,Vs,Kr,uc,Sx=(uc=class extends ya{constructor(){super();he(this,Wr,!0);he(this,Vs);he(this,Kr);Y(this,Kr,t=>{if(!Sr&&window.addEventListener){const r=()=>t(!0),a=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",a)}}})}onSubscribe(){w(this,Vs)||this.setEventListener(w(this,Kr))}onUnsubscribe(){var t;this.hasListeners()||((t=w(this,Vs))==null||t.call(this),Y(this,Vs,void 0))}setEventListener(t){var r;Y(this,Kr,t),(r=w(this,Vs))==null||r.call(this),Y(this,Vs,t(this.setOnline.bind(this)))}setOnline(t){w(this,Wr)!==t&&(Y(this,Wr,t),this.listeners.forEach(a=>{a(t)}))}isOnline(){return w(this,Wr)}},Wr=new WeakMap,Vs=new WeakMap,Kr=new WeakMap,uc),vn=new Sx;function kx(s){return Math.min(1e3*2**s,3e4)}function Td(s){return(s??"online")==="online"?vn.isOnline():!0}var Ai=class extends Error{constructor(s){super("CancelledError"),this.revert=s==null?void 0:s.revert,this.silent=s==null?void 0:s.silent}};function Pd(s){let t=!1,r=0,a;const n=Pi(),i=()=>n.status!=="pending",o=h=>{var f;if(!i()){const b=new Ai(h);g(b),(f=s.onCancel)==null||f.call(s,b)}},l=()=>{t=!0},c=()=>{t=!1},m=()=>ko.isFocused()&&(s.networkMode==="always"||vn.isOnline())&&s.canRun(),p=()=>Td(s.networkMode)&&s.canRun(),x=h=>{i()||(a==null||a(),n.resolve(h))},g=h=>{i()||(a==null||a(),n.reject(h))},u=()=>new Promise(h=>{var f;a=b=>{(i()||m())&&h(b)},(f=s.onPause)==null||f.call(s)}).then(()=>{var h;a=void 0,i()||(h=s.onContinue)==null||h.call(s)}),y=()=>{if(i())return;let h;const f=r===0?s.initialPromise:void 0;try{h=f??s.fn()}catch(b){h=Promise.reject(b)}Promise.resolve(h).then(x).catch(b=>{var E;if(i())return;const v=s.retry??(Sr?0:3),j=s.retryDelay??kx,_=typeof j=="function"?j(r,b):j,I=v===!0||typeof v=="number"&&r<v||typeof v=="function"&&v(r,b);if(t||!I){g(b);return}r++,(E=s.onFail)==null||E.call(s,r,b),yx(_).then(()=>m()?void 0:u()).then(()=>{t?g(b):y()})})};return{promise:n,status:()=>n.status,cancel:o,continue:()=>(a==null||a(),n),cancelRetry:l,continueRetry:c,canStart:p,start:()=>(p()?y():u().then(y),n)}}var hr,mc,Ad=(mc=class{constructor(){he(this,hr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ci(this.gcTime)&&Y(this,hr,ur.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(s){this.gcTime=Math.max(this.gcTime||0,s??(Sr?1/0:300*1e3))}clearGcTimeout(){w(this,hr)&&(ur.clearTimeout(w(this,hr)),Y(this,hr,void 0))}},hr=new WeakMap,mc),pr,Gr,Lt,fr,ht,$a,xr,Xt,Ns,hc,Cx=(hc=class extends Ad{constructor(t){super();he(this,Xt);he(this,pr);he(this,Gr);he(this,Lt);he(this,fr);he(this,ht);he(this,$a);he(this,xr);Y(this,xr,!1),Y(this,$a,t.defaultOptions),this.setOptions(t.options),this.observers=[],Y(this,fr,t.client),Y(this,Lt,w(this,fr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Y(this,pr,ll(this.options)),this.state=t.state??w(this,pr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=w(this,ht))==null?void 0:t.promise}setOptions(t){if(this.options={...w(this,$a),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=ll(this.options);r.data!==void 0&&(this.setState(ol(r.data,r.dataUpdatedAt)),Y(this,pr,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&w(this,Lt).remove(this)}setData(t,r){const a=Ti(this.state.data,t,this.options);return Ae(this,Xt,Ns).call(this,{data:a,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),a}setState(t,r){Ae(this,Xt,Ns).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var a,n;const r=(a=w(this,ht))==null?void 0:a.promise;return(n=w(this,ht))==null||n.cancel(t),r?r.then(jt).catch(jt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(w(this,pr))}isActive(){return this.observers.some(t=>Ft(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_o||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Xs(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!kd(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(a=>a.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=w(this,ht))==null||r.continue()}onOnline(){var r;const t=this.observers.find(a=>a.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=w(this,ht))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),w(this,Lt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(w(this,ht)&&(w(this,xr)?w(this,ht).cancel({revert:!0}):w(this,ht).cancelRetry()),this.scheduleGc()),w(this,Lt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Xt,Ns).call(this,{type:"invalidate"})}async fetch(t,r){var c,m,p,x,g,u,y,h,f,b,v,j;if(this.state.fetchStatus!=="idle"&&((c=w(this,ht))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(w(this,ht))return w(this,ht).continueRetry(),w(this,ht).promise}if(t&&this.setOptions(t),!this.options.queryFn){const _=this.observers.find(I=>I.options.queryFn);_&&this.setOptions(_.options)}const a=new AbortController,n=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(Y(this,xr,!0),a.signal)})},i=()=>{const _=Ed(this.options,r),E=(()=>{const O={client:w(this,fr),queryKey:this.queryKey,meta:this.meta};return n(O),O})();return Y(this,xr,!1),this.options.persister?this.options.persister(_,E,this):_(E)},l=(()=>{const _={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:w(this,fr),state:this.state,fetchFn:i};return n(_),_})();(m=this.options.behavior)==null||m.onFetch(l,this),Y(this,Gr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=l.fetchOptions)==null?void 0:p.meta))&&Ae(this,Xt,Ns).call(this,{type:"fetch",meta:(x=l.fetchOptions)==null?void 0:x.meta}),Y(this,ht,Pd({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:_=>{_ instanceof Ai&&_.revert&&this.setState({...w(this,Gr),fetchStatus:"idle"}),a.abort()},onFail:(_,I)=>{Ae(this,Xt,Ns).call(this,{type:"failed",failureCount:_,error:I})},onPause:()=>{Ae(this,Xt,Ns).call(this,{type:"pause"})},onContinue:()=>{Ae(this,Xt,Ns).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const _=await w(this,ht).start();if(_===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(_),(u=(g=w(this,Lt).config).onSuccess)==null||u.call(g,_,this),(h=(y=w(this,Lt).config).onSettled)==null||h.call(y,_,this.state.error,this),_}catch(_){if(_ instanceof Ai){if(_.silent)return w(this,ht).promise;if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw Ae(this,Xt,Ns).call(this,{type:"error",error:_}),(b=(f=w(this,Lt).config).onError)==null||b.call(f,_,this),(j=(v=w(this,Lt).config).onSettled)==null||j.call(v,this.state.data,_,this),_}finally{this.scheduleGc()}}},pr=new WeakMap,Gr=new WeakMap,Lt=new WeakMap,fr=new WeakMap,ht=new WeakMap,$a=new WeakMap,xr=new WeakMap,Xt=new WeakSet,Ns=function(t){const r=a=>{switch(t.type){case"failed":return{...a,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,...Rd(a.data,this.options),fetchMeta:t.meta??null};case"success":const n={...a,...ol(t.data,t.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Y(this,Gr,t.manual?n:void 0),n;case"error":const i=t.error;return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...t.state}}};this.state=r(this.state),dt.batch(()=>{this.observers.forEach(a=>{a.onQueryUpdate()}),w(this,Lt).notify({query:this,type:"updated",action:t})})},hc);function Rd(s,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Td(t.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}function ol(s,t){return{data:s,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ll(s){const t=typeof s.initialData=="function"?s.initialData():s.initialData,r=t!==void 0,a=r?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var St,Me,Ba,bt,gr,Yr,_s,Ws,Ua,Qr,Zr,yr,br,Ks,Jr,Ue,Ea,Ri,Mi,Ii,Oi,Di,Li,Fi,Md,pc,Ex=(pc=class extends ya{constructor(t,r){super();he(this,Ue);he(this,St);he(this,Me);he(this,Ba);he(this,bt);he(this,gr);he(this,Yr);he(this,_s);he(this,Ws);he(this,Ua);he(this,Qr);he(this,Zr);he(this,yr);he(this,br);he(this,Ks);he(this,Jr,new Set);this.options=r,Y(this,St,t),Y(this,Ws,null),Y(this,_s,Pi()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(w(this,Me).addObserver(this),cl(w(this,Me),this.options)?Ae(this,Ue,Ea).call(this):this.updateResult(),Ae(this,Ue,Oi).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return qi(w(this,Me),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return qi(w(this,Me),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,Ue,Di).call(this),Ae(this,Ue,Li).call(this),w(this,Me).removeObserver(this)}setOptions(t){const r=this.options,a=w(this,Me);if(this.options=w(this,St).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ft(this.options.enabled,w(this,Me))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,Ue,Fi).call(this),w(this,Me).setOptions(this.options),r._defaulted&&!bn(this.options,r)&&w(this,St).getQueryCache().notify({type:"observerOptionsUpdated",query:w(this,Me),observer:this});const n=this.hasListeners();n&&dl(w(this,Me),a,this.options,r)&&Ae(this,Ue,Ea).call(this),this.updateResult(),n&&(w(this,Me)!==a||Ft(this.options.enabled,w(this,Me))!==Ft(r.enabled,w(this,Me))||Xs(this.options.staleTime,w(this,Me))!==Xs(r.staleTime,w(this,Me)))&&Ae(this,Ue,Ri).call(this);const i=Ae(this,Ue,Mi).call(this);n&&(w(this,Me)!==a||Ft(this.options.enabled,w(this,Me))!==Ft(r.enabled,w(this,Me))||i!==w(this,Ks))&&Ae(this,Ue,Ii).call(this,i)}getOptimisticResult(t){const r=w(this,St).getQueryCache().build(w(this,St),t),a=this.createResult(r,t);return Px(this,a)&&(Y(this,bt,a),Y(this,Yr,this.options),Y(this,gr,w(this,Me).state)),a}getCurrentResult(){return w(this,bt)}trackResult(t,r){return new Proxy(t,{get:(a,n)=>(this.trackProp(n),r==null||r(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&w(this,_s).status==="pending"&&w(this,_s).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(a,n))})}trackProp(t){w(this,Jr).add(t)}getCurrentQuery(){return w(this,Me)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=w(this,St).defaultQueryOptions(t),a=w(this,St).getQueryCache().build(w(this,St),r);return a.fetch().then(()=>this.createResult(a,r))}fetch(t){return Ae(this,Ue,Ea).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),w(this,bt)))}createResult(t,r){var N;const a=w(this,Me),n=this.options,i=w(this,bt),o=w(this,gr),l=w(this,Yr),m=t!==a?t.state:w(this,Ba),{state:p}=t;let x={...p},g=!1,u;if(r._optimisticResults){const T=this.hasListeners(),P=!T&&cl(t,r),S=T&&dl(t,a,r,n);(P||S)&&(x={...x,...Rd(p.data,t.options)}),r._optimisticResults==="isRestoring"&&(x.fetchStatus="idle")}let{error:y,errorUpdatedAt:h,status:f}=x;u=x.data;let b=!1;if(r.placeholderData!==void 0&&u===void 0&&f==="pending"){let T;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(T=i.data,b=!0):T=typeof r.placeholderData=="function"?r.placeholderData((N=w(this,Zr))==null?void 0:N.state.data,w(this,Zr)):r.placeholderData,T!==void 0&&(f="success",u=Ti(i==null?void 0:i.data,T,r),g=!0)}if(r.select&&u!==void 0&&!b)if(i&&u===(o==null?void 0:o.data)&&r.select===w(this,Ua))u=w(this,Qr);else try{Y(this,Ua,r.select),u=r.select(u),u=Ti(i==null?void 0:i.data,u,r),Y(this,Qr,u),Y(this,Ws,null)}catch(T){Y(this,Ws,T)}w(this,Ws)&&(y=w(this,Ws),u=w(this,Qr),h=Date.now(),f="error");const v=x.fetchStatus==="fetching",j=f==="pending",_=f==="error",I=j&&v,E=u!==void 0,D={status:f,fetchStatus:x.fetchStatus,isPending:j,isSuccess:f==="success",isError:_,isInitialLoading:I,isLoading:I,data:u,dataUpdatedAt:x.dataUpdatedAt,error:y,errorUpdatedAt:h,failureCount:x.fetchFailureCount,failureReason:x.fetchFailureReason,errorUpdateCount:x.errorUpdateCount,isFetched:x.dataUpdateCount>0||x.errorUpdateCount>0,isFetchedAfterMount:x.dataUpdateCount>m.dataUpdateCount||x.errorUpdateCount>m.errorUpdateCount,isFetching:v,isRefetching:v&&!j,isLoadingError:_&&!E,isPaused:x.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:_&&E,isStale:Co(t,r),refetch:this.refetch,promise:w(this,_s),isEnabled:Ft(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const T=W=>{D.status==="error"?W.reject(D.error):D.data!==void 0&&W.resolve(D.data)},P=()=>{const W=Y(this,_s,D.promise=Pi());T(W)},S=w(this,_s);switch(S.status){case"pending":t.queryHash===a.queryHash&&T(S);break;case"fulfilled":(D.status==="error"||D.data!==S.value)&&P();break;case"rejected":(D.status!=="error"||D.error!==S.reason)&&P();break}}return D}updateResult(){const t=w(this,bt),r=this.createResult(w(this,Me),this.options);if(Y(this,gr,w(this,Me).state),Y(this,Yr,this.options),w(this,gr).data!==void 0&&Y(this,Zr,w(this,Me)),bn(r,t))return;Y(this,bt,r);const a=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!w(this,Jr).size)return!0;const o=new Set(i??w(this,Jr));return this.options.throwOnError&&o.add("error"),Object.keys(w(this,bt)).some(l=>{const c=l;return w(this,bt)[c]!==t[c]&&o.has(c)})};Ae(this,Ue,Md).call(this,{listeners:a()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,Ue,Oi).call(this)}},St=new WeakMap,Me=new WeakMap,Ba=new WeakMap,bt=new WeakMap,gr=new WeakMap,Yr=new WeakMap,_s=new WeakMap,Ws=new WeakMap,Ua=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,yr=new WeakMap,br=new WeakMap,Ks=new WeakMap,Jr=new WeakMap,Ue=new WeakSet,Ea=function(t){Ae(this,Ue,Fi).call(this);let r=w(this,Me).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(jt)),r},Ri=function(){Ae(this,Ue,Di).call(this);const t=Xs(this.options.staleTime,w(this,Me));if(Sr||w(this,bt).isStale||!Ci(t))return;const a=kd(w(this,bt).dataUpdatedAt,t)+1;Y(this,yr,ur.setTimeout(()=>{w(this,bt).isStale||this.updateResult()},a))},Mi=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(w(this,Me)):this.options.refetchInterval)??!1},Ii=function(t){Ae(this,Ue,Li).call(this),Y(this,Ks,t),!(Sr||Ft(this.options.enabled,w(this,Me))===!1||!Ci(w(this,Ks))||w(this,Ks)===0)&&Y(this,br,ur.setInterval(()=>{(this.options.refetchIntervalInBackground||ko.isFocused())&&Ae(this,Ue,Ea).call(this)},w(this,Ks)))},Oi=function(){Ae(this,Ue,Ri).call(this),Ae(this,Ue,Ii).call(this,Ae(this,Ue,Mi).call(this))},Di=function(){w(this,yr)&&(ur.clearTimeout(w(this,yr)),Y(this,yr,void 0))},Li=function(){w(this,br)&&(ur.clearInterval(w(this,br)),Y(this,br,void 0))},Fi=function(){const t=w(this,St).getQueryCache().build(w(this,St),this.options);if(t===w(this,Me))return;const r=w(this,Me);Y(this,Me,t),Y(this,Ba,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},Md=function(t){dt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(w(this,bt))}),w(this,St).getQueryCache().notify({query:w(this,Me),type:"observerResultsUpdated"})})},pc);function Tx(s,t){return Ft(t.enabled,s)!==!1&&s.state.data===void 0&&!(s.state.status==="error"&&t.retryOnMount===!1)}function cl(s,t){return Tx(s,t)||s.state.data!==void 0&&qi(s,t,t.refetchOnMount)}function qi(s,t,r){if(Ft(t.enabled,s)!==!1&&Xs(t.staleTime,s)!=="static"){const a=typeof r=="function"?r(s):r;return a==="always"||a!==!1&&Co(s,t)}return!1}function dl(s,t,r,a){return(s!==t||Ft(a.enabled,s)===!1)&&(!r.suspense||s.state.status!=="error")&&Co(s,r)}function Co(s,t){return Ft(t.enabled,s)!==!1&&s.isStaleByTime(Xs(t.staleTime,s))}function Px(s,t){return!bn(s.getCurrentResult(),t)}function ul(s){return{onFetch:(t,r)=>{var p,x,g,u,y;const a=t.options,n=(g=(x=(p=t.fetchOptions)==null?void 0:p.meta)==null?void 0:x.fetchMore)==null?void 0:g.direction,i=((u=t.state.data)==null?void 0:u.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const m=async()=>{let h=!1;const f=j=>{jx(j,()=>t.signal,()=>h=!0)},b=Ed(t.options,t.fetchOptions),v=async(j,_,I)=>{if(h)return Promise.reject();if(_==null&&j.pages.length)return Promise.resolve(j);const O=(()=>{const P={client:t.client,queryKey:t.queryKey,pageParam:_,direction:I?"backward":"forward",meta:t.options.meta};return f(P),P})(),D=await b(O),{maxPages:N}=t.options,T=I?vx:bx;return{pages:T(j.pages,D,N),pageParams:T(j.pageParams,_,N)}};if(n&&i.length){const j=n==="backward",_=j?Ax:ml,I={pages:i,pageParams:o},E=_(a,I);l=await v(I,E,j)}else{const j=s??i.length;do{const _=c===0?o[0]??a.initialPageParam:ml(a,l);if(c>0&&_==null)break;l=await v(l,_),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var h,f;return(f=(h=t.options).persister)==null?void 0:f.call(h,m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=m}}}function ml(s,{pages:t,pageParams:r}){const a=t.length-1;return t.length>0?s.getNextPageParam(t[a],t,r[a],r):void 0}function Ax(s,{pages:t,pageParams:r}){var a;return t.length>0?(a=s.getPreviousPageParam)==null?void 0:a.call(s,t[0],t,r[0],r):void 0}var Ha,ds,vt,vr,us,$s,fc,Rx=(fc=class extends Ad{constructor(t){super();he(this,us);he(this,Ha);he(this,ds);he(this,vt);he(this,vr);Y(this,Ha,t.client),this.mutationId=t.mutationId,Y(this,vt,t.mutationCache),Y(this,ds,[]),this.state=t.state||Id(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){w(this,ds).includes(t)||(w(this,ds).push(t),this.clearGcTimeout(),w(this,vt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Y(this,ds,w(this,ds).filter(r=>r!==t)),this.scheduleGc(),w(this,vt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){w(this,ds).length||(this.state.status==="pending"?this.scheduleGc():w(this,vt).remove(this))}continue(){var t;return((t=w(this,vr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,m,p,x,g,u,y,h,f,b,v,j,_,I,E,O,D,N;const r=()=>{Ae(this,us,$s).call(this,{type:"continue"})},a={client:w(this,Ha),meta:this.options.meta,mutationKey:this.options.mutationKey};Y(this,vr,Pd({fn:()=>this.options.mutationFn?this.options.mutationFn(t,a):Promise.reject(new Error("No mutationFn found")),onFail:(T,P)=>{Ae(this,us,$s).call(this,{type:"failed",failureCount:T,error:P})},onPause:()=>{Ae(this,us,$s).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>w(this,vt).canRun(this)}));const n=this.state.status==="pending",i=!w(this,vr).canStart();try{if(n)r();else{Ae(this,us,$s).call(this,{type:"pending",variables:t,isPaused:i}),await((l=(o=w(this,vt).config).onMutate)==null?void 0:l.call(o,t,this,a));const P=await((m=(c=this.options).onMutate)==null?void 0:m.call(c,t,a));P!==this.state.context&&Ae(this,us,$s).call(this,{type:"pending",context:P,variables:t,isPaused:i})}const T=await w(this,vr).start();return await((x=(p=w(this,vt).config).onSuccess)==null?void 0:x.call(p,T,t,this.state.context,this,a)),await((u=(g=this.options).onSuccess)==null?void 0:u.call(g,T,t,this.state.context,a)),await((h=(y=w(this,vt).config).onSettled)==null?void 0:h.call(y,T,null,this.state.variables,this.state.context,this,a)),await((b=(f=this.options).onSettled)==null?void 0:b.call(f,T,null,t,this.state.context,a)),Ae(this,us,$s).call(this,{type:"success",data:T}),T}catch(T){try{await((j=(v=w(this,vt).config).onError)==null?void 0:j.call(v,T,t,this.state.context,this,a))}catch(P){Promise.reject(P)}try{await((I=(_=this.options).onError)==null?void 0:I.call(_,T,t,this.state.context,a))}catch(P){Promise.reject(P)}try{await((O=(E=w(this,vt).config).onSettled)==null?void 0:O.call(E,void 0,T,this.state.variables,this.state.context,this,a))}catch(P){Promise.reject(P)}try{await((N=(D=this.options).onSettled)==null?void 0:N.call(D,void 0,T,t,this.state.context,a))}catch(P){Promise.reject(P)}throw Ae(this,us,$s).call(this,{type:"error",error:T}),T}finally{w(this,vt).runNext(this)}}},Ha=new WeakMap,ds=new WeakMap,vt=new WeakMap,vr=new WeakMap,us=new WeakSet,$s=function(t){const r=a=>{switch(t.type){case"failed":return{...a,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...a,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:t.error,failureCount:a.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),dt.batch(()=>{w(this,ds).forEach(a=>{a.onMutationUpdate(t)}),w(this,vt).notify({mutation:this,type:"updated",action:t})})},fc);function Id(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ss,es,Va,xc,Mx=(xc=class extends ya{constructor(t={}){super();he(this,Ss);he(this,es);he(this,Va);this.config=t,Y(this,Ss,new Set),Y(this,es,new Map),Y(this,Va,0)}build(t,r,a){const n=new Rx({client:t,mutationCache:this,mutationId:++Qa(this,Va)._,options:t.defaultMutationOptions(r),state:a});return this.add(n),n}add(t){w(this,Ss).add(t);const r=en(t);if(typeof r=="string"){const a=w(this,es).get(r);a?a.push(t):w(this,es).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(w(this,Ss).delete(t)){const r=en(t);if(typeof r=="string"){const a=w(this,es).get(r);if(a)if(a.length>1){const n=a.indexOf(t);n!==-1&&a.splice(n,1)}else a[0]===t&&w(this,es).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=en(t);if(typeof r=="string"){const a=w(this,es).get(r),n=a==null?void 0:a.find(i=>i.state.status==="pending");return!n||n===t}else return!0}runNext(t){var a;const r=en(t);if(typeof r=="string"){const n=(a=w(this,es).get(r))==null?void 0:a.find(i=>i!==t&&i.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){dt.batch(()=>{w(this,Ss).forEach(t=>{this.notify({type:"removed",mutation:t})}),w(this,Ss).clear(),w(this,es).clear()})}getAll(){return Array.from(w(this,Ss))}find(t){const r={exact:!0,...t};return this.getAll().find(a=>al(r,a))}findAll(t={}){return this.getAll().filter(r=>al(t,r))}notify(t){dt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return dt.batch(()=>Promise.all(t.map(r=>r.continue().catch(jt))))}},Ss=new WeakMap,es=new WeakMap,Va=new WeakMap,xc);function en(s){var t;return(t=s.options.scope)==null?void 0:t.id}var ks,Gs,kt,Cs,Ps,on,zi,gc,Ix=(gc=class extends ya{constructor(r,a){super();he(this,Ps);he(this,ks);he(this,Gs);he(this,kt);he(this,Cs);Y(this,ks,r),this.setOptions(a),this.bindMethods(),Ae(this,Ps,on).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var n;const a=this.options;this.options=w(this,ks).defaultMutationOptions(r),bn(this.options,a)||w(this,ks).getMutationCache().notify({type:"observerOptionsUpdated",mutation:w(this,kt),observer:this}),a!=null&&a.mutationKey&&this.options.mutationKey&&kr(a.mutationKey)!==kr(this.options.mutationKey)?this.reset():((n=w(this,kt))==null?void 0:n.state.status)==="pending"&&w(this,kt).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=w(this,kt))==null||r.removeObserver(this)}onMutationUpdate(r){Ae(this,Ps,on).call(this),Ae(this,Ps,zi).call(this,r)}getCurrentResult(){return w(this,Gs)}reset(){var r;(r=w(this,kt))==null||r.removeObserver(this),Y(this,kt,void 0),Ae(this,Ps,on).call(this),Ae(this,Ps,zi).call(this)}mutate(r,a){var n;return Y(this,Cs,a),(n=w(this,kt))==null||n.removeObserver(this),Y(this,kt,w(this,ks).getMutationCache().build(w(this,ks),this.options)),w(this,kt).addObserver(this),w(this,kt).execute(r)}},ks=new WeakMap,Gs=new WeakMap,kt=new WeakMap,Cs=new WeakMap,Ps=new WeakSet,on=function(){var a;const r=((a=w(this,kt))==null?void 0:a.state)??Id();Y(this,Gs,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},zi=function(r){dt.batch(()=>{var a,n,i,o,l,c,m,p;if(w(this,Cs)&&this.hasListeners()){const x=w(this,Gs).variables,g=w(this,Gs).context,u={client:w(this,ks),meta:this.options.meta,mutationKey:this.options.mutationKey};if((r==null?void 0:r.type)==="success"){try{(n=(a=w(this,Cs)).onSuccess)==null||n.call(a,r.data,x,g,u)}catch(y){Promise.reject(y)}try{(o=(i=w(this,Cs)).onSettled)==null||o.call(i,r.data,null,x,g,u)}catch(y){Promise.reject(y)}}else if((r==null?void 0:r.type)==="error"){try{(c=(l=w(this,Cs)).onError)==null||c.call(l,r.error,x,g,u)}catch(y){Promise.reject(y)}try{(p=(m=w(this,Cs)).onSettled)==null||p.call(m,void 0,r.error,x,g,u)}catch(y){Promise.reject(y)}}}this.listeners.forEach(x=>{x(w(this,Gs))})})},gc),ms,yc,Ox=(yc=class extends ya{constructor(t={}){super();he(this,ms);this.config=t,Y(this,ms,new Map)}build(t,r,a){const n=r.queryKey,i=r.queryHash??No(n,r);let o=this.get(i);return o||(o=new Cx({client:t,queryKey:n,queryHash:i,options:t.defaultQueryOptions(r),state:a,defaultOptions:t.getQueryDefaults(n)}),this.add(o)),o}add(t){w(this,ms).has(t.queryHash)||(w(this,ms).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=w(this,ms).get(t.queryHash);r&&(t.destroy(),r===t&&w(this,ms).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){dt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return w(this,ms).get(t)}getAll(){return[...w(this,ms).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(a=>rl(r,a))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(a=>rl(t,a)):r}notify(t){dt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){dt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){dt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ms=new WeakMap,yc),at,Ys,Qs,Xr,ea,Zs,ta,sa,bc,Dx=(bc=class{constructor(s={}){he(this,at);he(this,Ys);he(this,Qs);he(this,Xr);he(this,ea);he(this,Zs);he(this,ta);he(this,sa);Y(this,at,s.queryCache||new Ox),Y(this,Ys,s.mutationCache||new Mx),Y(this,Qs,s.defaultOptions||{}),Y(this,Xr,new Map),Y(this,ea,new Map),Y(this,Zs,0)}mount(){Qa(this,Zs)._++,w(this,Zs)===1&&(Y(this,ta,ko.subscribe(async s=>{s&&(await this.resumePausedMutations(),w(this,at).onFocus())})),Y(this,sa,vn.subscribe(async s=>{s&&(await this.resumePausedMutations(),w(this,at).onOnline())})))}unmount(){var s,t;Qa(this,Zs)._--,w(this,Zs)===0&&((s=w(this,ta))==null||s.call(this),Y(this,ta,void 0),(t=w(this,sa))==null||t.call(this),Y(this,sa,void 0))}isFetching(s){return w(this,at).findAll({...s,fetchStatus:"fetching"}).length}isMutating(s){return w(this,Ys).findAll({...s,status:"pending"}).length}getQueryData(s){var r;const t=this.defaultQueryOptions({queryKey:s});return(r=w(this,at).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(s){const t=this.defaultQueryOptions(s),r=w(this,at).build(this,t),a=r.state.data;return a===void 0?this.fetchQuery(s):(s.revalidateIfStale&&r.isStaleByTime(Xs(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(a))}getQueriesData(s){return w(this,at).findAll(s).map(({queryKey:t,state:r})=>{const a=r.data;return[t,a]})}setQueryData(s,t,r){const a=this.defaultQueryOptions({queryKey:s}),n=w(this,at).get(a.queryHash),i=n==null?void 0:n.state.data,o=xx(t,i);if(o!==void 0)return w(this,at).build(this,a).setData(o,{...r,manual:!0})}setQueriesData(s,t,r){return dt.batch(()=>w(this,at).findAll(s).map(({queryKey:a})=>[a,this.setQueryData(a,t,r)]))}getQueryState(s){var r;const t=this.defaultQueryOptions({queryKey:s});return(r=w(this,at).get(t.queryHash))==null?void 0:r.state}removeQueries(s){const t=w(this,at);dt.batch(()=>{t.findAll(s).forEach(r=>{t.remove(r)})})}resetQueries(s,t){const r=w(this,at);return dt.batch(()=>(r.findAll(s).forEach(a=>{a.reset()}),this.refetchQueries({type:"active",...s},t)))}cancelQueries(s,t={}){const r={revert:!0,...t},a=dt.batch(()=>w(this,at).findAll(s).map(n=>n.cancel(r)));return Promise.all(a).then(jt).catch(jt)}invalidateQueries(s,t={}){return dt.batch(()=>(w(this,at).findAll(s).forEach(r=>{r.invalidate()}),(s==null?void 0:s.refetchType)==="none"?Promise.resolve():this.refetchQueries({...s,type:(s==null?void 0:s.refetchType)??(s==null?void 0:s.type)??"active"},t)))}refetchQueries(s,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},a=dt.batch(()=>w(this,at).findAll(s).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(jt)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(jt)}fetchQuery(s){const t=this.defaultQueryOptions(s);t.retry===void 0&&(t.retry=!1);const r=w(this,at).build(this,t);return r.isStaleByTime(Xs(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(s){return this.fetchQuery(s).then(jt).catch(jt)}fetchInfiniteQuery(s){return s.behavior=ul(s.pages),this.fetchQuery(s)}prefetchInfiniteQuery(s){return this.fetchInfiniteQuery(s).then(jt).catch(jt)}ensureInfiniteQueryData(s){return s.behavior=ul(s.pages),this.ensureQueryData(s)}resumePausedMutations(){return vn.isOnline()?w(this,Ys).resumePausedMutations():Promise.resolve()}getQueryCache(){return w(this,at)}getMutationCache(){return w(this,Ys)}getDefaultOptions(){return w(this,Qs)}setDefaultOptions(s){Y(this,Qs,s)}setQueryDefaults(s,t){w(this,Xr).set(kr(s),{queryKey:s,defaultOptions:t})}getQueryDefaults(s){const t=[...w(this,Xr).values()],r={};return t.forEach(a=>{Ma(s,a.queryKey)&&Object.assign(r,a.defaultOptions)}),r}setMutationDefaults(s,t){w(this,ea).set(kr(s),{mutationKey:s,defaultOptions:t})}getMutationDefaults(s){const t=[...w(this,ea).values()],r={};return t.forEach(a=>{Ma(s,a.mutationKey)&&Object.assign(r,a.defaultOptions)}),r}defaultQueryOptions(s){if(s._defaulted)return s;const t={...w(this,Qs).queries,...this.getQueryDefaults(s.queryKey),...s,_defaulted:!0};return t.queryHash||(t.queryHash=No(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===_o&&(t.enabled=!1),t}defaultMutationOptions(s){return s!=null&&s._defaulted?s:{...w(this,Qs).mutations,...(s==null?void 0:s.mutationKey)&&this.getMutationDefaults(s.mutationKey),...s,_defaulted:!0}}clear(){w(this,at).clear(),w(this,Ys).clear()}},at=new WeakMap,Ys=new WeakMap,Qs=new WeakMap,Xr=new WeakMap,ea=new WeakMap,Zs=new WeakMap,ta=new WeakMap,sa=new WeakMap,bc),Od=d.createContext(void 0),is=s=>{const t=d.useContext(Od);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Lx=({client:s,children:t})=>(d.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),e.jsx(Od.Provider,{value:s,children:t})),Dd=d.createContext(!1),Fx=()=>d.useContext(Dd);Dd.Provider;function qx(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}var zx=d.createContext(qx()),$x=()=>d.useContext(zx),Bx=(s,t,r)=>{const a=r!=null&&r.state.error&&typeof s.throwOnError=="function"?So(s.throwOnError,[r.state.error,r]):s.throwOnError;(s.suspense||s.experimental_prefetchInRender||a)&&(t.isReset()||(s.retryOnMount=!1))},Ux=s=>{d.useEffect(()=>{s.clearReset()},[s])},Hx=({result:s,errorResetBoundary:t,throwOnError:r,query:a,suspense:n})=>s.isError&&!t.isReset()&&!s.isFetching&&a&&(n&&s.data===void 0||So(r,[s.error,a])),Vx=s=>{if(s.suspense){const r=n=>n==="static"?n:Math.max(n??1e3,1e3),a=s.staleTime;s.staleTime=typeof a=="function"?(...n)=>r(a(...n)):r(a),typeof s.gcTime=="number"&&(s.gcTime=Math.max(s.gcTime,1e3))}},Wx=(s,t)=>s.isLoading&&s.isFetching&&!t,Kx=(s,t)=>(s==null?void 0:s.suspense)&&t.isPending,hl=(s,t,r)=>t.fetchOptimistic(s).catch(()=>{r.clearReset()});function Gx(s,t,r){var g,u,y,h;const a=Fx(),n=$x(),i=is(),o=i.defaultQueryOptions(s);(u=(g=i.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||u.call(g,o);const l=i.getQueryCache().get(o.queryHash);o._optimisticResults=a?"isRestoring":"optimistic",Vx(o),Bx(o,n,l),Ux(n);const c=!i.getQueryCache().get(o.queryHash),[m]=d.useState(()=>new t(i,o)),p=m.getOptimisticResult(o),x=!a&&s.subscribed!==!1;if(d.useSyncExternalStore(d.useCallback(f=>{const b=x?m.subscribe(dt.batchCalls(f)):jt;return m.updateResult(),b},[m,x]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),d.useEffect(()=>{m.setOptions(o)},[o,m]),Kx(o,p))throw hl(o,m,n);if(Hx({result:p,errorResetBoundary:n,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw p.error;if((h=(y=i.getDefaultOptions().queries)==null?void 0:y._experimental_afterQuery)==null||h.call(y,o,p),o.experimental_prefetchInRender&&!Sr&&Wx(p,a)){const f=c?hl(o,m,n):l==null?void 0:l.promise;f==null||f.catch(jt).finally(()=>{m.updateResult()})}return o.notifyOnChangeProps?p:m.trackResult(p)}function os(s,t){return Gx(s,Ex)}function it(s,t){const r=is(),[a]=d.useState(()=>new Ix(r,s));d.useEffect(()=>{a.setOptions(s)},[a,s]);const n=d.useSyncExternalStore(d.useCallback(o=>a.subscribe(dt.batchCalls(o)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),i=d.useCallback((o,l)=>{a.mutate(o,l).catch(jt)},[a]);if(n.error&&So(a.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:i,mutateAsync:n.mutate}}const Yx=s=>{if(typeof s=="string")try{return JSON.parse(s)}catch{return{}}return s||{}};function as(s,t){return os({queryKey:["cms-content",s,t],queryFn:async()=>{const{data:r,error:a}=await M.from("site_content").select("*").eq("page_name",s).eq("section_key",t).eq("is_active",!0).maybeSingle();if(a)throw a;return r?{...r,content:Yx(r.content)}:null}})}function Ve(){var x;const[s,t]=d.useState(!1),r=An(),{user:a,isAdmin:n,signOut:i}=Bt(),{itemCount:o}=mx(),{data:l}=as("global","settings"),{data:c}=as("global","navigation"),m=(l==null?void 0:l.content)||{siteName:"Moenviron Loop",logoUrl:"https://slelguoygbfzlpylpxfs.supabase.co/storage/v1/render/image/public/project-uploads/2274ce5a-a92d-4b73-b73e-99562f585de3/moenviron-logo-resized-1768037588209.webp?width=400&height=200&resize=contain"},p=((x=c==null?void 0:c.content)==null?void 0:x.links)||[{href:"/",label:"Home"},{href:"/about",label:"About Us"},{href:"/projects",label:"Initiatives"},{href:"/impact",label:"Impact"},{href:"/donate",label:"Donate"},{href:"/partners",label:"For Brands"},{href:"/shop",label:"Shop"}];return e.jsxs("nav",{className:"sticky top-0 z-50 w-full border-b border-border/50 bg-secondary/95 backdrop-blur supports-[backdrop-filter]:bg-secondary/80",children:[e.jsxs("div",{className:"container flex h-24 items-center justify-between",children:[e.jsx(Oe,{to:"/",className:"flex items-center",children:e.jsx("img",{src:m.logoUrl,alt:m.siteName,width:"192",height:"96",className:"h-[6rem] w-auto object-contain"})}),e.jsxs("div",{className:"hidden items-center gap-8 md:flex",children:[p.map(g=>e.jsx(Oe,{to:g.href,className:`text-sm font-medium transition-colors hover:text-primary ${r.pathname===g.href?"text-primary":"text-muted-foreground"}`,children:g.label},g.href)),n&&e.jsx(Oe,{to:"/admin",className:"text-sm font-medium text-primary hover:text-primary/80",children:"Admin"})]}),e.jsxs("div",{className:"hidden items-center gap-2 md:flex",children:[e.jsx(Oe,{to:"/cart",children:e.jsxs(R,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(As,{className:"h-5 w-5"}),o>0&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-5 w-5 items-center justify-center rounded-full bg-primary text-xs font-medium text-primary-foreground",children:o>99?"99+":o})]})}),a?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{to:"/wishlist",children:e.jsx(R,{variant:"ghost",size:"icon",children:e.jsx(ra,{className:"h-5 w-5"})})}),e.jsx(Oe,{to:"/profile",children:e.jsx(R,{variant:"ghost",size:"icon",children:e.jsx(Ni,{className:"h-5 w-5"})})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>i(),children:e.jsx(Uh,{className:"h-5 w-5"})})]}):e.jsx(Oe,{to:"/auth",children:e.jsx(R,{variant:"ghost",size:"icon",children:e.jsx(Ni,{className:"h-5 w-5"})})}),e.jsx(Oe,{to:"/contact",children:e.jsx(R,{children:"Contact Us"})})]}),e.jsx("button",{onClick:()=>t(!s),className:"flex h-10 w-10 items-center justify-center md:hidden","aria-label":"Toggle menu",children:s?e.jsx(Dn,{className:"h-6 w-6"}):e.jsx(Hh,{className:"h-6 w-6"})})]}),s&&e.jsx("div",{className:"border-t border-border bg-background md:hidden",children:e.jsxs("div",{className:"container flex flex-col gap-4 py-4",children:[p.map(g=>e.jsx(Oe,{to:g.href,onClick:()=>t(!1),className:`text-sm font-medium transition-colors hover:text-primary ${r.pathname===g.href?"text-primary":"text-muted-foreground"}`,children:g.label},g.href)),e.jsxs("div",{className:"flex items-center gap-4 pt-4 border-t border-border",children:[e.jsx(Oe,{to:"/cart",onClick:()=>t(!1),children:e.jsxs(R,{variant:"outline",size:"sm",className:"relative",children:[e.jsx(As,{className:"mr-2 h-4 w-4"}),"Cart",o>0&&e.jsx("span",{className:"ml-1 flex h-5 w-5 items-center justify-center rounded-full bg-primary text-xs font-medium text-primary-foreground",children:o>99?"99+":o})]})}),a&&e.jsx(Oe,{to:"/wishlist",onClick:()=>t(!1),children:e.jsxs(R,{variant:"outline",size:"sm",children:[e.jsx(ra,{className:"mr-2 h-4 w-4"}),"Wishlist"]})}),e.jsx(Oe,{to:"/contact",onClick:()=>t(!1),children:e.jsx(R,{size:"sm",children:"Contact Us"})})]})]})})]})}function We(){const s=ns(),{data:t}=as("global","settings"),{data:r}=as("global","navigation"),[a,n]=d.useState(""),[i,o]=d.useState(!1),[l,c]=d.useState("idle"),m=async v=>{if(v.preventDefault(),!(!a||i)){o(!0);try{const{error:j}=await M.from("newsletter_subscribers").insert({email:a,source:"footer"});if(j)if(j.code==="23505")c("success");else throw j;else c("success");n("")}catch{c("error")}finally{o(!1),setTimeout(()=>c("idle"),3e3)}}},p=(t==null?void 0:t.content)||{},x=(p.contactEmail||"").trim(),g=x.toLowerCase(),u=!x||g==="moses@moenviron.com"?"info@moenviron.com":x,y={siteName:p.siteName||"Moenviron Loop",logoUrl:p.logoUrl||"https://slelguoygbfzlpylpxfs.supabase.co/storage/v1/render/image/public/project-uploads/2274ce5a-a92d-4b73-b73e-99562f585de3/moenviron-logo-resized-1768037588209.webp?width=400&height=200&resize=contain",contactEmail:u,contactPhone:p.contactPhone||"+44 7394 382060",address:p.address||"Wiltshire, SP11 9GP, United Kingdom",footerText:p.footerText||"Pioneering the circular economy through sustainable fashion. Ethical UK collection, advanced Kenya processing, and measurable global impact."},f=((r==null?void 0:r.content)||{}).links||[{href:"/shop",label:"Shop"},{href:"/about",label:"About Us"},{href:"/impact",label:"Our Impact"},{href:"/partners",label:"For Brands"},{href:"/contact",label:"Contact"}],b=v=>{s(v),window.scrollTo({top:0,behavior:"smooth"})};return e.jsx("footer",{className:"border-t border-border bg-secondary",children:e.jsxs("div",{className:"container py-12 md:py-16",children:[e.jsxs("div",{className:"grid gap-8 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(Oe,{to:"/",className:"flex items-center",children:e.jsx("img",{src:y.logoUrl,alt:y.siteName,width:"200",height:"144",className:"h-36 w-auto object-contain"})}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:y.footerText}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground",children:[e.jsxs("a",{href:`mailto:${y.contactEmail}`,className:"flex items-center gap-2 hover:text-primary transition-colors","aria-label":`Email us at ${y.contactEmail}`,children:[e.jsx(zt,{className:"h-4 w-4","aria-hidden":"true"}),y.contactEmail]}),e.jsxs("a",{href:`tel:${y.contactPhone.replace(/\s/g,"")}`,className:"flex items-center gap-2 hover:text-primary transition-colors","aria-label":`Call us at ${y.contactPhone}`,children:[e.jsx(sd,{className:"h-4 w-4","aria-hidden":"true"}),y.contactPhone]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"h-4 w-4","aria-hidden":"true"}),y.address]})]}),e.jsxs("div",{className:"flex gap-4 pt-4",children:[e.jsx("a",{href:"https://www.linkedin.com/in/moses-onyuro-98336837b/?originalSubdomain=uk",target:"_blank",rel:"noopener noreferrer",className:"h-10 w-10 text-muted-foreground hover:text-primary transition-all inline-flex items-center justify-center rounded-full bg-white/5 hover:bg-white/10 border border-white/5 hover:border-primary/20 hover:scale-110 active:scale-95","aria-label":"Follow Moenviron on LinkedIn",children:e.jsx(Bh,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("a",{href:"https://www.instagram.com/moenviron/?e=26e96327-3a9b-410e-8c0c-6f706b123a22&g=5",target:"_blank",rel:"noopener noreferrer",className:"h-10 w-10 text-muted-foreground hover:text-primary transition-all inline-flex items-center justify-center rounded-full bg-white/5 hover:bg-white/10 border border-white/5 hover:border-primary/20 hover:scale-110 active:scale-95","aria-label":"Follow Moenviron on Instagram",children:e.jsx(qh,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("a",{href:"https://www.tiktok.com/@moenviron",target:"_blank",rel:"noopener noreferrer",className:"h-10 w-10 text-muted-foreground hover:text-primary transition-all inline-flex items-center justify-center rounded-full bg-white/5 hover:bg-white/10 border border-white/5 hover:border-primary/20 hover:scale-110 active:scale-95","aria-label":"Follow Moenviron on TikTok",children:e.jsx("svg",{className:"h-5 w-5 fill-current",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.03 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.9-.32-1.89-.39-2.8-.09-.94.24-1.85.91-2.29 1.75-.47.88-.43 2.02.12 2.87.61.9 1.76 1.45 2.84 1.25 1.24-.14 2.29-1.15 2.54-2.36.03-2.6.03-5.21.03-7.81V.02z"})})}),e.jsx("a",{href:"https://youtube.com/@moenvironlimited?si=S9WWNrgmvRWN962T",target:"_blank",rel:"noopener noreferrer",className:"h-10 w-10 text-muted-foreground hover:text-primary transition-all inline-flex items-center justify-center rounded-full bg-white/5 hover:bg-white/10 border border-white/5 hover:border-primary/20 hover:scale-110 active:scale-95","aria-label":"Follow Moenviron on YouTube",children:e.jsx(lp,{className:"h-5 w-5","aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"lg:col-span-3 grid grid-cols-2 md:grid-cols-3 gap-8",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"mb-4 font-semibold text-foreground",children:"Navigation"}),e.jsx("ul",{className:"space-y-2",children:f.map(v=>e.jsx("li",{children:e.jsx("button",{onClick:()=>b(v.href),className:"text-sm text-muted-foreground hover:text-primary transition-colors text-left",children:v.label})},v.href))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-4 font-semibold text-foreground",children:"Legal"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>b("/privacy"),className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Privacy Policy"})}),e.jsx("li",{children:e.jsx("button",{onClick:()=>b("/terms"),className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Terms & Conditions"})}),e.jsx("li",{children:e.jsx("button",{onClick:()=>b("/returns"),className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Returns Policy"})})]})]}),e.jsxs("div",{className:"col-span-2 md:col-span-1",children:[e.jsx("h4",{className:"mb-4 font-semibold text-foreground",children:"Newsletter"}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed mb-3",children:"Get updates on sustainable fashion and exclusive offers."}),e.jsxs("form",{onSubmit:m,className:"flex gap-2",children:[e.jsx("input",{type:"email",value:a,onChange:v=>n(v.target.value),placeholder:"Your email",required:!0,className:"flex-1 px-3 py-2 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-primary"}),e.jsx("button",{type:"submit",disabled:i,className:"px-3 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50",children:i?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsx(In,{className:"h-4 w-4"})})]}),l==="success"&&e.jsx("p",{className:"text-xs text-green-500 mt-2",children:"Subscribed successfully!"}),l==="error"&&e.jsx("p",{className:"text-xs text-red-500 mt-2",children:"Something went wrong. Try again."}),e.jsxs("div",{className:"mt-4 flex items-center gap-4",children:[e.jsx("img",{src:"https://flagcdn.com/w160/eu.png",alt:"UK/EU Partnership",width:"20",height:"14",className:"h-3.5 w-auto opacity-70 grayscale hover:grayscale-0 transition-all"}),e.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-widest font-semibold",children:"SCA Compliant • GDPR Ready"})]})]})]})]}),e.jsxs("div",{className:"mt-12 flex flex-col items-center justify-between gap-4 border-t border-border pt-8 md:flex-row",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["© ",new Date().getFullYear()," ",y.siteName,". All rights reserved."]}),e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nurturing Nature, Nurturing Life."})]})]})})}const Qx="/assets/hero-mountain-CQDL3g17.png",Zx=[{url:Qx,alt:"Mountain landscape with forests and river valley"},{url:"https://images.unsplash.com/photo-1558171813-4c088753af8f?w=1920&q=80",alt:"Sustainable fashion production"},{url:"https://images.unsplash.com/photo-1532996122724-e3c354a0b15b?w=1920&q=80",alt:"Textile recycling process"}];function Jx(){const{data:s}=as("home","hero"),[t,r]=d.useState(0),[a,n]=d.useState(!1),i=(s==null?void 0:s.content)||{},o=Array.isArray(i.slides)&&i.slides.length>0?i.slides:Zx,l={badge:i.badge||"Circular Fashion • UK, Kenya & African Partnership",headline:i.headline||i.title||"Transforming Textile Waste into <i>Sustainable Fashion</i>",subheadline:i.subheadline||i.subtitle||"The London-Nairobi Circular Bridge. We collect discarded textiles in the UK, process them with artisanal Kenya and African craftsmanship, and bring them back as premium circular fashion.",cta_primary_text:i.cta_primary_text||i.ctaText||"Join the Movement",cta_primary_link:i.cta_primary_link||i.ctaLink||"/shop",cta_secondary_text:i.cta_secondary_text||"Partner With Us",cta_secondary_link:i.cta_secondary_link||"/partners"},c=d.useCallback(x=>{a||(n(!0),r(x),setTimeout(()=>n(!1),700))},[a]),m=d.useCallback(()=>{c((t+1)%o.length)},[t,o.length,c]),p=d.useCallback(()=>{c((t-1+o.length)%o.length)},[t,o.length,c]);return d.useEffect(()=>{const x=setInterval(()=>{m()},6e3);return()=>clearInterval(x)},[m]),e.jsxs("section",{className:"relative overflow-hidden min-h-[70vh] md:min-h-[85vh] flex items-center",children:[e.jsxs("div",{className:"absolute inset-0 z-0",children:[o.map((x,g)=>e.jsx("div",{className:`absolute inset-0 transition-opacity duration-700 ease-in-out ${g===t?"opacity-100":"opacity-0"}`,children:e.jsx("img",{src:`${x.url}${x.url.includes("unsplash.com")?x.url.includes("?")?"&w=1200&q=75":"?w=1200&q=75":""}`,alt:x.alt,width:"1920",height:"1080",className:"h-full w-full object-cover object-center md:object-top",style:{filter:"contrast(1.05) saturate(1.1) brightness(1.02)",imageRendering:"auto"},loading:g===0?"eager":"lazy",fetchPriority:g===0?"high":"low"})},g)),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/40 via-black/50 to-black/60 md:from-black/30 md:via-black/40 md:to-black/50"})]}),o.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:p,className:"absolute left-2 md:left-4 top-1/2 -translate-y-1/2 z-20 p-1.5 md:p-2 rounded-full bg-white/10 hover:bg-white/20 backdrop-blur-sm transition-all duration-300 text-white","aria-label":"Previous slide",children:e.jsx(Ph,{className:"h-5 w-5 md:h-6 md:w-6"})}),e.jsx("button",{onClick:m,className:"absolute right-2 md:right-4 top-1/2 -translate-y-1/2 z-20 p-1.5 md:p-2 rounded-full bg-white/10 hover:bg-white/20 backdrop-blur-sm transition-all duration-300 text-white","aria-label":"Next slide",children:e.jsx(Ah,{className:"h-5 w-5 md:h-6 md:w-6"})}),e.jsx("div",{className:"absolute bottom-6 md:bottom-8 left-1/2 -translate-x-1/2 z-20 flex gap-2",children:o.map((x,g)=>e.jsx("button",{onClick:()=>c(g),className:`w-2.5 h-2.5 md:w-3 md:h-3 rounded-full transition-all duration-300 ${g===t?"bg-white scale-110":"bg-white/40 hover:bg-white/60"}`,"aria-label":`Go to slide ${g+1}`},g))})]}),e.jsx("div",{className:"container relative z-10 py-12 px-6 md:py-32 md:px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsxs("div",{className:"mb-4 md:mb-6 inline-flex items-center gap-2 text-xs md:text-sm font-medium text-white/90 animate-fade-in",children:[e.jsx(wr,{className:"h-3.5 w-3.5 md:h-4 md:w-4","aria-hidden":"true"}),e.jsx("span",{children:l.badge})]}),e.jsx("h1",{className:"mb-4 md:mb-6 font-serif text-3xl sm:text-4xl font-normal tracking-tight text-white md:text-6xl lg:text-7xl animate-fade-in leading-[1.15]",style:{animationDelay:"0.1s"},dangerouslySetInnerHTML:{__html:l.headline}}),e.jsx("p",{className:"mb-8 md:mb-10 text-base md:text-xl text-white/85 max-w-2xl mx-auto animate-fade-in leading-relaxed px-2 md:px-0",style:{animationDelay:"0.2s"},children:l.subheadline}),e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 sm:flex-row animate-fade-in",style:{animationDelay:"0.3s"},children:[e.jsx(Oe,{to:l.cta_primary_link,children:e.jsxs(R,{size:"lg",className:"gap-2 bg-[#2D5A43] text-white hover:bg-[#3d7a5a] border-0 px-8 rounded-full",children:[l.cta_primary_text,e.jsx(ss,{className:"h-4 w-4"})]})}),e.jsx(Oe,{to:l.cta_secondary_link,children:e.jsx(R,{size:"lg",variant:"outline",className:"gap-2 border-white/50 text-white hover:bg-white/10 bg-transparent px-8 rounded-full",children:l.cta_secondary_text})})]}),e.jsxs("div",{className:"mt-16 flex flex-wrap items-center justify-center gap-8 text-sm text-white/80 animate-fade-in",style:{animationDelay:"0.4s"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"h-5 w-5","aria-hidden":"true"}),e.jsx("span",{children:"UN SDG Aligned"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-5 w-5","aria-hidden":"true"}),e.jsx("span",{children:"Carbon Tracked"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wr,{className:"h-5 w-5","aria-hidden":"true"}),e.jsx("span",{children:"100% Circular"})]})]})]})})]})}const Xx=({value:s,format:t,delay:r=0})=>{const[a,n]=d.useState(0),i=d.useRef(0),[o,l]=d.useState(!1),c=d.useRef(null);return d.useEffect(()=>{const m=new IntersectionObserver(([p])=>{p.isIntersecting&&l(!0)},{threshold:.1});return c.current&&m.observe(c.current),()=>m.disconnect()},[]),d.useEffect(()=>{if(!o)return;const m=2e3,p=60,x=s/p,g=m/p;setTimeout(()=>{const u=setInterval(()=>{i.current+=x,i.current>=s?(n(s),clearInterval(u)):n(i.current)},g);return()=>clearInterval(u)},r*1e3)},[s,o,r]),e.jsx("div",{ref:c,children:t(a)})},eg={tonnes_recycled:{icon:wr,label:"Textiles Recycled",format:s=>`${s.toFixed(1)} tonnes`},carbon_offset:{icon:Yc,label:"Carbon Prevented",format:s=>`${s.toFixed(0)} kg CO₂`},water_saved:{icon:Jc,label:"Water Saved",format:s=>`${Math.round(s/1e3)}k litres`},jobs_created:{icon:rr,label:"Jobs Created",format:s=>`${s.toFixed(0)} people`}};function tg(){const[s,t]=d.useState([{metric_name:"tonnes_recycled",metric_value:12.5,unit:"tonnes"},{metric_name:"carbon_offset",metric_value:8450,unit:"kg CO2"},{metric_name:"water_saved",metric_value:45e3,unit:"litres"},{metric_name:"jobs_created",metric_value:45,unit:"people"}]),{data:r}=as("home","impact-counter"),a=(r==null?void 0:r.content)||{},n={title:a.title||"Our Impact So Far",subtitle:a.subtitle||"Real-time metrics from our UK-Kenya circular fashion operation"};return d.useEffect(()=>{async function i(){try{const{data:o,error:l}=await M.from("impact_metrics").select("metric_name, metric_value, unit").order("recorded_at",{ascending:!1});if(!l&&o&&o.length>0){const c=o.reduce((m,p)=>(m[p.metric_name]||(m[p.metric_name]=p),m),{});t(Object.values(c))}}catch(o){console.error("Error fetching metrics:",o)}}i()},[]),e.jsx("section",{className:"border-y border-border bg-card py-12",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsx("h2",{className:"font-display text-2xl font-bold text-foreground md:text-4xl",children:n.title}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:n.subtitle})]}),e.jsx("div",{className:"grid grid-cols-2 gap-6 md:grid-cols-4",children:s.map((i,o)=>{const l=eg[i.metric_name];if(!l)return null;const c=l.icon;return e.jsxs("div",{className:"text-center animate-counter-up",style:{animationDelay:`${o*.1}s`},children:[e.jsx("div",{className:"mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(c,{className:"h-6 w-6 text-primary"})}),e.jsx("div",{className:"text-2xl font-bold text-foreground md:text-3xl",children:e.jsx(Xx,{value:Number(i.metric_value),format:l.format,delay:o*.1})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:l.label})]},i.metric_name)})})]})})}const sg={Package:Et,Truck:On,Factory:Dh,ShoppingBag:As};function rg(){const{data:s}=as("home","how-it-works"),t=(s==null?void 0:s.content)||{},r={title:t.title||"The London-Nairobi Circular Loop",subtitle:t.subtitle||"Our unique cross-continental partnership proves that waste is merely a resource in the wrong place. Experience the journey of a garment from collection to restoration.",steps:t.steps||[{icon:"Package",title:"UK Collection",description:"We curate high-potential discarded textiles from across the UK, diverting tonnes from landfills every month.",location:"United Kingdom"},{icon:"Truck",title:"The Circular Bridge",description:"Our carbon-optimised logistics bridge the gap between UK surplus and Kenyan craftsmanship.",location:"Transit"},{icon:"Factory",title:"Artisanal Processing",description:"At our Nairobi hub, skilled artisans transform textiles through expert cleaning, repair, and creative upcycling.",location:"Nairobi, Kenya"},{icon:"ShoppingBag",title:"Conscious Fashion",description:"Ethically restored pieces return to the market as premium circular garments with full carbon transparency.",location:"Worldwide"}]};return e.jsx("section",{className:"py-16 md:py-24 bg-secondary/30",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-12 text-center",children:[e.jsx("h2",{className:"text-3xl font-bold text-foreground md:text-4xl",children:r.title}),e.jsx("p",{className:"mx-auto mt-4 max-w-2xl text-muted-foreground",children:r.subtitle})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-0 right-0 top-16 hidden h-0.5 bg-border md:block"}),e.jsx("div",{className:"grid gap-8 md:grid-cols-4",children:r.steps.map((a,n)=>{const i=sg[a.icon]||Et;return e.jsxs("div",{className:"relative text-center animate-fade-in-up",style:{animationDelay:`${n*.15}s`},children:[e.jsxs("div",{className:"relative mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-primary shadow-medium",children:[e.jsx(i,{className:"h-8 w-8 text-primary-foreground"}),e.jsx("div",{className:"absolute -bottom-1 -right-1 flex h-6 w-6 items-center justify-center rounded-full bg-accent text-xs font-bold text-accent-foreground",children:n+1})]}),e.jsx("h3",{className:"mb-2 text-lg font-semibold text-foreground",children:a.title}),e.jsx("p",{className:"mb-3 text-sm text-muted-foreground leading-relaxed",children:a.description}),e.jsx("span",{className:"inline-block rounded-full bg-secondary px-3 py-1 text-xs font-medium text-secondary-foreground",children:a.location})]},a.title)})})]})]})})}const ag=[{title:"UK Collection",description:"Textile waste collected across the United Kingdom",hoverDetails:"Over 336,000 tonnes of clothing is thrown away in the UK annually. We divert this from landfills to give it new life.",image:"https://images.unsplash.com/photo-1532996122724-e3c354a0b15b?q=60&w=600&auto=format&fit=crop",color:"bg-primary/10"},{title:"Sorting & Processing",description:"Materials sorted by fiber type and condition",hoverDetails:"Advanced manual and automated sorting ensures 95% of collected textiles find a second life through reuse or recycling.",image:"https://images.unsplash.com/photo-1621451537084-482c73073a0f?q=60&w=600&auto=format&fit=crop",color:"bg-accent/10"},{title:"Kenya Manufacturing",description:"Skilled artisans transform materials in Nairobi",hoverDetails:"Supporting Nairobi's economy by transforming global waste into high-value products with skilled local artisans.",image:"https://images.unsplash.com/photo-1558770147-d2a384e1ad85?q=60&w=600&auto=format&fit=crop",color:"bg-secondary/10"},{title:"Sustainable Fashion",description:"New garments with full carbon traceability",hoverDetails:"Our garments use 99% less water and produce 90% fewer emissions than virgin textile production.",image:"https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?q=60&w=600&auto=format&fit=crop",color:"bg-primary/10"},{title:"Global Impact",description:"Reducing landfill waste worldwide",hoverDetails:"Every ton of textiles recycled saves approximately 8 tons of CO2e emissions globally.",image:"https://images.unsplash.com/photo-1611284446314-60a58ac0deb9?q=60&w=600&auto=format&fit=crop",color:"bg-accent/10"},{title:"Community Employment",description:"Creating jobs in developing economies",hoverDetails:"Creating dignified work opportunities for women and youth in the Kenyan textile and manufacturing sectors.",image:"https://images.unsplash.com/photo-1521737711867-e3b97375f902?q=60&w=600&auto=format&fit=crop",color:"bg-secondary/10"},{title:"Carbon Offset",description:"Every product tracks its environmental savings",hoverDetails:"Transparent traceability allowing brands to account for every kilogram of carbon saved through our circular model.",image:"https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?q=60&w=600&auto=format&fit=crop",color:"bg-primary/10"},{title:"B2B Solutions",description:"EPR compliance for fashion brands",hoverDetails:"Helping brands meet Extended Producer Responsibility requirements through closed-loop systems and real impact data.",image:"https://images.unsplash.com/photo-1497215728101-856f4ea42174?q=60&w=600&auto=format&fit=crop",color:"bg-accent/10"}];function ng(){const s=d.useRef(null),t=d.useRef(null),[r,a]=d.useState(0),[n,i]=d.useState(!1),{data:o}=as("home","impact-collage"),l=(o==null?void 0:o.content)||{},c={title:l.title||"Our Circular Journey",subtitle:l.subtitle||"From textile waste collection to sustainable fashion — discover how we're transforming the industry through high-impact circular systems.",images:l.images||ag},m=c.images,p=[...m,...m],x=d.useCallback(()=>{const u=s.current;if(!u||n)return;const y=u.scrollWidth/2,h=u.scrollLeft/y*100;a(Math.min(h,100))},[n]),g=d.useCallback(u=>{const y=s.current,h=t.current;if(!y||!h)return;const f=h.getBoundingClientRect(),b=u-f.left,v=Math.max(0,Math.min(100,b/f.width*100)),j=y.scrollWidth/2;y.scrollLeft=v/100*j,a(v)},[]);return d.useEffect(()=>{if(!n)return;const u=f=>{f.preventDefault(),g(f.clientX)},y=f=>{g(f.touches[0].clientX)},h=()=>{i(!1)};return document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),document.addEventListener("touchmove",y),document.addEventListener("touchend",h),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",h)}},[n,g]),d.useEffect(()=>{const u=s.current;if(!u)return;let y,h=u.scrollLeft;const f=.5;let b=!1,v=!0;const j=new IntersectionObserver(([O])=>{v=O.isIntersecting},{threshold:.1});j.observe(u);const _=()=>{if(!v||b||n){y=requestAnimationFrame(_);return}h+=f;const O=u.scrollWidth/2;h>=O&&(h=0),u.scrollLeft=h,x(),y=requestAnimationFrame(_)};y=requestAnimationFrame(_);const I=()=>{b=!0},E=()=>{b=!1,h=u.scrollLeft};return u.addEventListener("mouseenter",I),u.addEventListener("mouseleave",E),()=>{cancelAnimationFrame(y),j.disconnect(),u.removeEventListener("mouseenter",I),u.removeEventListener("mouseleave",E)}},[m,x,n]),e.jsxs("section",{className:"py-16 md:py-24 overflow-hidden bg-muted/30",children:[e.jsx("div",{className:"container mb-12",children:e.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[e.jsx("h2",{className:"text-3xl font-bold text-foreground md:text-4xl tracking-tight",children:c.title}),e.jsx("p",{className:"mt-4 text-muted-foreground text-lg",children:c.subtitle})]})}),e.jsx("div",{ref:s,className:"flex gap-6 overflow-x-hidden cursor-grab px-4",style:{scrollBehavior:"auto"},children:p.map((u,y)=>e.jsxs("div",{className:"group relative flex-shrink-0 w-80 h-[450px] overflow-hidden rounded-2xl border border-border/50 transition-all hover:shadow-2xl",children:[e.jsx("img",{src:u.image||u.url,alt:u.title,width:"320",height:"450",loading:"lazy",className:"absolute inset-0 w-full h-full object-cover transition-transform duration-700 ease-out group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/40 to-transparent group-hover:from-black/95 group-hover:via-black/60 transition-colors duration-500"}),e.jsxs("div",{className:"absolute inset-0 p-8 flex flex-col justify-end text-white",children:[e.jsxs("div",{className:"transition-transform duration-500 transform group-hover:-translate-y-4",children:[e.jsx("h3",{className:"text-2xl font-bold mb-3 tracking-tight group-hover:text-primary-foreground transition-colors",children:u.title}),e.jsx("p",{className:"text-sm text-white/80 leading-relaxed font-medium transition-opacity duration-300 group-hover:opacity-0 group-hover:h-0 overflow-hidden",children:u.description})]}),e.jsx("div",{className:"absolute bottom-8 left-8 right-8 translate-y-8 opacity-0 group-hover:translate-y-0 group-hover:opacity-100 transition-all duration-500 ease-out delay-75",children:e.jsx("div",{className:"bg-primary/20 backdrop-blur-md p-4 rounded-xl border border-white/20",children:e.jsx("p",{className:"text-sm leading-relaxed font-medium text-white/95",children:u.hoverDetails||u.subtitle})})})]}),e.jsx("div",{className:"absolute top-4 right-4 bg-white/10 backdrop-blur-md px-3 py-1 rounded-full border border-white/20",children:e.jsxs("span",{className:"text-[10px] uppercase tracking-widest font-bold text-white/80",children:["Step ",y%m.length+1]})})]},`${u.title}-${y}`))}),e.jsx("div",{className:"mt-6 flex justify-center px-4",children:e.jsxs("div",{ref:t,className:"w-full max-w-xs md:max-w-md h-2 md:h-3 bg-[#E5E7EB] rounded-full overflow-hidden relative cursor-pointer select-none",onMouseDown:u=>{i(!0),g(u.clientX)},onTouchStart:u=>{i(!0),g(u.touches[0].clientX)},onClick:u=>{g(u.clientX)},children:[e.jsx("div",{className:"h-full bg-[#2D5A43] rounded-full transition-all duration-150 pointer-events-none",style:{width:`${Math.max(r,5)}%`}}),e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-4 h-4 md:w-5 md:h-5 bg-[#2D5A43] rounded-full shadow-md border-2 border-white pointer-events-none",style:{left:`calc(${Math.max(r,2)}% - 8px)`}})]})}),e.jsx("div",{className:"container mt-12 text-center",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 bg-background/50 backdrop-blur-sm rounded-full border border-border shadow-sm",children:[e.jsx("span",{className:"w-2 h-2 bg-primary rounded-full animate-pulse"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Hover to explore the impact • Scroll continues automatically"})]})})]})}const ig=[{number:8,title:"Decent Work and Economic Growth",description:"Creating sustainable employment in Kenya's textile sector",color:"hsl(345 70% 45%)"},{number:12,title:"Responsible Consumption and Production",description:"Circular fashion that reduces waste and extends product lifecycles",color:"hsl(35 85% 50%)"},{number:13,title:"Climate Action",description:"Reducing textile waste emissions and carbon footprint",color:"hsl(150 50% 35%)"}];function og(){const{data:s}=as("home","sdg-badges"),t=(s==null?void 0:s.content)||{},r={title:t.title||"UN Sustainable Development Goals",subtitle:t.subtitle||"Our operations directly contribute to three key UN SDGs, creating measurable impact across economic, environmental, and social dimensions.",badges:t.badges||ig},a=r.badges;return e.jsx("section",{className:"bg-card py-16 md:py-24",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-12 text-center",children:[e.jsx("h2",{className:"text-3xl font-bold text-foreground md:text-4xl",children:r.title}),e.jsx("p",{className:"mx-auto mt-4 max-w-2xl text-muted-foreground",children:r.subtitle})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-3",children:a.map((n,i)=>e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border bg-background p-6 shadow-soft transition-all hover:shadow-medium animate-fade-in-up",style:{animationDelay:`${i*.1}s`},children:[e.jsx("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-lg text-2xl font-bold text-white",style:{backgroundColor:n.color},children:n.number}),e.jsx("h3",{className:"mb-2 text-lg font-semibold text-foreground",children:n.title}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:n.description}),e.jsx("div",{className:"absolute bottom-0 left-0 h-1 w-full origin-left scale-x-0 transition-transform duration-300 group-hover:scale-x-100",style:{backgroundColor:n.color}})]},n.number))}),e.jsx("div",{className:"mt-12 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Committed to the"," ",e.jsx("a",{href:"https://sdgs.un.org",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-primary hover:underline",children:"UN 2030 Agenda for Sustainable Development"})]})})]})})}const lg={Building2:Vc,FileCheck:yo,TrendingUp:_r};function cg(){const{data:s}=as("home","partner-cta"),t=(s==null?void 0:s.content)||{},r={badge:t.badge||"For Brands & Retailers",title:t.title||"Partner With Moenviron",description:t.description||"Are you a fashion brand looking to meet EPR requirements, improve ESG scores, or launch a textile take-back program? Our UK-Kenya infrastructure provides verified, traceable circular fashion solutions at scale.",cta_text:t.cta_text||"Explore Partnership",cta_link:t.cta_link||"/partners",benefits:t.benefits||[{icon:"FileCheck",title:"EPR Compliance",description:"Meet Extended Producer Responsibility requirements with verified textile recycling"},{icon:"TrendingUp",title:"ESG Reporting",description:"Detailed impact metrics for your sustainability reports and stakeholders"},{icon:"Building2",title:"Brand Partnership",description:"White-label solutions for take-back schemes and circular fashion programs"}]};return e.jsxs("section",{className:"relative overflow-hidden bg-primary py-16 md:py-24",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsxs("svg",{className:"h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("defs",{children:e.jsx("pattern",{id:"partner-grid",width:"60",height:"60",patternUnits:"userSpaceOnUse",children:e.jsx("circle",{cx:"30",cy:"30",r:"1",fill:"currentColor"})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#partner-grid)"})]})}),e.jsx("div",{className:"container relative",children:e.jsxs("div",{className:"grid gap-12 lg:grid-cols-2 lg:items-center",children:[e.jsxs("div",{className:"text-primary-foreground",children:[e.jsx("span",{className:"mb-4 inline-block rounded-full bg-primary-foreground/10 px-4 py-2 text-sm font-medium",children:r.badge}),e.jsx("h2",{className:"mb-4 text-3xl font-bold md:text-4xl",children:r.title}),e.jsx("p",{className:"mb-8 text-lg opacity-90 leading-relaxed",children:r.description}),e.jsx(Oe,{to:r.cta_link,children:e.jsxs(R,{size:"lg",variant:"secondary",className:"gap-2",children:[r.cta_text,e.jsx(ss,{className:"h-4 w-4"})]})})]}),e.jsx("div",{className:"space-y-4",children:(r.benefits||[]).map((a,n)=>{const i=lg[a.icon]||yo;return e.jsxs("div",{className:"flex gap-4 rounded-xl bg-primary-foreground/10 p-5 backdrop-blur-sm animate-fade-in-up",style:{animationDelay:`${n*.1}s`},children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-primary-foreground/20",children:e.jsx(i,{className:"h-6 w-6 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-primary-foreground",children:a.title}),e.jsx("p",{className:"mt-1 text-sm text-primary-foreground/80",children:a.description})]})]},a.title)})})]})})]})}const Ms=$m,Mr=Bm,dg=qm,Ld=d.forwardRef(({className:s,...t},r)=>e.jsx(Ac,{ref:r,className:me("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...t}));Ld.displayName=Ac.displayName;const gs=d.forwardRef(({className:s,children:t,...r},a)=>e.jsxs(dg,{children:[e.jsx(Ld,{}),e.jsxs(Rc,{ref:a,className:me("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...r,children:[t,e.jsxs(zm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Dn,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gs.displayName=Rc.displayName;const Is=({className:s,...t})=>e.jsx("div",{className:me("flex flex-col space-y-1.5 text-center sm:text-left",s),...t});Is.displayName="DialogHeader";const Eo=({className:s,...t})=>e.jsx("div",{className:me("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...t});Eo.displayName="DialogFooter";const Os=d.forwardRef(({className:s,...t},r)=>e.jsx(Mc,{ref:r,className:me("text-lg font-semibold leading-none tracking-tight",s),...t}));Os.displayName=Mc.displayName;const Ya=d.forwardRef(({className:s,...t},r)=>e.jsx(Ic,{ref:r,className:me("text-sm text-muted-foreground",s),...t}));Ya.displayName=Ic.displayName;const Q=d.forwardRef(({className:s,type:t,...r},a)=>e.jsx("input",{type:t,className:me("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:a,...r}));Q.displayName="Input";const ug=()=>{const[s,t]=d.useState(!1),[r,a]=d.useState(""),[n,i]=d.useState(!1),{toast:o}=mo();d.useEffect(()=>{if(localStorage.getItem("newsletter-popup-seen"))return;const p=setTimeout(()=>{t(!0)},3e3);return()=>clearTimeout(p)},[]);const l=()=>{t(!1),localStorage.setItem("newsletter-popup-seen","true")},c=async m=>{if(m.preventDefault(),!(!r||n)){i(!0);try{const{error:p}=await M.from("newsletter_subscribers").insert({email:r,is_active:!0,source:"popup"});if(p)if(p.code==="23505")o({title:"Already subscribed",description:"This email is already on our list!"});else throw p;else{try{await M.functions.invoke("sync-to-mailerlite",{body:{action:"sync"}})}catch(x){console.log("MailerLite sync skipped:",x)}o({title:"Welcome to the movement",description:"You've successfully joined our newsletter."})}l()}catch(p){console.error("Newsletter signup error:",p),o({title:"Error",description:"Failed to subscribe. Please try again.",variant:"destructive"})}finally{i(!1)}}};return e.jsx(Ms,{open:s,onOpenChange:m=>{m||l()},children:e.jsx(gs,{className:"max-w-[800px] p-0 overflow-hidden border-none bg-transparent",children:e.jsxs("div",{className:"flex flex-col md:flex-row h-full md:h-[500px] bg-white rounded-none",children:[e.jsxs("div",{className:"w-full md:w-1/2 relative h-64 md:h-auto overflow-hidden",children:[e.jsx("img",{src:"https://images.unsplash.com/photo-1523381210434-271e8be1f52b?q=80&w=1200&auto=format&fit=crop",alt:"Artisan Craftsmanship",className:"absolute inset-0 w-full h-full object-cover grayscale-[0.2]"}),e.jsx("div",{className:"absolute inset-0 bg-black/20"}),e.jsx("div",{className:"absolute bottom-8 left-8",children:e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.3em] text-white/80",children:"Vol. 01 Edition"})})]}),e.jsx("div",{className:"w-full md:w-1/2 p-8 md:p-12 flex flex-col justify-center relative bg-[#F9F7F2]",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-[0.3em] text-[#2D5A43] mb-4",children:"Newsletter"}),e.jsxs("h2",{className:"text-4xl font-display leading-tight mb-4",children:["Join Our ",e.jsx("br",{}),"Circular World"]}),e.jsx("p",{className:"text-muted-foreground font-light leading-relaxed",children:"Get exclusive access to collection drops, artisan stories, and circular economy insights."})]}),e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx(zt,{className:"absolute left-0 top-1/2 -translate-y-1/2 h-4 w-4 text-black/20 group-focus-within:text-black transition-colors"}),e.jsx(Q,{type:"email",placeholder:"YOUR EMAIL ADDRESS",value:r,onChange:m=>a(m.target.value),className:"bg-transparent border-0 border-b border-black/10 rounded-none pl-7 py-6 text-xs font-bold tracking-widest uppercase focus-visible:ring-0 focus-visible:border-black transition-all placeholder:text-black/20",required:!0})]}),e.jsx(R,{type:"submit",disabled:n,className:"w-full h-14 bg-black text-white rounded-none font-bold uppercase tracking-widest text-[10px] hover:bg-black/90 transition-all group disabled:opacity-50",children:n?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:["Join the Movement",e.jsx(ss,{className:"ml-2 h-3 w-3 transition-transform group-hover:translate-x-1"})]})})]}),e.jsx("p",{className:"text-[9px] text-muted-foreground uppercase tracking-widest",children:"No spam. Only high-impact updates. Unsubscribe anytime."})]})})]})})})};var ti,pl;function mg(){if(pl)return ti;pl=1;var s=typeof Element<"u",t=typeof Map=="function",r=typeof Set=="function",a=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function n(i,o){if(i===o)return!0;if(i&&o&&typeof i=="object"&&typeof o=="object"){if(i.constructor!==o.constructor)return!1;var l,c,m;if(Array.isArray(i)){if(l=i.length,l!=o.length)return!1;for(c=l;c--!==0;)if(!n(i[c],o[c]))return!1;return!0}var p;if(t&&i instanceof Map&&o instanceof Map){if(i.size!==o.size)return!1;for(p=i.entries();!(c=p.next()).done;)if(!o.has(c.value[0]))return!1;for(p=i.entries();!(c=p.next()).done;)if(!n(c.value[1],o.get(c.value[0])))return!1;return!0}if(r&&i instanceof Set&&o instanceof Set){if(i.size!==o.size)return!1;for(p=i.entries();!(c=p.next()).done;)if(!o.has(c.value[0]))return!1;return!0}if(a&&ArrayBuffer.isView(i)&&ArrayBuffer.isView(o)){if(l=i.length,l!=o.length)return!1;for(c=l;c--!==0;)if(i[c]!==o[c])return!1;return!0}if(i.constructor===RegExp)return i.source===o.source&&i.flags===o.flags;if(i.valueOf!==Object.prototype.valueOf&&typeof i.valueOf=="function"&&typeof o.valueOf=="function")return i.valueOf()===o.valueOf();if(i.toString!==Object.prototype.toString&&typeof i.toString=="function"&&typeof o.toString=="function")return i.toString()===o.toString();if(m=Object.keys(i),l=m.length,l!==Object.keys(o).length)return!1;for(c=l;c--!==0;)if(!Object.prototype.hasOwnProperty.call(o,m[c]))return!1;if(s&&i instanceof Element)return!1;for(c=l;c--!==0;)if(!((m[c]==="_owner"||m[c]==="__v"||m[c]==="__o")&&i.$$typeof)&&!n(i[m[c]],o[m[c]]))return!1;return!0}return i!==i&&o!==o}return ti=function(o,l){try{return n(o,l)}catch(c){if((c.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw c}},ti}var hg=mg();const pg=uo(hg);var si,fl;function fg(){if(fl)return si;fl=1;var s=function(t,r,a,n,i,o,l,c){if(!t){var m;if(r===void 0)m=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[a,n,i,o,l,c],x=0;m=new Error(r.replace(/%s/g,function(){return p[x++]})),m.name="Invariant Violation"}throw m.framesToPop=1,m}};return si=s,si}var xg=fg();const xl=uo(xg);var ri,gl;function gg(){return gl||(gl=1,ri=function(t,r,a,n){var i=a?a.call(n,t,r):void 0;if(i!==void 0)return!!i;if(t===r)return!0;if(typeof t!="object"||!t||typeof r!="object"||!r)return!1;var o=Object.keys(t),l=Object.keys(r);if(o.length!==l.length)return!1;for(var c=Object.prototype.hasOwnProperty.bind(r),m=0;m<o.length;m++){var p=o[m];if(!c(p))return!1;var x=t[p],g=r[p];if(i=a?a.call(n,x,g,p):void 0,i===!1||i===void 0&&x!==g)return!1}return!0}),ri}var yg=gg();const bg=uo(yg);var Fd=(s=>(s.BASE="base",s.BODY="body",s.HEAD="head",s.HTML="html",s.LINK="link",s.META="meta",s.NOSCRIPT="noscript",s.SCRIPT="script",s.STYLE="style",s.TITLE="title",s.FRAGMENT="Symbol(react.fragment)",s))(Fd||{}),ai={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}},yl=Object.values(Fd),To={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},vg=Object.entries(To).reduce((s,[t,r])=>(s[r]=t,s),{}),ts="data-rh",$r={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},Br=(s,t)=>{for(let r=s.length-1;r>=0;r-=1){const a=s[r];if(Object.prototype.hasOwnProperty.call(a,t))return a[t]}return null},jg=s=>{let t=Br(s,"title");const r=Br(s,$r.TITLE_TEMPLATE);if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const a=Br(s,$r.DEFAULT_TITLE);return t||a||void 0},wg=s=>Br(s,$r.ON_CHANGE_CLIENT_STATE)||(()=>{}),ni=(s,t)=>t.filter(r=>typeof r[s]<"u").map(r=>r[s]).reduce((r,a)=>({...r,...a}),{}),Ng=(s,t)=>t.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,a)=>{if(!r.length){const n=Object.keys(a);for(let i=0;i<n.length;i+=1){const l=n[i].toLowerCase();if(s.indexOf(l)!==-1&&a[l])return r.concat(a)}}return r},[]),_g=s=>console&&typeof console.warn=="function"&&console.warn(s),Na=(s,t,r)=>{const a={};return r.filter(n=>Array.isArray(n[s])?!0:(typeof n[s]<"u"&&_g(`Helmet: ${s} should be of type "Array". Instead found type "${typeof n[s]}"`),!1)).map(n=>n[s]).reverse().reduce((n,i)=>{const o={};i.filter(c=>{let m;const p=Object.keys(c);for(let g=0;g<p.length;g+=1){const u=p[g],y=u.toLowerCase();t.indexOf(y)!==-1&&!(m==="rel"&&c[m].toLowerCase()==="canonical")&&!(y==="rel"&&c[y].toLowerCase()==="stylesheet")&&(m=y),t.indexOf(u)!==-1&&(u==="innerHTML"||u==="cssText"||u==="itemprop")&&(m=u)}if(!m||!c[m])return!1;const x=c[m].toLowerCase();return a[m]||(a[m]={}),o[m]||(o[m]={}),a[m][x]?!1:(o[m][x]=!0,!0)}).reverse().forEach(c=>n.push(c));const l=Object.keys(o);for(let c=0;c<l.length;c+=1){const m=l[c],p={...a[m],...o[m]};a[m]=p}return n},[]).reverse()},Sg=(s,t)=>{if(Array.isArray(s)&&s.length){for(let r=0;r<s.length;r+=1)if(s[r][t])return!0}return!1},kg=s=>({baseTag:Ng(["href"],s),bodyAttributes:ni("bodyAttributes",s),defer:Br(s,$r.DEFER),encode:Br(s,$r.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:ni("htmlAttributes",s),linkTags:Na("link",["rel","href"],s),metaTags:Na("meta",["name","charset","http-equiv","property","itemprop"],s),noscriptTags:Na("noscript",["innerHTML"],s),onChangeClientState:wg(s),scriptTags:Na("script",["src","innerHTML"],s),styleTags:Na("style",["cssText"],s),title:jg(s),titleAttributes:ni("titleAttributes",s),prioritizeSeoTags:Sg(s,$r.PRIORITIZE_SEO_TAGS)}),qd=s=>Array.isArray(s)?s.join(""):s,Cg=(s,t)=>{const r=Object.keys(s);for(let a=0;a<r.length;a+=1)if(t[r[a]]&&t[r[a]].includes(s[r[a]]))return!0;return!1},ii=(s,t)=>Array.isArray(s)?s.reduce((r,a)=>(Cg(a,t)?r.priority.push(a):r.default.push(a),r),{priority:[],default:[]}):{default:s,priority:[]},bl=(s,t)=>({...s,[t]:void 0}),Eg=["noscript","script","style"],$i=(s,t=!0)=>t===!1?String(s):String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;"),zd=s=>Object.keys(s).reduce((t,r)=>{const a=typeof s[r]<"u"?`${r}="${s[r]}"`:`${r}`;return t?`${t} ${a}`:a},""),Tg=(s,t,r,a)=>{const n=zd(r),i=qd(t);return n?`<${s} ${ts}="true" ${n}>${$i(i,a)}</${s}>`:`<${s} ${ts}="true">${$i(i,a)}</${s}>`},Pg=(s,t,r=!0)=>t.reduce((a,n)=>{const i=n,o=Object.keys(i).filter(m=>!(m==="innerHTML"||m==="cssText")).reduce((m,p)=>{const x=typeof i[p]>"u"?p:`${p}="${$i(i[p],r)}"`;return m?`${m} ${x}`:x},""),l=i.innerHTML||i.cssText||"",c=Eg.indexOf(s)===-1;return`${a}<${s} ${ts}="true" ${o}${c?"/>":`>${l}</${s}>`}`},""),$d=(s,t={})=>Object.keys(s).reduce((r,a)=>{const n=To[a];return r[n||a]=s[a],r},t),Ag=(s,t,r)=>{const a={key:t,[ts]:!0},n=$d(r,a);return[H.createElement("title",n,t)]},ln=(s,t)=>t.map((r,a)=>{const n={key:a,[ts]:!0};return Object.keys(r).forEach(i=>{const l=To[i]||i;if(l==="innerHTML"||l==="cssText"){const c=r.innerHTML||r.cssText;n.dangerouslySetInnerHTML={__html:c}}else n[l]=r[i]}),H.createElement(s,n)}),Dt=(s,t,r=!0)=>{switch(s){case"title":return{toComponent:()=>Ag(s,t.title,t.titleAttributes),toString:()=>Tg(s,t.title,t.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>$d(t),toString:()=>zd(t)};default:return{toComponent:()=>ln(s,t),toString:()=>Pg(s,t,r)}}},Rg=({metaTags:s,linkTags:t,scriptTags:r,encode:a})=>{const n=ii(s,ai.meta),i=ii(t,ai.link),o=ii(r,ai.script);return{priorityMethods:{toComponent:()=>[...ln("meta",n.priority),...ln("link",i.priority),...ln("script",o.priority)],toString:()=>`${Dt("meta",n.priority,a)} ${Dt("link",i.priority,a)} ${Dt("script",o.priority,a)}`},metaTags:n.default,linkTags:i.default,scriptTags:o.default}},Mg=s=>{const{baseTag:t,bodyAttributes:r,encode:a=!0,htmlAttributes:n,noscriptTags:i,styleTags:o,title:l="",titleAttributes:c,prioritizeSeoTags:m}=s;let{linkTags:p,metaTags:x,scriptTags:g}=s,u={toComponent:()=>{},toString:()=>""};return m&&({priorityMethods:u,linkTags:p,metaTags:x,scriptTags:g}=Rg(s)),{priority:u,base:Dt("base",t,a),bodyAttributes:Dt("bodyAttributes",r,a),htmlAttributes:Dt("htmlAttributes",n,a),link:Dt("link",p,a),meta:Dt("meta",x,a),noscript:Dt("noscript",i,a),script:Dt("script",g,a),style:Dt("style",o,a),title:Dt("title",{title:l,titleAttributes:c},a)}},Bi=Mg,tn=[],Bd=!!(typeof window<"u"&&window.document&&window.document.createElement),Ui=class{constructor(s,t){vs(this,"instances",[]);vs(this,"canUseDOM",Bd);vs(this,"context");vs(this,"value",{setHelmet:s=>{this.context.helmet=s},helmetInstances:{get:()=>this.canUseDOM?tn:this.instances,add:s=>{(this.canUseDOM?tn:this.instances).push(s)},remove:s=>{const t=(this.canUseDOM?tn:this.instances).indexOf(s);(this.canUseDOM?tn:this.instances).splice(t,1)}}});this.context=s,this.canUseDOM=t||!1,t||(s.helmet=Bi({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},Ig={},Ud=H.createContext(Ig),jr,Hd=(jr=class extends d.Component{constructor(r){super(r);vs(this,"helmetData");this.helmetData=new Ui(this.props.context||{},jr.canUseDOM)}render(){return H.createElement(Ud.Provider,{value:this.helmetData.value},this.props.children)}},vs(jr,"canUseDOM",Bd),jr),Dr=(s,t)=>{const r=document.head||document.querySelector("head"),a=r.querySelectorAll(`${s}[${ts}]`),n=[].slice.call(a),i=[];let o;return t&&t.length&&t.forEach(l=>{const c=document.createElement(s);for(const m in l)if(Object.prototype.hasOwnProperty.call(l,m))if(m==="innerHTML")c.innerHTML=l.innerHTML;else if(m==="cssText")c.styleSheet?c.styleSheet.cssText=l.cssText:c.appendChild(document.createTextNode(l.cssText));else{const p=m,x=typeof l[p]>"u"?"":l[p];c.setAttribute(m,x)}c.setAttribute(ts,"true"),n.some((m,p)=>(o=p,c.isEqualNode(m)))?n.splice(o,1):i.push(c)}),n.forEach(l=>{var c;return(c=l.parentNode)==null?void 0:c.removeChild(l)}),i.forEach(l=>r.appendChild(l)),{oldTags:n,newTags:i}},Hi=(s,t)=>{const r=document.getElementsByTagName(s)[0];if(!r)return;const a=r.getAttribute(ts),n=a?a.split(","):[],i=[...n],o=Object.keys(t);for(const l of o){const c=t[l]||"";r.getAttribute(l)!==c&&r.setAttribute(l,c),n.indexOf(l)===-1&&n.push(l);const m=i.indexOf(l);m!==-1&&i.splice(m,1)}for(let l=i.length-1;l>=0;l-=1)r.removeAttribute(i[l]);n.length===i.length?r.removeAttribute(ts):r.getAttribute(ts)!==o.join(",")&&r.setAttribute(ts,o.join(","))},Og=(s,t)=>{typeof s<"u"&&document.title!==s&&(document.title=qd(s)),Hi("title",t)},vl=(s,t)=>{const{baseTag:r,bodyAttributes:a,htmlAttributes:n,linkTags:i,metaTags:o,noscriptTags:l,onChangeClientState:c,scriptTags:m,styleTags:p,title:x,titleAttributes:g}=s;Hi("body",a),Hi("html",n),Og(x,g);const u={baseTag:Dr("base",r),linkTags:Dr("link",i),metaTags:Dr("meta",o),noscriptTags:Dr("noscript",l),scriptTags:Dr("script",m),styleTags:Dr("style",p)},y={},h={};Object.keys(u).forEach(f=>{const{newTags:b,oldTags:v}=u[f];b.length&&(y[f]=b),v.length&&(h[f]=u[f].oldTags)}),t&&t(),c(s,y,h)},_a=null,Dg=s=>{_a&&cancelAnimationFrame(_a),s.defer?_a=requestAnimationFrame(()=>{vl(s,()=>{_a=null})}):(vl(s),_a=null)},Lg=Dg,jl=class extends d.Component{constructor(){super(...arguments);vs(this,"rendered",!1)}shouldComponentUpdate(t){return!bg(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:r}=this.props.context;let a=null;const n=kg(t.get().map(i=>{const o={...i.props};return delete o.context,o}));Hd.canUseDOM?Lg(n):Bi&&(a=Bi(n)),r(a)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},xi,Vd=(xi=class extends d.Component{shouldComponentUpdate(s){return!pg(bl(this.props,"helmetData"),bl(s,"helmetData"))}mapNestedChildrenToProps(s,t){if(!t)return null;switch(s.type){case"script":case"noscript":return{innerHTML:t};case"style":return{cssText:t};default:throw new Error(`<${s.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(s,t,r,a){return{...t,[s.type]:[...t[s.type]||[],{...r,...this.mapNestedChildrenToProps(s,a)}]}}mapObjectTypeChildren(s,t,r,a){switch(s.type){case"title":return{...t,[s.type]:a,titleAttributes:{...r}};case"body":return{...t,bodyAttributes:{...r}};case"html":return{...t,htmlAttributes:{...r}};default:return{...t,[s.type]:{...r}}}}mapArrayTypeChildrenToProps(s,t){let r={...t};return Object.keys(s).forEach(a=>{r={...r,[a]:s[a]}}),r}warnOnInvalidChildren(s,t){return xl(yl.some(r=>s.type===r),typeof s.type=="function"?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${yl.join(", ")} are allowed. Helmet does not support rendering <${s.type}> elements. Refer to our API for more information.`),xl(!t||typeof t=="string"||Array.isArray(t)&&!t.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${s.type}>. Did you forget to wrap your children in braces? ( <${s.type}>{\`\`}</${s.type}> ) Refer to our API for more information.`),!0}mapChildrenToProps(s,t){let r={};return H.Children.forEach(s,a=>{if(!a||!a.props)return;const{children:n,...i}=a.props,o=Object.keys(i).reduce((c,m)=>(c[vg[m]||m]=i[m],c),{});let{type:l}=a;switch(typeof l=="symbol"?l=l.toString():this.warnOnInvalidChildren(a,n),l){case"Symbol(react.fragment)":t=this.mapChildrenToProps(n,t);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(a,r,o,n);break;default:t=this.mapObjectTypeChildren(a,t,o,n);break}}),this.mapArrayTypeChildrenToProps(r,t)}render(){const{children:s,...t}=this.props;let r={...t},{helmetData:a}=t;if(s&&(r=this.mapChildrenToProps(s,r)),a&&!(a instanceof Ui)){const n=a;a=new Ui(n.context,!0),delete r.helmetData}return a?H.createElement(jl,{...r,context:a.value}):H.createElement(Ud.Consumer,null,n=>H.createElement(jl,{...r,context:n}))}},vs(xi,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),xi);const ws={title:"Moenviron Loop - Sustainable Fashion from Recycled Textiles",description:"Pioneering the circular economy through sustainable fashion. Ethical UK collection, advanced Kenya processing, and measurable global impact.",image:"https://wwtszgqxspdsarsvqqws.supabase.co/storage/v1/object/public/project-uploads/2274ce5a-a92d-4b73-b73e-99562f585de3/moenviron-logo-resized-1768037588209.webp?width=1200&height=630&resize=contain",url:"https://moenviron.com"};function Ut({title:s,description:t,image:r,url:a,type:n="website",product:i}){const o=s?`${s} | Moenviron Loop`:ws.title,l=t||ws.description,c=r||ws.image,m=a||ws.url,p={"@context":"https://schema.org","@type":"Organization",name:"Moenviron Loop",url:ws.url,logo:ws.image,description:ws.description,contactPoint:{"@type":"ContactPoint",telephone:"+44 7394 382060",contactType:"customer service",email:"info@moenviron.com",areaServed:["GB","KE"],availableLanguage:["English"]},address:{"@type":"PostalAddress",addressRegion:"Wiltshire",postalCode:"SP11 9GP",addressCountry:"GB"},sameAs:["https://www.linkedin.com/in/moses-onyuro-98336837b/","https://www.instagram.com/moenviron/","https://www.tiktok.com/@moenviron"]},x=i?{"@context":"https://schema.org","@type":"Product",name:i.name,description:i.description,image:i.image||c,sku:i.sku||i.name.toLowerCase().replace(/\s+/g,"-"),brand:{"@type":"Brand",name:i.brand||"Moenviron Loop"},category:i.category,offers:{"@type":"Offer",price:i.price,priceCurrency:i.currency,availability:`https://schema.org/${i.availability||"InStock"}`,seller:{"@type":"Organization",name:"Moenviron Loop"}},manufacturer:{"@type":"Organization",name:"Moenviron Loop",address:{"@type":"PostalAddress",addressLocality:"Nairobi",addressCountry:"KE"}},isRelatedTo:{"@type":"Thing",name:"Sustainable Fashion"},additionalProperty:[{"@type":"PropertyValue",name:"Material",value:"100% Recycled UK Textiles"},{"@type":"PropertyValue",name:"Sustainability",value:"Circular Economy Product"}]}:null,g={"@context":"https://schema.org","@type":"WebSite",name:"Moenviron Loop",url:ws.url,potentialAction:{"@type":"SearchAction",target:`${ws.url}/shop?search={search_term_string}`,"query-input":"required name=search_term_string"}};return e.jsxs(Vd,{children:[e.jsx("title",{children:o}),e.jsx("meta",{name:"description",content:l}),e.jsx("link",{rel:"canonical",href:m}),e.jsx("meta",{property:"og:title",content:o}),e.jsx("meta",{property:"og:description",content:l}),e.jsx("meta",{property:"og:image",content:c}),e.jsx("meta",{property:"og:url",content:m}),e.jsx("meta",{property:"og:type",content:n}),e.jsx("meta",{property:"og:site_name",content:"Moenviron Loop"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:o}),e.jsx("meta",{name:"twitter:description",content:l}),e.jsx("meta",{name:"twitter:image",content:c}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"googlebot",content:"index, follow"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(p)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(g)}),x&&e.jsx("script",{type:"application/ld+json",children:JSON.stringify(x)})]})}const Fg=()=>e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Sustainable Fashion from Recycled Textiles",description:"Pioneering the circular economy through sustainable fashion. Ethical UK collection, advanced Kenya processing, and measurable global impact."}),e.jsx(Ve,{}),e.jsx(ug,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx(Jx,{}),e.jsx(tg,{}),e.jsx(rg,{}),e.jsx(ng,{}),e.jsx(og,{}),e.jsx(cg,{})]}),e.jsx(We,{})]}),mt="ORCHIDS_HOVER_v1",oi="orchids_visual_edit_mode",sn="orchids_focused_element";let wl="";const Ot=s=>{try{const t=JSON.stringify(s);if(t===wl)return;wl=t}catch{}window.parent.postMessage(s,"*")},rn=4,Nl=s=>{var a;const t=s.tagName.toLowerCase(),r=["p","h1","h2","h3","h4","h5","h6","span","div","li","td","th","label","a","button"];if(s.contentEditable==="true"||t==="input"||t==="textarea")return!0;if(r.includes(t)&&((a=s.textContent)!=null&&a.trim())){const n=Array.from(s.childNodes).some(i=>{var o;return i.nodeType===Node.TEXT_NODE&&((o=i.textContent)==null?void 0:o.trim())});if(s.childElementCount===0||s.childElementCount<=1&&n)return!0}return!1},li=s=>{let t="";for(const r of s.childNodes)r.nodeType===Node.TEXT_NODE&&(t+=r.textContent||"");return t},Sa=s=>{const t=s.split(":");if(t.length<3)return null;const r=parseInt(t.pop()||"0"),a=parseInt(t.pop()||"0"),n=t.join(":");return isNaN(a)||isNaN(r)?null:{filePath:n,line:a,column:r}},_l=s=>{const t=window.getComputedStyle(s),r=(a,n)=>{if(n==="backgroundColor"&&(a==="rgba(0, 0, 0, 0)"||a==="rgb(0, 0, 0, 0)"||a==="transparent"||a===""))return"transparent";if(n==="backgroundImage"&&(a==="none"||a==="")||n==="textDecoration"&&(a.includes("none")||a===""))return"none";if(n==="fontStyle"&&(a==="normal"||a===""))return"normal";if(n==="fontWeight"){const i=parseInt(a);return isNaN(i)?a||"400":String(i)}return n==="opacity"&&(a==="1"||a==="")?"1":(n.includes("padding")||n.includes("margin"))&&(a==="0px"||a==="0")||n==="borderRadius"&&(a==="0px"||a==="0")?"0":n==="letterSpacing"&&(a==="normal"||a==="0px")||n==="gap"&&(a==="normal"||a==="0px")?"normal":a};return{fontSize:r(t.fontSize,"fontSize"),color:r(t.color,"color"),fontWeight:r(t.fontWeight,"fontWeight"),fontStyle:r(t.fontStyle,"fontStyle"),textDecoration:r(t.textDecoration,"textDecoration"),textAlign:r(t.textAlign,"textAlign"),lineHeight:r(t.lineHeight,"lineHeight"),letterSpacing:r(t.letterSpacing,"letterSpacing"),paddingLeft:r(t.paddingLeft,"paddingLeft"),paddingRight:r(t.paddingRight,"paddingRight"),paddingTop:r(t.paddingTop,"paddingTop"),paddingBottom:r(t.paddingBottom,"paddingBottom"),marginLeft:r(t.marginLeft,"marginLeft"),marginRight:r(t.marginRight,"marginRight"),marginTop:r(t.marginTop,"marginTop"),marginBottom:r(t.marginBottom,"marginBottom"),backgroundColor:r(t.backgroundColor,"backgroundColor"),backgroundImage:r(t.backgroundImage,"backgroundImage"),borderRadius:r(t.borderRadius,"borderRadius"),fontFamily:r(t.fontFamily,"fontFamily"),opacity:r(t.opacity,"opacity"),display:r(t.display,"display"),flexDirection:r(t.flexDirection,"flexDirection"),alignItems:r(t.alignItems,"alignItems"),justifyContent:r(t.justifyContent,"justifyContent"),gap:r(t.gap,"gap")}},Lr=s=>{if(!s)return"";try{const t=new URL(s,window.location.origin);if(t.pathname==="/_next/image"){const r=t.searchParams.get("url");if(r)return decodeURIComponent(r)}return t.href}catch{return s}},Sl=s=>s.includes(`
`)?`{\`${s.replace(/\n/g,"\\n")}\`}`:s;function qg(){const[s,t]=d.useState(null),[r,a]=d.useState([]),[n,i]=d.useState(null),[o,l]=d.useState(null),[c,m]=d.useState(()=>typeof window<"u"?localStorage.getItem(oi)==="true":!1),[p,x]=d.useState(!1),[g,u]=d.useState(null),[y,h]=d.useState(null),[f,b]=d.useState(!1),[v,j]=d.useState(null),[_,I]=d.useState(null),E=d.useRef(!1),O=d.useRef(null),D=d.useRef(null),N=d.useRef(null),T=d.useRef(!1),P=d.useRef(null),S=d.useRef(""),W=d.useRef(""),K=d.useRef(null),F=d.useRef(null),k=d.useRef(!1),A=d.useRef(null),q=d.useRef({}),re=d.useRef(new Map),$=d.useRef(!1),Te=d.useRef(0),fe=d.useRef(null),we=d.useRef(new Set),ke=d.useRef(new Map),Ze=d.useRef(new Map);d.useEffect(()=>{T.current=c,typeof window<"u"&&localStorage.setItem(oi,String(c))},[c]),d.useEffect(()=>{c&&(window.parent.postMessage({type:mt,msg:"VISUAL_EDIT_MODE_ACK",active:!0},"*"),window.parent.postMessage({type:mt,msg:"VISUAL_EDIT_MODE_RESTORED",active:!0},"*"),setTimeout(()=>{if(typeof window<"u"){const L=localStorage.getItem(sn);if(L)try{const{id:ge}=JSON.parse(L),ne=document.querySelector(`[data-orchids-id="${ge}"]`);if(ne){const de=ne.getBoundingClientRect(),Ie=new MouseEvent("click",{clientX:de.left+de.width/2,clientY:de.top+de.height/2,bubbles:!0,cancelable:!0});ne.dispatchEvent(Ie)}}catch{}}},500))},[]);const st=L=>({top:L.top-rn,left:L.left-rn,width:L.width+rn*2,height:L.height+rn*2}),Z=()=>{if(N.current){const L=N.current.getBoundingClientRect();i(st(L))}};d.useEffect(()=>{if(c&&!A.current){const L=document.createElement("style");L.textContent=`
        [contenteditable="true"]:focus {
          outline: none !important;
          box-shadow: none !important;
          border-color: inherit !important;
        }
        [contenteditable="true"] {
          cursor: text !important;
        }
        /* Prevent the default blue highlight on contenteditable */
        [contenteditable="true"]::selection {
          background-color: rgba(59, 130, 246, 0.3);
        }
        [contenteditable="true"]::-moz-selection {
          background-color: rgba(59, 130, 246, 0.3);
        }
        /* Prevent child elements from being editable */
        [contenteditable="true"] [contenteditable="false"] {
          user-select: none !important;
          -webkit-user-select: none !important;
          -moz-user-select: none !important;
          -ms-user-select: none !important;
          opacity: 0.7 !important;
          cursor: default !important;
        }
        /* Ensure protected elements can't be selected */
        [data-orchids-protected="true"] {
          user-select: none !important;
          -webkit-user-select: none !important;
          -moz-user-select: none !important;
          -ms-user-select: none !important;
        }
      `,document.head.appendChild(L),A.current=L}else!c&&A.current&&(A.current.remove(),A.current=null);return()=>{A.current&&(A.current.remove(),A.current=null)}},[c]);const ze=L=>{L.querySelectorAll("*").forEach(ne=>{const de=ne;de.contentEditable="false",de.setAttribute("data-orchids-protected","true"),de.style.userSelect="none",de.style.webkitUserSelect="none"})},V=L=>{L.querySelectorAll('[data-orchids-protected="true"]').forEach(ne=>{const de=ne;de.removeAttribute("contenteditable"),de.removeAttribute("data-orchids-protected"),de.style.userSelect="",de.style.webkitUserSelect=""})},je=L=>{if(L!==F.current){console.warn("Attempting to handle text change for non-editing element");return}const ge=L.getAttribute("data-orchids-id");if(!ge)return;let ne,de;if(L.childElementCount>0?(ne=li(L),de=S.current):(ne=L.innerText||L.textContent||"",de=S.current),ne!==de){const Ie=Sa(ge);if(!Ie)return;const Pe={type:mt,msg:"TEXT_CHANGED",id:ge,oldText:Sl(de),newText:Sl(ne),filePath:Ie.filePath,line:Ie.line,column:Ie.column};Ot(Pe),S.current=ne}},xe=(L,ge)=>{const ne=L.getAttribute("data-orchids-id");if(!ne||!Sa(ne))return;document.querySelectorAll(`[data-orchids-id="${ne}"]`).forEach(ie=>{Object.entries(ge).forEach(([le,pe])=>{const G=le.replace(/([A-Z])/g,"-$1").toLowerCase();let J=pe;le==="backgroundColor"&&(pe==="transparent"||pe==="rgba(0, 0, 0, 0)"||pe==="rgb(0, 0, 0, 0)")&&(J="transparent"),le==="backgroundColor"&&J==="transparent"||le==="backgroundImage"&&pe==="none"||le==="textDecoration"&&pe==="none"||le==="fontStyle"&&pe==="normal"||le==="opacity"&&pe==="1"||(le.includes("padding")||le.includes("margin"))&&pe==="0"||le==="borderRadius"&&pe==="0"||le==="letterSpacing"&&pe==="normal"||le==="gap"&&pe==="normal"?ie.style.removeProperty(G):ie.style.setProperty(G,J,"important")})});const Pe=re.current.get(ne)||{};re.current.set(ne,{...Pe,...ge}),$.current=!0,requestAnimationFrame(()=>{Z()})},Ce=L=>{if(!$.current)return;const ge=L.getAttribute("data-orchids-id");if(!ge)return;const ne=Sa(ge);if(!ne)return;const de=re.current.get(ge);if(!de||Object.keys(de).length===0)return;const Ie=L.getAttribute("class")||"",Pe={type:mt,msg:"STYLE_BLUR",id:ge,styles:de,className:Ie,filePath:ne.filePath,line:ne.line,column:ne.column};Ot(Pe),$.current=!1},xt=()=>{const L=K.current;if(!L)return;const ge=L.getAttribute("data-orchids-id");if(!ge)return;const ne=Sa(ge);if(!ne)return;const de=Lr(L.src),Ie=Lr(W.current);if(!de||de===Ie)return;const Pe={type:mt,msg:"IMAGE_BLUR",id:ge,oldSrc:Ie,newSrc:de,filePath:ne.filePath,line:ne.line,column:ne.column};Ot(Pe),W.current=de,K.current=null};d.useEffect(()=>{function L(ge){var ne,de,Ie;if(((ne=ge.data)==null?void 0:ne.type)==="ORCHIDS_STYLE_UPDATE"){const{elementId:Pe,styles:ie}=ge.data,le=document.querySelectorAll(`[data-orchids-id="${Pe}"]`);if(le.length>0){const pe=ie.fontFamily||ie.fontFamily;if(pe){const G=pe.replace(/['\s]+/g,"+");if(!we.current.has(G)){const J=document.createElement("link");J.rel="stylesheet",J.href=`https://fonts.googleapis.com/css2?family=${G}:wght@400&display=swap`,document.head.appendChild(J),we.current.add(G)}}if(pe){ke.current.set(Pe,pe);const G=Ze.current.get(Pe);G&&clearTimeout(G);const J=window.setTimeout(()=>{ke.current.delete(Pe),Ze.current.delete(Pe)},2e3);Ze.current.set(Pe,J)}le.forEach(G=>{N.current===G?xe(G,ie):Object.entries(ie).forEach(([J,ve])=>{const Ke=J.replace(/([A-Z])/g,"-$1").toLowerCase();let lt=String(ve);J==="backgroundColor"&&(ve==="transparent"||ve==="rgba(0, 0, 0, 0)"||ve==="rgb(0, 0, 0, 0)")&&(lt="transparent"),J==="backgroundColor"&&lt==="transparent"||J==="backgroundImage"&&ve==="none"||J==="textDecoration"&&ve==="none"||J==="fontStyle"&&ve==="normal"||J==="opacity"&&ve==="1"||(J.includes("padding")||J.includes("margin"))&&ve==="0"||J==="borderRadius"&&ve==="0"||J==="letterSpacing"&&ve==="normal"||J==="gap"&&ve==="normal"?G.style.removeProperty(Ke):G.style.setProperty(Ke,lt,"important")})})}}else if(((de=ge.data)==null?void 0:de.type)==="ORCHIDS_IMAGE_UPDATE"){const{elementId:Pe,src:ie,oldSrc:le}=ge.data;let pe=null;if(document.querySelectorAll(`[data-orchids-id="${Pe}"]`).forEach(J=>{if(J.tagName.toLowerCase()==="img"){const ve=J,Ke=Lr(ve.src);pe||(pe=ve),le&&Lr(le)===Ke&&(pe=ve)}}),!pe)return;if(pe.tagName.toLowerCase()==="img"){const J=pe;J.removeAttribute("srcset"),J.srcset="",J.src=ie,W.current=Lr(ie),K.current=J,J.onload=()=>Z()}}else if(((Ie=ge.data)==null?void 0:Ie.type)==="RESIZE_ELEMENT"){const{elementId:Pe,width:ie,height:le}=ge.data,pe=document.querySelector(`[data-orchids-id="${Pe}"]`);pe&&N.current===pe&&(pe.style.setProperty("width",`${ie}px`,"important"),pe.style.setProperty("height",`${le}px`,"important"),Z())}}return window.addEventListener("message",L),()=>window.removeEventListener("message",L)},[]);const ut=(L,ge)=>{if(!N.current)return;L.preventDefault(),L.stopPropagation();const ne=N.current.getBoundingClientRect();t(null),O.current=null,document.body.style.pointerEvents="none",document.querySelectorAll(".resize-handle").forEach(Ie=>{Ie.style.pointerEvents="auto"}),x(!0),E.current=!0,u(ge),h({x:L.clientX,y:L.clientY,width:ne.width,height:ne.height})};d.useEffect(()=>{if(!p||!y||!g||!N.current)return;const L=ne=>{var pe;const de=ne.clientX-y.x,Ie=ne.clientY-y.y;let Pe=y.width,ie=y.height;g.includes("e")&&(Pe=y.width+de),g.includes("w")&&(Pe=y.width-de),g.includes("s")&&(ie=y.height+Ie),g.includes("n")&&(ie=y.height-Ie);const le=(pe=N.current)==null?void 0:pe.parentElement;if(le){const G=le.getBoundingClientRect(),J=window.getComputedStyle(le),ve=parseFloat(J.paddingLeft)||0,Ke=parseFloat(J.paddingRight)||0,lt=parseFloat(J.paddingTop)||0,ct=parseFloat(J.paddingBottom)||0,Nt=G.width-ve-Ke,pt=G.height-lt-ct,_t=Pe>Nt,It=ie>pt;Pe=Math.max(20,_t?Pe:Math.min(Pe,Nt)),ie=Math.max(20,It?ie:Math.min(ie,pt))}else Pe=Math.max(20,Pe),ie=Math.max(20,ie);s&&t(null),o&&window.parent.postMessage({type:mt,msg:"RESIZE_ELEMENT",elementId:o,width:Math.round(Pe),height:Math.round(ie)},"*")},ge=()=>{if(N.current&&o){const ne=N.current,de=window.getComputedStyle(ne),Ie=parseFloat(de.width)||ne.offsetWidth,Pe=parseFloat(de.height)||ne.offsetHeight,ie=de.maxWidth,le=de.maxHeight,pe=ie&&ie!=="none"&&ie!=="initial",G=le&&le!=="none"&&le!=="initial",J=ne.parentElement;let ve=`${Math.round(Ie)}px`,Ke=`${Math.round(Pe)}px`;if(J){const pt=J.getBoundingClientRect(),_t=window.getComputedStyle(J),It=parseFloat(_t.paddingLeft)||0,Kt=parseFloat(_t.paddingRight)||0,cs=parseFloat(_t.paddingTop)||0,or=parseFloat(_t.paddingBottom)||0,va=pt.width-It-Kt,Or=pt.height-cs-or,Tt=Ie/va*100,yt=Pe/Or*100;(Math.abs(Tt-Math.round(Tt))<.1||[25,33.333,50,66.667,75,100].some(gt=>Math.abs(Tt-gt)<.5))&&(ve=`${Math.round(Tt*10)/10}%`),Math.abs(yt-Math.round(yt))<.1&&[25,50,75,100].includes(Math.round(yt))&&(Ke=`${Math.round(yt)}%`)}const lt={};lt.width=ve,lt.height=Ke,pe&&(lt.maxWidth=ve),G&&(lt.maxHeight=Ke);const ct={type:mt,msg:"STYLE_BLUR",id:o,styles:lt,filePath:"",line:0,column:0,className:ne.getAttribute("class")||""},Nt=ne.getAttribute("data-orchids-id");if(Nt){const pt=Sa(Nt);pt&&(ct.filePath=pt.filePath,ct.line=pt.line,ct.column=pt.column)}window.parent.postMessage(ct,"*")}x(!1),E.current=!1,u(null),h(null),document.body.style.pointerEvents="",O.current=null};return document.addEventListener("mousemove",L),document.addEventListener("mouseup",ge),()=>{document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",ge)}},[p,y,g,o,s]);const Wt=()=>{if(F.current){const L=F.current;F.current=null,Ce(L),je(L),L.childElementCount>0&&V(L),k.current||(L.contentEditable="false");const ne=(L.getAttribute("style")||"").replace(/outline:\s*none\s*!important;?/gi,"").replace(/box-shadow:\s*none\s*!important;?/gi,"").trim().replace(/;\s*;/g,";").replace(/^;|;$/g,"");ne?L.setAttribute("style",ne):L.removeAttribute("style"),L.blur();const de=L._editHandlers;de&&(L.removeEventListener("focus",de.focus),L.removeEventListener("blur",de.blur),L.removeEventListener("input",de.input),delete L._editHandlers),k.current=!1,S.current=""}};return d.useEffect(()=>{if(!c)return;const L=ne=>{const Ie=ne.target.closest("a");Ie&&!Ie.isContentEditable&&(ne.preventDefault(),ne.stopPropagation())},ge=ne=>{ne.preventDefault(),ne.stopPropagation()};return document.addEventListener("click",L,!0),document.addEventListener("submit",ge,!0),()=>{document.removeEventListener("click",L,!0),document.removeEventListener("submit",ge,!0)}},[c]),d.useEffect(()=>{c||(Wt(),re.current.clear(),$.current=!1,K.current=null)},[c]),d.useEffect(()=>{if(N.current){const L=()=>{if(Z(),N.current&&o){const ne=N.current.getBoundingClientRect(),de=st(ne);if(de){const Ie={type:mt,msg:"FOCUS_MOVED",id:o,rect:{top:de.top,left:de.left,width:de.width,height:de.height}};Ot(Ie)}}};window.addEventListener("scroll",L,!0),window.addEventListener("resize",L);const ge=new ResizeObserver(L);return ge.observe(N.current),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L),ge.disconnect()}}},[o]),d.useEffect(()=>{function L(ie){var pe;if(E.current||!T.current||f)return;const le=((pe=document.elementFromPoint(ie.clientX,ie.clientY))==null?void 0:pe.closest("[data-orchids-id]"))??null;if(le!==O.current){if(O.current=le,!le){t(null),a([]),j(null),D.current=null,xt(),Ot({type:mt,msg:"HIT",id:null,tag:null,rect:null});return}const G=le.getAttribute("data-orchids-id");if(G===D.current)return;D.current=G;const J=le.getAttribute("data-orchids-name")||le.tagName.toLowerCase(),ve=document.querySelectorAll(`[data-orchids-id="${G}"]`),Ke=[];if(ve.forEach(ct=>{if(ct.getAttribute("data-orchids-id")===o)return;const pt=ct.getBoundingClientRect();Ke.push(st(pt))}),a(Ke),G!==o){const ct=le.getBoundingClientRect(),Nt=st(ct);t(Nt)}else t(null);j(J);const lt={type:mt,msg:"HIT",id:G,tag:J,rect:G!==o?st(le.getBoundingClientRect()):null};Ot(lt)}}function ge(){if(!T.current||E.current)return;t(null),a([]),j(null),xt(),O.current=null,D.current=null,Ot({type:mt,msg:"HIT",id:null,tag:null,rect:null})}function ne(ie){var pe;if(E.current||!T.current)return;const le=(pe=ie.target)==null?void 0:pe.closest("[data-orchids-id]");if(le&&Nl(le)&&(k.current=le.contentEditable==="true",!k.current)){const G=le.getAttribute("style")||"";le.setAttribute("style",`${G}; outline: none !important; box-shadow: none !important;`),le.contentEditable="true",le.childElementCount>0&&ze(le)}}function de(ie){if(E.current||!T.current)return;const le=Date.now();if(le-Te.current<100)return;Te.current=le;const G=ie.target.closest("[data-orchids-id]");if(G){const J=G.getAttribute("data-orchids-name")||G.tagName.toLowerCase(),ve=G.getAttribute("data-orchids-id"),Ke=Nl(G),lt=G.tagName.toLowerCase()==="a"||!!G.closest("a"),ct=G.tagName.toLowerCase()==="button"||G.getAttribute("role")==="button";(lt||ct||!Ke)&&(ie.preventDefault(),ie.stopPropagation());const Nt=N.current;if(N.current=G,l(ve),I(J),ve&&typeof window<"u"){const Tt={id:ve,tag:J};localStorage.setItem(sn,JSON.stringify(Tt))}const pt=document.querySelectorAll(`[data-orchids-id="${ve}"]`),_t=[];if(pt.forEach(Tt=>{if(Tt===G)return;const yt=Tt.getBoundingClientRect();_t.push(st(yt))}),a(_t),_t.length>0&&j(J),G.tagName.toLowerCase()==="img"?K.current=G:K.current=null,q.current=_l(G),Ke&&(fe.current&&(clearTimeout(fe.current),fe.current=null),F.current&&F.current!==G&&(F.current.blur(),Wt()),G!==F.current)){F.current=G,G.childElementCount>0?S.current=li(G):S.current=G.innerText||G.textContent||"";const yt=(gt=>({handleFocus:()=>{gt===F.current&&(Ce(gt),gt.childElementCount>0?S.current=li(gt):S.current=gt.innerText||gt.textContent||"",$.current=!1)},handleBlur:()=>{gt===F.current&&(Ce(gt),je(gt))},handleInput:()=>{F.current}}))(G);G.addEventListener("focus",yt.handleFocus),G.addEventListener("blur",yt.handleBlur),G.addEventListener("input",yt.handleInput),G._editHandlers={focus:yt.handleFocus,blur:yt.handleBlur,input:yt.handleInput}}const It=G.getBoundingClientRect(),Kt=st(It);i(Kt),t(null);const cs=G.getAttribute("class")||"",or=G.tagName.toLowerCase()==="img"?G.src:void 0;or&&(W.current=Lr(or));const va=_l(G),Or={type:mt,msg:"ELEMENT_CLICKED",id:ve,tag:J,rect:Kt?{top:Kt.top,left:Kt.left,width:Kt.width,height:Kt.height}:{top:0,left:0,width:0,height:0},clickPosition:{x:ie.clientX,y:ie.clientY},isEditable:Ke,currentStyles:va,className:cs,src:or};Ot(Or),setTimeout(()=>{xt(),Nt&&Nt!==G&&Ce(Nt),F.current&&F.current!==G&&Wt()},0)}else if(N.current){xt(),Ce(N.current),Wt(),N.current=null,l(null),I(null),i(null),t(null),a([]),j(null),typeof window<"u"&&localStorage.removeItem(sn);const J={type:mt,msg:"ELEMENT_CLICKED",id:null,tag:null,rect:{top:0,left:0,width:0,height:0},clickPosition:{x:ie.clientX,y:ie.clientY},isEditable:!1,currentStyles:{},className:""};Ot(J)}}function Ie(ie){var le;if(((le=ie.data)==null?void 0:le.type)===mt){if(ie.data.msg==="PREVIEW_FONT"&&"elementId"in ie.data){const{elementId:pe,fontFamily:G}=ie.data;if(ke.current.has(pe))return;const J=document.querySelector(`[data-orchids-id="${pe}"]`);if(!J)return;const ve=G.replace(/\s+/g,"+");if(!we.current.has(ve)){const Ke=document.createElement("link");Ke.rel="stylesheet",Ke.href=`https://fonts.googleapis.com/css2?family=${ve}:wght@400&display=swap`,document.head.appendChild(Ke),we.current.add(ve)}J.style.fontFamily=`'${G}', sans-serif`;return}if(ie.data.msg==="SCROLL"&&"dx"in ie.data&&"dy"in ie.data&&window.scrollBy(ie.data.dx,ie.data.dy),ie.data.msg==="VISUAL_EDIT_MODE"&&"active"in ie.data){const pe=ie.data.active;m(pe),!pe&&typeof window<"u"&&(localStorage.removeItem(oi),localStorage.removeItem(sn)),window.parent.postMessage({type:mt,msg:"VISUAL_EDIT_MODE_ACK",active:pe},"*"),pe||(xt(),Wt(),K.current=null,t(null),a([]),i(null),l(null),O.current=null,N.current=null,$.current=!1,j(null),I(null),Ot({type:mt,msg:"HIT",id:null,tag:null,rect:null}))}if(ie.data.msg==="CLEAR_INLINE_STYLES"&&"elementId"in ie.data&&(document.querySelectorAll(`[data-orchids-id="${ie.data.elementId}"]`).forEach(G=>{["fontSize","color","fontWeight","fontStyle","textDecoration","textAlign","paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","backgroundColor","backgroundImage"].forEach(ve=>{G.style[ve]=""})}),re.current.delete(ie.data.elementId)),ie.data.msg==="SHOW_ELEMENT_HOVER"&&"elementId"in ie.data){const{elementId:pe}=ie.data;if(!pe){a([]),j(null);return}const G=document.querySelectorAll(`[data-orchids-id="${pe}"]`);if(G.length>0){const J=[];let ve="";G.forEach(Ke=>{if(Ke===N.current)return;const lt=Ke.getBoundingClientRect();J.push(st(lt)),ve||(ve=Ke.getAttribute("data-orchids-name")||Ke.tagName.toLowerCase())}),a(J),j(J.length>0?ve:null)}}}}function Pe(){if(E.current||!T.current)return;b(!0),t(null),a([]),Ot({type:mt,msg:"SCROLL_STARTED"}),P.current&&clearTimeout(P.current),P.current=window.setTimeout(()=>{b(!1),Ot({type:mt,msg:"SCROLL_STOPPED"})},16)}return document.addEventListener("pointermove",L,{passive:!0}),document.addEventListener("pointerleave",ge),document.addEventListener("mousedown",ne,{capture:!0}),document.addEventListener("click",de,{capture:!0}),window.addEventListener("message",Ie),window.addEventListener("scroll",Pe,!0),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerleave",ge),document.removeEventListener("mousedown",ne,!0),document.removeEventListener("click",de,!0),window.removeEventListener("message",Ie),window.removeEventListener("scroll",Pe,!0),P.current&&clearTimeout(P.current)}},[o,p]),e.jsxs(e.Fragment,{children:[c&&!p&&e.jsx(e.Fragment,{children:r.filter(L=>L!==null).map((L,ge)=>e.jsxs("div",{children:[e.jsx("div",{className:"fixed pointer-events-none border-[0.5px] border-[#38bdf8] bg-blue-200/20 border-dashed rounded-sm",style:{zIndex:1e5,left:L.left,top:L.top,width:L.width,height:L.height}}),v&&e.jsx("div",{className:"fixed pointer-events-none text-[10px] text-white bg-[#38bdf8] px-1 py-0.5 rounded-sm",style:{zIndex:100001,left:L.left,top:L.top-20},children:v})]},ge))}),c&&n&&e.jsxs(e.Fragment,{children:[_&&e.jsx("div",{className:"fixed text-[10px] font-semibold text-white bg-[#3b82f6] px-1 rounded-sm pointer-events-none select-none",style:{zIndex:100003,left:n.left-4,top:n.top-16},children:_}),e.jsx("div",{className:"fixed pointer-events-none border-[1.5px] border-[#38bdf8] rounded-sm",style:{zIndex:100001,left:n.left,top:n.top,width:n.width,height:n.height}}),!p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-nw-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left-4,top:n.top-4},onMouseDown:L=>ut(L,"nw")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-ne-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left+n.width-4,top:n.top-4},onMouseDown:L=>ut(L,"ne")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-sw-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left-4,top:n.top+n.height-4},onMouseDown:L=>ut(L,"sw")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-se-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left+n.width-4,top:n.top+n.height-4},onMouseDown:L=>ut(L,"se")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-n-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left+n.width/2-4,top:n.top-4},onMouseDown:L=>ut(L,"n")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-s-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left+n.width/2-4,top:n.top+n.height-4},onMouseDown:L=>ut(L,"s")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-w-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left-4,top:n.top+n.height/2-4},onMouseDown:L=>ut(L,"w")}),e.jsx("div",{className:"fixed w-2 h-2 bg-[#38bdf8] rounded-full cursor-e-resize pointer-events-auto resize-handle",style:{zIndex:100002,left:n.left+n.width-4,top:n.top+n.height/2-4},onMouseDown:L=>ut(L,"e")})]})]})]})}const zg={async getProducts(){const{data:s,error:t}=await M.from("products").select("*").eq("is_active",!0).order("created_at",{ascending:!1});if(t)throw t;return s||[]},async getProductById(s){const{data:t,error:r}=await M.from("products").select("*").eq("id",s).single();if(r)throw r;return t},async getProductsByCategory(s){const{data:t,error:r}=await M.from("products").select("*").eq("category",s).eq("is_active",!0);if(r)throw r;return t||[]}};function $g(){return os({queryKey:["products"],queryFn:async()=>await zg.getProducts(),staleTime:1e3*60*5})}const Vi=async(s,t,r,a)=>{try{const n=new Date().toISOString().split("T")[0],{data:i,error:o}=await M.from("product_performance_stats").select("*").eq("product_id",s).eq("date",n).single();if(o&&o.code!=="PGRST116"){console.error("Error checking product stats:",o);return}if(i){const l={};t==="view"?l.views=(i.views||0)+1:t==="add_to_cart"?l.add_to_cart=(i.add_to_cart||0)+1:t==="purchase"&&(l.purchases=(i.purchases||0)+1);const{error:c}=await M.from("product_performance_stats").update(l).eq("id",i.id);c&&console.error("Error updating product stats:",c)}else{const l={product_id:s,date:n,views:t==="view"?1:0,add_to_cart:t==="add_to_cart"?1:0,purchases:t==="purchase"?1:0,revenue:t==="purchase"&&a?a:0},{error:c}=await M.from("product_performance_stats").insert(l);c&&console.error("Error inserting product stats:",c)}}catch(n){console.error(`Unexpected error tracking product ${t}:`,n)}},Bg=["All","Tops","Bottoms","Dresses","Outerwear","Accessories","Footwear","Swimwear"],Ug=()=>{const{data:s=[]}=$g(),[t,r]=d.useState(""),[a,n]=d.useState("All"),i=s.filter(l=>{var p;const c=l.name.toLowerCase().includes(t.toLowerCase())||(((p=l.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))??!1),m=a==="All"||l.category===a;return c&&m}),o=l=>{Vi(l.id,"view",l.name)};return e.jsxs("div",{className:"flex min-h-screen flex-col bg-white",children:[e.jsx(Ut,{title:"Shop Sustainable Fashion",description:"Discover ethically crafted pieces that give waste a second life. Beautifully designed, radically circular fashion from Moenviron Loop."}),e.jsx(Ve,{}),e.jsxs("main",{className:"flex-1",children:[e.jsxs("section",{className:"relative pt-24 pb-12 md:pt-32 md:pb-20 overflow-hidden min-h-[40vh] md:min-h-[50vh] flex items-center",children:[e.jsxs("div",{className:"absolute inset-0 z-0",children:[e.jsx("video",{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,poster:"https://images.unsplash.com/photo-1523381210434-271e8be1f52b?auto=format&fit=crop&q=80&w=2070",className:"h-full w-full object-cover",children:e.jsx("source",{src:"https://cdn.coverr.co/videos/coverr-moving-fabrics-9556/1080p.mp4",type:"video/mp4"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/40 to-white"})]}),e.jsx("div",{className:"container px-4 md:px-6 relative z-10",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center space-y-4 md:space-y-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 text-xs md:text-sm font-medium text-white/90 animate-fade-in",children:[e.jsx(wr,{className:"h-3.5 w-3.5 md:h-4 md:w-4","aria-hidden":"true"}),e.jsx("span",{children:"Circular Fashion Collection"})]}),e.jsxs("h1",{className:"text-4xl md:text-7xl font-display leading-tight text-white animate-fade-in",style:{animationDelay:"0.1s"},children:["The ",e.jsx("span",{className:"italic text-[#7CC38A]",children:"Marketplace"})]}),e.jsx("p",{className:"text-base md:text-lg text-white/80 font-light max-w-lg mx-auto leading-relaxed animate-fade-in px-4",style:{animationDelay:"0.2s"},children:"Discover ethically crafted pieces that give waste a second life."})]})})]}),e.jsx("section",{className:"sticky top-16 z-40 border-y border-black/5 bg-white/80 backdrop-blur-md py-3 md:py-4",children:e.jsxs("div",{className:"container px-4 md:px-6 flex flex-col md:flex-row items-center justify-between gap-4 md:gap-6",children:[e.jsx("div",{className:"flex items-center gap-4 md:gap-6 overflow-x-auto no-scrollbar w-full md:w-auto pb-1",children:Bg.map(l=>e.jsx("button",{onClick:()=>n(l),className:`text-[10px] md:text-[11px] font-bold uppercase tracking-[0.15em] md:tracking-[0.2em] transition-all whitespace-nowrap ${a===l?"text-black border-b-2 border-black pb-1":"text-black/30 hover:text-black/60 pb-1"}`,children:l},l))}),e.jsxs("div",{className:"relative w-full md:w-72",children:[e.jsx(vo,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-black/20"}),e.jsx("input",{type:"text",placeholder:"Find upcycled styles...",value:t,onChange:l=>r(l.target.value),className:"w-full bg-[#F9F7F2] border-none rounded-full py-2 md:py-2.5 pl-10 pr-4 text-sm focus:ring-1 focus:ring-black/5 transition-all"})]})]})}),e.jsx("section",{className:"py-8 md:py-16",children:e.jsx("div",{className:"container px-4 md:px-6",children:i.length===0?e.jsxs("div",{className:"py-16 md:py-24 text-center",children:[e.jsx("h3",{className:"text-xl md:text-2xl font-display mb-4",children:"No products found"}),e.jsx("p",{className:"text-muted-foreground font-light mb-6 md:mb-8 text-sm md:text-base",children:"Try adjusting your filters or search."}),e.jsx(R,{onClick:()=>{r(""),n("All")},variant:"outline",className:"rounded-full px-8",children:"Clear Filters"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3 md:gap-4 md:grid-cols-3 lg:grid-cols-4",children:i.map(l=>e.jsx(Oe,{to:`/shop/${l.id}`,className:"group",onClick:()=>o(l),children:e.jsxs("div",{className:"space-y-2 md:space-y-3",children:[e.jsxs("div",{className:"relative aspect-[3/4] overflow-hidden rounded-lg md:rounded-xl bg-[#F9F7F2]",children:[l.image_url?e.jsx("img",{src:l.image_url,alt:l.name,loading:"lazy",className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105",onError:c=>{const m=c.target;m.src="https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?q=80&w=800&auto=format&fit=crop"}}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{className:"h-6 w-6 md:h-8 md:w-8 text-black/10"})}),e.jsx("div",{className:"absolute bottom-2 right-2 translate-y-2 opacity-0 group-hover:translate-y-0 group-hover:opacity-100 transition-all duration-300 hidden md:block",children:e.jsx("div",{className:"bg-white/90 backdrop-blur-md p-2 rounded-full shadow-lg",children:e.jsx(As,{className:"h-4 w-4 text-black"})})}),l.carbon_offset_kg&&e.jsx("div",{className:"absolute top-1.5 left-1.5 md:top-2 md:left-2",children:e.jsxs("span",{className:"text-[8px] md:text-[9px] font-bold text-white bg-[#2D5A43] px-1.5 py-0.5 md:px-2 md:py-1 rounded-full",children:["-",l.carbon_offset_kg,"kg CO₂"]})})]}),e.jsxs("div",{className:"text-left space-y-0.5 md:space-y-1",children:[e.jsx("span",{className:"text-[8px] md:text-[9px] font-semibold uppercase tracking-widest text-black/40",children:l.category}),e.jsx("h3",{className:"text-xs md:text-sm font-medium leading-tight group-hover:text-[#2D5A43] transition-colors line-clamp-2",children:l.name}),e.jsxs("span",{className:"text-xs md:text-sm font-semibold text-[#1A1A1A]",children:[l.currency==="GBP"?"£":l.currency,l.price.toFixed(2)]})]})]})},l.id))})})}),e.jsx("section",{className:"py-12 md:py-24 bg-white border-t border-black/5",children:e.jsx("div",{className:"container px-4 md:px-6",children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl md:rounded-[2rem] bg-[#1A1A1A] text-white p-6 md:p-12 lg:p-20",children:[e.jsx("div",{className:"absolute inset-0 opacity-20",children:e.jsx("img",{src:"https://images.unsplash.com/photo-1544816155-12df9643f363?q=80&w=1200&auto=format&fit=crop",alt:"Background",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"relative z-10 grid md:grid-cols-2 gap-8 md:gap-12 items-center",children:[e.jsxs("div",{className:"space-y-4 md:space-y-6 text-center md:text-left",children:[e.jsxs("h2",{className:"text-2xl md:text-4xl lg:text-5xl font-display leading-tight",children:["Stay in the ",e.jsx("span",{className:"italic text-[#7CC38A]",children:"Loop"})]}),e.jsx("p",{className:"text-sm md:text-lg text-white/60 font-light max-w-sm mx-auto md:mx-0",children:"Be the first to know about new collection drops and artisan stories."})]}),e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:gap-4",children:[e.jsx("input",{type:"email",placeholder:"Your email address",className:"w-full bg-white/10 border border-white/20 rounded-full px-5 py-3 md:px-6 md:py-4 text-white text-sm md:text-base placeholder:text-white/40 focus:outline-none focus:ring-2 focus:ring-[#2D5A43] transition-all"}),e.jsxs(R,{className:"w-full md:w-auto bg-white text-black hover:bg-[#F9F7F2] rounded-full h-12 md:h-14 px-6 md:px-8 font-bold uppercase tracking-widest text-[9px] md:text-[10px]",children:["Subscribe",e.jsx(ss,{className:"ml-2 h-3.5 w-3.5 md:h-4 md:w-4"})]})]}),e.jsx("p",{className:"text-[9px] md:text-[10px] text-white/30 uppercase tracking-widest text-center md:text-left",children:"By joining, you agree to receive circular updates."})]})]})]})})})]}),e.jsx(We,{})]})},Hg=Wa("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Le({className:s,variant:t,...r}){return e.jsx("div",{className:me(Hg({variant:t}),s),...r})}const ci={async getWishlist(s){const{data:t,error:r}=await M.from("wishlists").select("*").eq("user_id",s);if(r)throw r;return t||[]},async addToWishlist(s,t){const{error:r}=await M.from("wishlists").insert({user_id:s,product_id:t});if(r)throw r},async removeFromWishlist(s,t){const{error:r}=await M.from("wishlists").delete().eq("user_id",s).eq("product_id",t);if(r)throw r}},di="guest_wishlist";function Wd(){const{user:s}=Bt(),t=is(),[r,a]=d.useState([]);d.useEffect(()=>{if(!s){const p=localStorage.getItem(di);if(p)try{a(JSON.parse(p))}catch(x){console.error("Failed to parse guest wishlist",x)}}},[s]);const{data:n=[],isLoading:i}=os({queryKey:["wishlist",s==null?void 0:s.id],queryFn:()=>s?ci.getWishlist(s.id):[],enabled:!!s}),o=it({mutationFn:p=>s?ci.addToWishlist(s.id,p):Promise.resolve(),onSuccess:(p,x)=>{if(s)t.invalidateQueries({queryKey:["wishlist",s.id]});else{const g=[...r,x];a(g),localStorage.setItem(di,JSON.stringify(g))}C.success("Added to wishlist")},onError:p=>{p.code==="23505"?C.info("Already in your wishlist"):C.error("Failed to add to wishlist")}}),l=it({mutationFn:p=>s?ci.removeFromWishlist(s.id,p):Promise.resolve(),onSuccess:(p,x)=>{if(s)t.invalidateQueries({queryKey:["wishlist",s.id]});else{const g=r.filter(u=>u!==x);a(g),localStorage.setItem(di,JSON.stringify(g))}C.success("Removed from wishlist")},onError:()=>{C.error("Failed to remove from wishlist")}});return{items:s?n:r.map(p=>({id:p,product_id:p,user_id:"guest",created_at:new Date().toISOString()})),isLoading:i,addToWishlist:p=>o.mutateAsync(p),removeFromWishlist:p=>l.mutateAsync(p),isInWishlist:p=>s?n.some(x=>x.product_id===p):r.includes(p),fetchWishlist:()=>t.invalidateQueries({queryKey:["wishlist",s==null?void 0:s.id]})}}const Vg=()=>{const{id:s}=zc(),[t,r]=d.useState(null),[a,n]=d.useState(!0),[i,o]=d.useState(1),{user:l}=Bt(),{isInWishlist:c,addToWishlist:m,removeFromWishlist:p}=Wd();d.useEffect(()=>{async function u(){if(!s)return;const{data:y,error:h}=await M.from("products").select("*").eq("id",s).eq("is_active",!0).maybeSingle();!h&&y&&(r(y),Vi(y.id,"view",y.name)),n(!1)}u()},[s]);const x=()=>{if(!t)return;Vi(t.id,"add_to_cart",t.name);const u=localStorage.getItem("moenviron-cart"),y=u?JSON.parse(u):[],h=y.findIndex(f=>f.id===t.id);h>=0?y[h].quantity+=i:y.push({id:t.id,name:t.name,price:t.price,currency:t.currency,quantity:i,image_url:t.image_url,carbon_offset_kg:t.carbon_offset_kg}),localStorage.setItem("moenviron-cart",JSON.stringify(y)),window.dispatchEvent(new CustomEvent("cart-updated")),C.success(`Added ${i} ${t.name} to cart`)},g=()=>{t&&(c(t.id)?p(t.id):m(t.id))};return a?e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}),e.jsx(We,{})]}):t?e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:t.name,description:t.description||`${t.name} - Sustainable fashion made from 100% recycled UK textiles`,image:t.image_url||void 0,type:"product",product:{name:t.name,description:t.description||`${t.name} - Sustainable fashion made from 100% recycled UK textiles`,price:t.price,currency:t.currency,image:t.image_url||void 0,sku:t.id,availability:t.stock_quantity>0?"InStock":"OutOfStock",category:t.category}}),e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-8",children:e.jsxs("div",{className:"container",children:[e.jsxs(Oe,{to:"/shop",className:"mb-6 inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Rn,{className:"h-4 w-4"}),"Back to Shop"]}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"relative aspect-square overflow-hidden rounded-2xl bg-muted",children:[t.image_url?e.jsx("img",{src:t.image_url,alt:t.name,className:"h-full w-full object-cover",onError:u=>{const y=u.target;y.src="https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?q=80&w=800&auto=format&fit=crop"}}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{className:"h-24 w-24 text-muted-foreground/30"})}),e.jsx(Le,{className:"absolute left-4 top-4",children:t.category})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground md:text-4xl",children:t.name}),e.jsxs("div",{className:"mt-4 flex items-center gap-4",children:[e.jsxs("span",{className:"text-3xl font-bold text-foreground",children:["£",t.price.toFixed(2)]}),t.carbon_offset_kg&&e.jsxs(Le,{variant:"secondary",className:"bg-primary/10 text-primary",children:[e.jsx(ft,{className:"mr-1 h-3 w-3"}),"-",t.carbon_offset_kg,"kg CO₂"]})]}),t.description&&e.jsx("p",{className:"mt-6 text-muted-foreground leading-relaxed",children:t.description}),e.jsxs("div",{className:"mt-6 space-y-3",children:[t.source_location&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(rs,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:["Crafted in ",t.source_location]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(wr,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Made from 100% recycled UK textiles"})]})]}),e.jsxs("div",{className:"mt-8 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:"Quantity:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"outline",size:"icon",onClick:()=>o(Math.max(1,i-1)),children:e.jsx(ed,{className:"h-4 w-4"})}),e.jsx("span",{className:"w-12 text-center font-medium",children:i}),e.jsx(R,{variant:"outline",size:"icon",onClick:()=>o(Math.min(t.stock_quantity,i+1)),children:e.jsx(fs,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.stock_quantity," in stock"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{size:"lg",className:"flex-1 gap-2",onClick:x,children:[e.jsx(As,{className:"h-5 w-5"}),"Add to Cart"]}),e.jsx(R,{size:"lg",variant:c(t.id)?"default":"outline",onClick:g,className:"gap-2",children:e.jsx(ra,{className:`h-5 w-5 ${c(t.id)?"fill-current":""}`})})]})]}),t.carbon_offset_kg&&e.jsx("div",{className:"mt-8 rounded-xl bg-primary/5 p-6 border border-primary/20",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-primary/10",children:e.jsx(ft,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Environmental Impact"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["By purchasing this product, you're preventing approximately"," ",e.jsxs("span",{className:"font-semibold text-primary",children:[t.carbon_offset_kg,"kg of CO₂"]})," ","from entering the atmosphere and supporting circular fashion."]})]})]})})]})]})]})}),e.jsx(We,{})]}):e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ft,{className:"mx-auto h-16 w-16 text-muted-foreground/30"}),e.jsx("h2",{className:"mt-4 text-xl font-semibold",children:"Product not found"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"This product may no longer be available."}),e.jsx(Oe,{to:"/shop",className:"mt-6 inline-block",children:e.jsx(R,{children:"Back to Shop"})})]})}),e.jsx(We,{})]})},Wg=()=>{const[s,t]=d.useState(null),r=[{title:"2026 Textile Traceability Report",description:"A comprehensive look at our supply chain transparency from UK collection to Kenya and Africa processing.",date:"January 2026",category:"Sustainability",content:`
          ## Executive Summary
          As of January 2026, Moenviron has achieved 100% blockchain-verified traceability for all textile movements between the UK and Kenya and Africa. This report details our methodology and the carbon reduction results.
          
          ## Key Findings
          - 45% reduction in logistics-related carbon emissions compared to 2024.
          - 1.2 million kg of textiles diverted from landfills in the last 12 months.
          - 300+ local jobs created in the Nairobi upcycling facility.
          
          ## Future Outlook
          We are expanding our collection points across Northern Europe by Q3 2026.
        `},{title:"Nairobi Processing: A Circular Case Study",description:"Exploring the socio-economic impact of our artisanal upcycling facility in the heart of Kenya and Africa.",date:"January 2026",category:"Impact",content:`
          ## The Nairobi Model
          Our facility in Nairobi serves as a blueprint for localized circular economies. By combining high-tech sorting with traditional artisanal repair, we create high-value fashion from perceived waste.
          
          ## Socio-Economic Impact
          - Average artisan wage is 60% above the regional living wage.
          - On-site daycare and education programs for 150 families.
          - Zero-waste production: All offcuts are repurposed into industrial stuffing or paper.
        `},{title:"The UK-Kenya and Africa Fashion Bridge 2026",description:"Policy recommendations for cross-border circular economies in the textile sector.",date:"January 2026",category:"Policy",content:`
          ## Policy Framework
          This paper outlines the necessary regulatory shifts to support circular trade. We advocate for "Green Lanes" in international shipping for certified upcycled goods.
          
          ## Recommendations
          1. Removal of import duties on textile waste destined for verified upcycling.
          2. Standardized carbon labeling across the Commonwealth.
          3. Tax incentives for brands participating in verified "Take-Back" programs.
        `}];return e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"About Us",description:"Learn about Moenviron's mission to transform fashion's relationship with waste through our UK-Kenya circular economy partnership."}),e.jsx(Ve,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx("section",{className:"gradient-hero py-12 md:py-24",children:e.jsx("div",{className:"container px-4 md:px-6",children:e.jsxs("div",{className:"mx-auto max-w-3xl text-center",children:[e.jsx("h1",{className:"font-display text-3xl font-bold text-foreground md:text-5xl",children:"About Moenviron"}),e.jsx("p",{className:"mt-3 md:mt-4 text-base md:text-lg text-muted-foreground px-4",children:"We're on a mission to transform fashion's relationship with waste, creating a circular economy that benefits people and planet."})]})})}),e.jsx("section",{className:"py-10 md:py-16",children:e.jsx("div",{className:"container px-4 md:px-6",children:e.jsxs("div",{className:"grid gap-8 md:gap-12 lg:grid-cols-2 lg:items-center",children:[e.jsxs("div",{className:"animate-fade-in order-2 lg:order-1",children:[e.jsx("h2",{className:"font-display text-2xl md:text-3xl font-bold text-foreground",children:"Our Mission"}),e.jsx("p",{className:"mt-3 md:mt-4 text-sm md:text-base text-muted-foreground leading-relaxed",children:"Every year, millions of tonnes of textiles end up in landfills across the UK. At Moenviron, we see this waste as an opportunity. We collect discarded textiles, ship them to our facility in Kenya, where skilled artisans sort, repair, and transform them into premium sustainable fashion."}),e.jsx("p",{className:"mt-3 md:mt-4 text-sm md:text-base text-muted-foreground leading-relaxed",children:"Our UK-Kenya partnership creates jobs, reduces environmental impact, and proves that circular fashion can be both ethical and profitable."})]}),e.jsxs("div",{className:"relative aspect-[4/3] md:aspect-[4/5] overflow-hidden rounded-xl md:rounded-2xl bg-muted shadow-xl md:shadow-2xl animate-fade-in-up order-1 lg:order-2",children:[e.jsx("img",{src:"https://images.unsplash.com/photo-1539109136881-3be0616acf4b?q=80&w=1000&auto=format&fit=crop",alt:"Sustainable fashion mission",className:"h-full w-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/40 to-transparent"})]})]})})}),e.jsx("section",{className:"bg-secondary/30 py-10 md:py-16",children:e.jsx("div",{className:"container px-4 md:px-6",children:e.jsx("div",{className:"mx-auto max-w-4xl",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-6 md:gap-8 items-center",children:[e.jsx("div",{className:"w-32 h-32 md:w-56 md:h-56 flex-shrink-0 rounded-xl md:rounded-2xl overflow-hidden border-2 md:border-4 border-white shadow-xl md:shadow-2xl rotate-3 transition-transform hover:rotate-0",children:e.jsx("img",{src:"https://slelguoygbfzlpylpxfs.supabase.co/storage/v1/render/image/public/project-uploads/2274ce5a-a92d-4b73-b73e-99562f585de3/image-1768041036895.png?width=8000&height=8000&resize=contain",alt:"Moses Mnai - CEO",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"flex-1 text-center md:text-left",children:[e.jsx(Yh,{className:"h-8 w-8 md:h-10 md:w-10 text-primary/20 mb-3 md:mb-4 mx-auto md:mx-0"}),e.jsx("h2",{className:"font-display text-xl md:text-3xl font-bold text-foreground mb-3 md:mb-4",children:"A Note from our CEO"}),e.jsx("p",{className:"text-base md:text-xl italic text-muted-foreground mb-4 md:mb-6 leading-relaxed",children:"“At Moenviron, we believe that nurturing nature is life. Our mission is to bridge the gap between the global textile waste and Africa’s artisanal brilliance, creating a circular system that empowers communities and protects our planet.”"}),e.jsx("p",{className:"font-display text-sm md:text-lg font-semibold text-foreground",children:"— Moses Mnai, Founder & CEO"})]})]})})})}),e.jsx("section",{className:"bg-card py-10 md:py-16",children:e.jsxs("div",{className:"container px-4 md:px-6",children:[e.jsx("h2",{className:"mb-3 md:mb-4 text-center text-2xl md:text-3xl font-bold text-foreground",children:"Why Choose Us"}),e.jsx("p",{className:"mb-8 md:mb-12 text-center text-sm md:text-base text-muted-foreground max-w-2xl mx-auto",children:"Premium quality, ethically restored fashion that's built to last"}),e.jsx("div",{className:"grid gap-4 md:gap-6 grid-cols-1 md:grid-cols-3",children:[{icon:Nr,title:"Sanitized & Safe",description:"Every piece undergoes professional sanitization and quality checks before reaching you."},{icon:tp,title:"Artisan Restored",description:"Skilled Kenyan craftspeople repair and elevate each garment to premium standards."},{icon:nd,title:"Built to Last",description:"High-quality materials and expert restoration mean your pieces last longer than fast fashion."}].map(a=>{const n=a.icon;return e.jsxs("div",{className:"rounded-xl border border-border bg-background p-4 md:p-6 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 md:mb-4 flex h-12 w-12 md:h-14 md:w-14 items-center justify-center rounded-full bg-primary/10",children:e.jsx(n,{className:"h-6 w-6 md:h-7 md:w-7 text-primary"})}),e.jsx("h3",{className:"mb-2 text-base md:text-lg font-semibold text-foreground",children:a.title}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:a.description})]},a.title)})})]})}),e.jsx("section",{className:"py-10 md:py-16",children:e.jsx("div",{className:"container px-4 md:px-6",children:e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-foreground",children:"UK-Kenya Partnership"}),e.jsx("p",{className:"mt-3 md:mt-4 text-sm md:text-base text-muted-foreground",children:"Our team spans two continents, united by a shared commitment to sustainable fashion. From our London office coordinating collections to our Nairobi facility where the transformation happens, we work together to close the fashion loop."})]})})}),e.jsx("section",{id:"whitepapers",className:"bg-secondary/30 py-10 md:py-16 scroll-mt-20",children:e.jsxs("div",{className:"container px-4 md:px-6",children:[e.jsxs("div",{className:"mb-8 md:mb-12 text-center",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-foreground",children:"Whitepapers & Insights"}),e.jsx("p",{className:"mt-3 md:mt-4 text-sm md:text-base text-muted-foreground max-w-2xl mx-auto",children:"Discover our deep dives into circular economy, textile traceability, and the socio-economic impact of sustainable fashion in East Africa."})]}),e.jsx("div",{className:"grid gap-4 md:gap-8 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:r.map(a=>e.jsxs("div",{className:"group relative flex flex-col rounded-xl md:rounded-2xl border border-border bg-background p-4 md:p-6 transition-all hover:shadow-lg",children:[e.jsx("div",{className:"mb-3 md:mb-4 flex h-10 w-10 md:h-12 md:w-12 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e.jsx(bo,{className:"h-5 w-5 md:h-6 md:w-6"})}),e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-[10px] md:text-xs font-medium text-primary uppercase tracking-wider",children:[e.jsx(Go,{className:"h-3 w-3"}),a.category]}),e.jsx("h3",{className:"mb-2 text-lg md:text-xl font-bold text-foreground group-hover:text-primary transition-colors",children:a.title}),e.jsx("p",{className:"mb-4 md:mb-6 flex-1 text-xs md:text-sm text-muted-foreground leading-relaxed",children:a.description}),e.jsxs("div",{className:"flex items-center justify-between mt-auto",children:[e.jsx("span",{className:"text-[10px] md:text-xs text-muted-foreground",children:a.date}),e.jsxs("button",{onClick:()=>t(a),className:"flex items-center gap-1.5 md:gap-2 text-xs md:text-sm font-semibold text-primary hover:underline",children:["Read Paper",e.jsx(hs,{className:"h-3.5 w-3.5 md:h-4 md:w-4"})]})]})]},a.title))}),e.jsx(Ms,{open:!!s,onOpenChange:()=>t(null),children:e.jsxs(gs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto mx-4",children:[e.jsxs(Is,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-primary uppercase tracking-wider mb-2",children:[e.jsx(Go,{className:"h-3 w-3"}),s==null?void 0:s.category]}),e.jsx(Os,{className:"font-display text-xl md:text-2xl lg:text-3xl",children:s==null?void 0:s.title}),e.jsxs(Ya,{className:"text-muted-foreground italic text-sm",children:["Published ",s==null?void 0:s.date]})]}),e.jsx("div",{className:"mt-4 md:mt-6 prose prose-slate max-w-none",children:s==null?void 0:s.content.split(`
`).map((a,n)=>a.trim().startsWith("##")?e.jsx("h3",{className:"text-lg md:text-xl font-bold mt-4 md:mt-6 mb-2 md:mb-3 text-foreground",children:a.replace("##","").trim()},n):a.trim().startsWith("-")?e.jsx("li",{className:"ml-4 mb-1 text-sm text-muted-foreground",children:a.replace("-","").trim()},n):a.trim().length>0?e.jsx("p",{className:"mb-3 md:mb-4 text-sm text-muted-foreground leading-relaxed",children:a.trim()},n):null)}),e.jsx("div",{className:"mt-6 md:mt-8 pt-4 md:pt-6 border-t flex justify-end",children:e.jsx(R,{onClick:()=>t(null),size:"sm",children:"Close Reader"})})]})}),e.jsx("div",{className:"mt-10 md:mt-16 rounded-xl md:rounded-2xl bg-primary p-6 md:p-8 lg:p-12 text-white",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-6 md:gap-8 items-center",children:[e.jsxs("div",{className:"text-center md:text-left",children:[e.jsx("h3",{className:"text-xl md:text-2xl font-bold mb-3 md:mb-4",children:"Informed by Global Standards"}),e.jsx("p",{className:"text-sm md:text-base text-primary-foreground/90 mb-4 md:mb-6",children:"Our research and methodology are aligned with industry leaders like the Ellen MacArthur Foundation and the Global Fashion Agenda."}),e.jsxs("div",{className:"flex flex-wrap gap-2 md:gap-4 justify-center md:justify-start",children:[e.jsxs("a",{href:"https://www.ellenmacarthurfoundation.org/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 md:gap-2 rounded-lg bg-white/10 px-3 py-1.5 md:px-4 md:py-2 text-xs md:text-sm font-medium hover:bg-white/20 transition-colors",children:["Ellen MacArthur",e.jsx(hs,{className:"h-3 w-3 md:h-4 md:w-4"})]}),e.jsxs("a",{href:"https://globalfashionagenda.org/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 md:gap-2 rounded-lg bg-white/10 px-3 py-1.5 md:px-4 md:py-2 text-xs md:text-sm font-medium hover:bg-white/20 transition-colors",children:["Global Fashion Agenda",e.jsx(hs,{className:"h-3 w-3 md:h-4 md:w-4"})]})]})]}),e.jsx("div",{className:"hidden md:flex justify-end",children:e.jsx(xa,{className:"h-24 w-24 lg:h-32 lg:w-32 text-white/20"})})]})})]})})]}),e.jsx(We,{})]})},X=d.forwardRef(({className:s,...t},r)=>e.jsx("div",{ref:r,className:me("rounded-lg border bg-card text-card-foreground shadow-sm",s),...t}));X.displayName="Card";const ye=d.forwardRef(({className:s,...t},r)=>e.jsx("div",{ref:r,className:me("flex flex-col space-y-1.5 p-6",s),...t}));ye.displayName="CardHeader";const be=d.forwardRef(({className:s,...t},r)=>e.jsx("h3",{ref:r,className:me("text-2xl font-semibold leading-none tracking-tight",s),...t}));be.displayName="CardTitle";const Be=d.forwardRef(({className:s,...t},r)=>e.jsx("p",{ref:r,className:me("text-sm text-muted-foreground",s),...t}));Be.displayName="CardDescription";const ee=d.forwardRef(({className:s,...t},r)=>e.jsx("div",{ref:r,className:me("p-6 pt-0",s),...t}));ee.displayName="CardContent";const Kg=d.forwardRef(({className:s,...t},r)=>e.jsx("div",{ref:r,className:me("flex items-center p-6 pt-0",s),...t}));Kg.displayName="CardFooter";const Pt=d.forwardRef(({className:s,...t},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:me("w-full caption-bottom text-sm",s),...t})}));Pt.displayName="Table";const At=d.forwardRef(({className:s,...t},r)=>e.jsx("thead",{ref:r,className:me("[&_tr]:border-b",s),...t}));At.displayName="TableHeader";const Rt=d.forwardRef(({className:s,...t},r)=>e.jsx("tbody",{ref:r,className:me("[&_tr:last-child]:border-0",s),...t}));Rt.displayName="TableBody";const Gg=d.forwardRef(({className:s,...t},r)=>e.jsx("tfoot",{ref:r,className:me("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...t}));Gg.displayName="TableFooter";const Qe=d.forwardRef(({className:s,...t},r)=>e.jsx("tr",{ref:r,className:me("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",s),...t}));Qe.displayName="TableRow";const ae=d.forwardRef(({className:s,...t},r)=>e.jsx("th",{ref:r,className:me("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t}));ae.displayName="TableHead";const se=d.forwardRef(({className:s,...t},r)=>e.jsx("td",{ref:r,className:me("p-4 align-middle [&:has([role=checkbox])]:pr-0",s),...t}));se.displayName="TableCell";const Yg=d.forwardRef(({className:s,...t},r)=>e.jsx("caption",{ref:r,className:me("mt-4 text-sm text-muted-foreground",s),...t}));Yg.displayName="TableCaption";const Qg=()=>{const s=[{url:"https://images.unsplash.com/photo-1591195853828-11db59a44f6b?auto=format&fit=crop&q=100&w=1200",caption:"Material Recovery",description:"Post-consumer textile collection at UK consolidation points.",tag:"Logistics / UK"},{url:"https://images.unsplash.com/photo-1586528116311-ad8dd3c8310d?auto=format&fit=crop&q=100&w=800",caption:"Traceable Logistics",description:"Automated batch sorting for international transit efficiency.",tag:"Process / Transit"},{url:"https://images.unsplash.com/photo-1565891741441-64926e441838?auto=format&fit=crop&q=100&w=800",caption:"Facility Ingestion",description:"Arrival at Nairobi Hub 01 for circular processing.",tag:"Operations / KE"},{url:"https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&q=100&w=800",caption:"Quality Verification",description:"Institutional-grade inspection for circular feedstocks.",tag:"Compliance / QA"}];return e.jsx("section",{className:"py-32 bg-white border-b border-black/5",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-20",children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-[0.3em] text-forest font-bold mb-6",children:"Process Documentation"}),e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start gap-12",children:[e.jsx("h2",{className:"font-display text-4xl font-medium tracking-tight text-foreground max-w-xl",children:"Visual Archive of the Circular Supply Chain"}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-md leading-relaxed",children:"Every step in our loop is documented and verified. This archive provides a technical window into the physical transformation of textiles."})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-px bg-black/5 border border-black/5",children:s.map((t,r)=>e.jsxs("div",{className:"bg-white p-6 group transition-colors hover:bg-black/[0.01]",children:[e.jsx("div",{className:"aspect-[4/5] overflow-hidden mb-8 bg-[#F5F5F5]",children:e.jsx("img",{src:t.url,alt:t.caption,loading:"lazy",className:"h-full w-full object-cover transition-transform duration-700 group-hover:scale-105"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-widest text-muted-foreground",children:t.tag}),e.jsx("h3",{className:"text-xl font-medium text-foreground tracking-tight",children:t.caption}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.description})]})]},r))}),e.jsx("div",{className:"mt-16 flex justify-center",children:e.jsxs("div",{className:"inline-flex items-center gap-4 px-6 py-3 border border-black/5 font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:[e.jsx("span",{children:"● Visual Log v4.2"}),e.jsx("span",{className:"h-4 w-px bg-black/5"}),e.jsx("span",{children:"Total Frames: 1,240"})]})})]})})},ui={tonnes_recycled:{icon:wr,label:"Textiles Recycled",color:"hsl(150 40% 35%)",description:"Amount of textile waste diverted from landfills and processed through our circular systems."},carbon_offset:{icon:Yc,label:"Carbon Prevented",color:"hsl(200 60% 45%)",description:"Greenhouse gas emissions avoided by replacing virgin materials with recycled textiles."},water_saved:{icon:Jc,label:"Water Saved",color:"hsl(220 70% 55%)",description:"Total water volume conserved compared to traditional textile production methods."},jobs_created:{icon:rr,label:"Jobs Created",color:"hsl(25 45% 45%)",description:"Sustainable employment opportunities established within our Kenyan processing facility."}},Zg=[{id:"1",metric_name:"tonnes_recycled",metric_value:2.1,unit:"tonnes",recorded_at:"2024-01-15",batch_id:"BATCH-001",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"recycling"},{id:"2",metric_name:"tonnes_recycled",metric_value:4.8,unit:"tonnes",recorded_at:"2024-02-15",batch_id:"BATCH-002",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"recycling"},{id:"3",metric_name:"tonnes_recycled",metric_value:6.2,unit:"tonnes",recorded_at:"2024-03-15",batch_id:"BATCH-003",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"recycling"},{id:"4",metric_name:"tonnes_recycled",metric_value:8.9,unit:"tonnes",recorded_at:"2024-04-15",batch_id:"BATCH-004",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"recycling"},{id:"5",metric_name:"tonnes_recycled",metric_value:10.5,unit:"tonnes",recorded_at:"2024-05-15",batch_id:"BATCH-005",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"recycling"},{id:"6",metric_name:"tonnes_recycled",metric_value:12.5,unit:"tonnes",recorded_at:"2024-06-15",batch_id:"BATCH-006",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"recycling"},{id:"7",metric_name:"carbon_offset",metric_value:1200,unit:"kg CO2",recorded_at:"2024-01-15",batch_id:"BATCH-001",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"emissions"},{id:"8",metric_name:"carbon_offset",metric_value:2800,unit:"kg CO2",recorded_at:"2024-02-15",batch_id:"BATCH-002",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"emissions"},{id:"9",metric_name:"carbon_offset",metric_value:4100,unit:"kg CO2",recorded_at:"2024-03-15",batch_id:"BATCH-003",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"emissions"},{id:"10",metric_name:"carbon_offset",metric_value:5600,unit:"kg CO2",recorded_at:"2024-04-15",batch_id:"BATCH-004",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"emissions"},{id:"11",metric_name:"carbon_offset",metric_value:7200,unit:"kg CO2",recorded_at:"2024-05-15",batch_id:"BATCH-005",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"emissions"},{id:"12",metric_name:"carbon_offset",metric_value:8450,unit:"kg CO2",recorded_at:"2024-06-15",batch_id:"BATCH-006",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"emissions"},{id:"13",metric_name:"water_saved",metric_value:8e3,unit:"litres",recorded_at:"2024-01-15",batch_id:"BATCH-001",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"water"},{id:"14",metric_name:"water_saved",metric_value:15e3,unit:"litres",recorded_at:"2024-02-15",batch_id:"BATCH-002",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"water"},{id:"15",metric_name:"water_saved",metric_value:22e3,unit:"litres",recorded_at:"2024-03-15",batch_id:"BATCH-003",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"water"},{id:"16",metric_name:"water_saved",metric_value:3e4,unit:"litres",recorded_at:"2024-04-15",batch_id:"BATCH-004",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"water"},{id:"17",metric_name:"water_saved",metric_value:38e3,unit:"litres",recorded_at:"2024-05-15",batch_id:"BATCH-005",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"water"},{id:"18",metric_name:"water_saved",metric_value:45e3,unit:"litres",recorded_at:"2024-06-15",batch_id:"BATCH-006",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"water"},{id:"19",metric_name:"jobs_created",metric_value:12,unit:"people",recorded_at:"2024-01-15",batch_id:"BATCH-001",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"social"},{id:"20",metric_name:"jobs_created",metric_value:18,unit:"people",recorded_at:"2024-02-15",batch_id:"BATCH-002",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"social"},{id:"21",metric_name:"jobs_created",metric_value:25,unit:"people",recorded_at:"2024-03-15",batch_id:"BATCH-003",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"social"},{id:"22",metric_name:"jobs_created",metric_value:32,unit:"people",recorded_at:"2024-04-15",batch_id:"BATCH-004",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"social"},{id:"23",metric_name:"jobs_created",metric_value:40,unit:"people",recorded_at:"2024-05-15",batch_id:"BATCH-005",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"social"},{id:"24",metric_name:"jobs_created",metric_value:45,unit:"people",recorded_at:"2024-06-15",batch_id:"BATCH-006",traceability_link:"#",facility_location:"Nairobi_Hub_01",category:"social"}],Jg=()=>{const[s,t]=d.useState(Zg),[r,a]=d.useState(!1),[n,i]=d.useState("tonnes_recycled"),{data:o,isLoading:l}=as("impact","header");d.useEffect(()=>{async function u(){const{data:y,error:h}=await M.from("impact_metrics").select("id, metric_name, metric_value, unit, recorded_at, notes").order("recorded_at",{ascending:!0});if(!h&&y&&y.length>0){const f=y.map(b=>({...b,batch_id:null,traceability_link:null,facility_location:null,category:null}));t(f)}a(!1)}u()},[]);const c=(o==null?void 0:o.content)||{},m={headline:c.headline||"Impact <span class='text-forest italic font-serif'>Redefined</span>",subheadline:c.subheadline||"Independent verification of our circular infrastructure across the UK-Kenya textile loop."},p=Object.entries(s.reduce((u,y)=>((!u[y.metric_name]||new Date(y.recorded_at)>new Date(u[y.metric_name].recorded_at))&&(u[y.metric_name]=y),u),{})).map(([,u])=>u),x=s.filter(u=>u.metric_name===n),g=s.filter(u=>u.batch_id).sort((u,y)=>new Date(y.recorded_at).getTime()-new Date(u.recorded_at).getTime());return e.jsxs("div",{className:"flex min-h-screen flex-col bg-background selection:bg-forest/20",children:[e.jsx(Ut,{title:"Environmental Impact",description:"Track our verified environmental impact: tonnes of textiles recycled, carbon offset, water saved, and jobs created through our UK-Kenya circular fashion loop."}),e.jsx(Ve,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx("section",{className:"pt-32 pb-16 md:pt-40 border-b border-black/5",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-end gap-8",children:[e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-forest animate-pulse"}),e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-[0.3em] text-muted-foreground",children:"Archive / Environmental ROI / v2.1.0"})]}),e.jsx("h1",{className:"font-display text-5xl md:text-7xl font-medium tracking-tight text-foreground leading-[1.1]",dangerouslySetInnerHTML:{__html:m.headline}}),e.jsx("p",{className:"mt-8 text-xl text-muted-foreground max-w-xl leading-relaxed",children:m.subheadline})]}),e.jsxs("div",{className:"flex flex-col items-end text-right font-mono text-[11px] leading-relaxed uppercase tracking-wider text-muted-foreground border-l border-black/5 pl-8 hidden md:flex",children:[e.jsxs("div",{className:"mb-4 text-forest font-bold flex items-center gap-2",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-forest"}),"System Status: Active"]}),e.jsx("p",{children:"Node: Nairobi Hub 01"}),e.jsx("p",{children:"Schema: L3-Trace-Verified"}),e.jsxs("p",{children:["Last Sync: ",new Date().toLocaleDateString("en-GB")," ",new Date().toLocaleTimeString("en-GB")]})]})]})})}),e.jsx("section",{className:"py-0 border-b border-black/5 overflow-x-auto no-scrollbar",children:e.jsx("div",{className:"container flex divide-x divide-black/5",children:p.length>0?p.map(u=>{const y=ui[u.metric_name];if(!y)return null;const h=n===u.metric_name;return e.jsxs("button",{onClick:()=>i(u.metric_name),className:`flex-1 py-12 px-8 min-w-[200px] text-left transition-all group relative ${h?"bg-forest/5":"hover:bg-black/[0.02]"}`,children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-3",children:y.label}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-4xl font-mono font-medium tracking-tighter",children:Number(u.metric_value).toLocaleString()}),e.jsx("span",{className:"text-[10px] font-mono text-muted-foreground uppercase",children:u.unit})]}),h&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-1 bg-forest"})]},u.metric_name)}):[1,2,3,4].map(u=>e.jsxs("div",{className:"flex-1 py-12 px-8 animate-pulse border-r border-black/5",children:[e.jsx("div",{className:"h-3 w-20 bg-muted mb-4"}),e.jsx("div",{className:"h-8 w-32 bg-muted"})]},u))})}),e.jsx("section",{id:"traceability",className:"py-24 bg-[#FAFAFA]",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-sm font-mono uppercase tracking-[0.3em] text-forest font-bold mb-4",children:"Verification Ledger"}),e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start gap-6",children:[e.jsx("p",{className:"text-2xl text-foreground font-medium max-w-2xl leading-snug",children:"Real-time processing logs from our UK and Kenyan facilities. Every data point is cross-verified for EPR compliance."}),e.jsx(Le,{variant:"outline",className:"rounded-none border-black/10 px-4 py-2 text-[10px] font-mono uppercase tracking-widest",children:"ISO-14001 Standards"})]})]}),e.jsx("div",{className:"border border-black/5 bg-white shadow-sm overflow-hidden",children:e.jsxs(Pt,{children:[e.jsx(At,{className:"bg-black/[0.02] border-b border-black/5",children:e.jsxs(Qe,{className:"hover:bg-transparent",children:[e.jsx(ae,{className:"font-mono text-[10px] uppercase tracking-widest py-4",children:"Batch Reference"}),e.jsx(ae,{className:"font-mono text-[10px] uppercase tracking-widest",children:"Facility"}),e.jsx(ae,{className:"font-mono text-[10px] uppercase tracking-widest",children:"Parameter"}),e.jsx(ae,{className:"font-mono text-[10px] uppercase tracking-widest",children:"Value"}),e.jsx(ae,{className:"font-mono text-[10px] uppercase tracking-widest",children:"Status"}),e.jsx(ae,{className:"font-mono text-[10px] uppercase tracking-widest text-right",children:"Certificate"})]})}),e.jsx(Rt,{children:g.length>0?g.map(u=>e.jsxs(Qe,{className:"hover:bg-black/[0.01] border-b border-black/5 last:border-0 transition-colors",children:[e.jsxs(se,{className:"font-mono text-[11px] font-bold text-forest py-5",children:["#",u.batch_id]}),e.jsx(se,{className:"font-mono text-[11px] text-muted-foreground uppercase",children:u.facility_location||"Nairobi_Hub_01"}),e.jsx(se,{className:"text-[13px] font-medium uppercase tracking-tight",children:u.metric_name.replace("_"," ")}),e.jsxs(se,{className:"font-mono text-[13px] font-medium",children:[u.metric_value," ",u.unit]}),e.jsx(se,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-forest"}),e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-widest text-forest font-bold",children:"Verified"})]})}),e.jsx(se,{className:"text-right",children:e.jsx("a",{href:u.traceability_link||"#",target:"_blank",className:"inline-flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-widest text-muted-foreground hover:text-forest transition-colors underline underline-offset-4",children:"Access Data"})})]},u.id)):e.jsx(Qe,{children:e.jsx(se,{colSpan:6,className:"h-32 text-center text-muted-foreground font-mono text-[11px] uppercase tracking-widest",children:"Awaiting data ingestion..."})})})]})})]})}),e.jsx(Qg,{}),e.jsx("section",{className:"py-32 bg-white",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-20 grid md:grid-cols-2 gap-12 items-end",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-mono uppercase tracking-[0.3em] text-forest font-bold mb-4",children:"Historical Performance"}),e.jsx("p",{className:"text-4xl font-medium tracking-tight text-foreground",children:"Performance Trends"}),e.jsx("p",{className:"mt-6 text-lg text-muted-foreground leading-relaxed",children:"Longitudinal data analysis of our circular infrastructure. Metrics are tracked monthly to monitor growth in recovery efficiency and carbon mitigation."})]}),e.jsx("div",{className:"flex flex-wrap gap-2 md:justify-end",children:Object.entries(ui).map(([u,y])=>e.jsx("button",{onClick:()=>i(u),className:`px-6 py-2 text-[10px] font-mono uppercase tracking-widest border transition-all ${n===u?"bg-black text-white border-black":"bg-transparent text-muted-foreground border-black/10 hover:border-black/30"}`,children:y.label},u))})]}),e.jsx("div",{className:"h-[500px] w-full border border-black/5 p-8 md:p-12",children:e.jsx(mn,{width:"100%",height:"100%",children:e.jsxs(gi,{data:x,children:[e.jsx(yi,{strokeDasharray:"4 4",vertical:!1,stroke:"rgba(0,0,0,0.05)"}),e.jsx(bi,{dataKey:"recorded_at",axisLine:!1,tickLine:!1,tickFormatter:u=>new Date(u).toLocaleDateString("en-GB",{month:"short",year:"2-digit"}),stroke:"#999",fontSize:10,fontFamily:"monospace",dy:20}),e.jsx(vi,{axisLine:!1,tickLine:!1,stroke:"#999",fontSize:10,fontFamily:"monospace",dx:-20}),e.jsx(hn,{content:({active:u,payload:y,label:h})=>u&&y&&y.length?e.jsxs("div",{className:"border border-black bg-white p-4 shadow-xl",children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-2",children:new Date(h).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}),e.jsxs("p",{className:"text-xl font-mono font-bold text-black",children:[Number(y[0].value).toLocaleString(),e.jsx("span",{className:"ml-2 text-[10px] text-muted-foreground",children:y[0].payload.unit})]})]}):null}),e.jsx(ji,{type:"monotone",dataKey:"metric_value",stroke:"#1A3C34",strokeWidth:2,fill:"#1A3C34",fillOpacity:.05,animationDuration:2e3,animationEasing:"ease-in-out",animationBegin:0})]})})})]})}),e.jsx("section",{className:"py-32 bg-[#FAFAFA] border-t border-black/5",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-sm font-mono uppercase tracking-[0.3em] text-forest font-bold mb-4",children:"Cumulative Impact"}),e.jsx("p",{className:"text-4xl font-medium tracking-tight text-foreground",children:"Environmental Progress Overview"}),e.jsx("p",{className:"mt-6 text-lg text-muted-foreground leading-relaxed max-w-2xl",children:"A comprehensive view of all key impact metrics over time, demonstrating our growing contribution to sustainable textile management."})]}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:Object.entries(ui).map(([u,y])=>{const h=s.filter(j=>j.metric_name===u),f=h.length>0?h[h.length-1].metric_value:0,b=h.length>0?h[h.length-1].unit:"",v=y.icon;return e.jsxs(X,{className:"border border-black/5 bg-white shadow-sm",children:[e.jsx(ye,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-forest/10",children:e.jsx(v,{className:"h-5 w-5 text-forest"})}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-mono uppercase tracking-widest",children:y.label}),e.jsx(Be,{className:"text-xs mt-1",children:y.description})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-2xl font-mono font-bold text-forest",children:Number(f).toLocaleString()}),e.jsx("p",{className:"text-[10px] font-mono text-muted-foreground uppercase",children:b})]})]})}),e.jsx(ee,{className:"pt-4",children:e.jsx("div",{className:"h-[150px] w-full",children:e.jsx(mn,{width:"100%",height:"100%",children:e.jsxs(gi,{data:h,children:[e.jsx(yi,{strokeDasharray:"4 4",vertical:!1,stroke:"rgba(0,0,0,0.05)"}),e.jsx(bi,{dataKey:"recorded_at",axisLine:!1,tickLine:!1,tickFormatter:j=>new Date(j).toLocaleDateString("en-GB",{month:"short"}),stroke:"#999",fontSize:9,fontFamily:"monospace"}),e.jsx(vi,{hide:!0}),e.jsx(hn,{content:({active:j,payload:_,label:I})=>j&&_&&_.length?e.jsxs("div",{className:"border border-black bg-white p-3 shadow-lg text-xs",children:[e.jsx("p",{className:"font-mono text-muted-foreground mb-1",children:new Date(I).toLocaleDateString("en-GB",{month:"short",year:"numeric"})}),e.jsxs("p",{className:"font-mono font-bold",children:[Number(_[0].value).toLocaleString()," ",_[0].payload.unit]})]}):null}),e.jsx(ji,{type:"monotone",dataKey:"metric_value",stroke:y.color,strokeWidth:2,fill:y.color,fillOpacity:.1,animationDuration:1500})]})})})})]},u)})})]})})]}),e.jsx(We,{})]})};function Xg(){const s=`
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Moenviron Impact Report 2025</title>
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
    
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      color: #1a1a1a;
      line-height: 1.6;
      background: #fff;
    }
    
    .page {
      width: 210mm;
      min-height: 297mm;
      padding: 20mm;
      margin: 0 auto;
      background: #fff;
    }
    
    .cover {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      min-height: calc(297mm - 40mm);
      background: linear-gradient(135deg, #2D5A43 0%, #1a3a2a 100%);
      color: white;
      padding: 40mm 30mm;
      margin: -20mm;
      margin-bottom: 20mm;
    }
    
    .cover-header {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 4px;
      opacity: 0.7;
    }
    
    .cover-title {
      font-size: 48px;
      font-weight: 700;
      line-height: 1.1;
      margin: 40px 0;
    }
    
    .cover-subtitle {
      font-size: 20px;
      font-weight: 300;
      opacity: 0.9;
      max-width: 400px;
    }
    
    .cover-footer {
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      margin-top: auto;
    }
    
    .cover-logo {
      font-size: 24px;
      font-weight: 700;
    }
    
    .cover-date {
      font-size: 14px;
      opacity: 0.7;
    }
    
    h1 {
      font-size: 28px;
      font-weight: 700;
      margin-bottom: 20px;
      color: #2D5A43;
    }
    
    h2 {
      font-size: 20px;
      font-weight: 600;
      margin: 30px 0 15px;
      color: #1a1a1a;
      border-bottom: 2px solid #2D5A43;
      padding-bottom: 8px;
    }
    
    h3 {
      font-size: 16px;
      font-weight: 600;
      margin: 20px 0 10px;
      color: #2D5A43;
    }
    
    p {
      margin-bottom: 12px;
      color: #444;
    }
    
    .intro {
      font-size: 18px;
      color: #666;
      margin-bottom: 30px;
      padding: 20px;
      background: #f9f7f2;
      border-left: 4px solid #2D5A43;
    }
    
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 20px;
      margin: 30px 0;
    }
    
    .stat-card {
      background: linear-gradient(135deg, #f9f7f2 0%, #fff 100%);
      padding: 25px;
      border-radius: 12px;
      text-align: center;
      border: 1px solid #e5e5e5;
    }
    
    .stat-value {
      font-size: 36px;
      font-weight: 700;
      color: #2D5A43;
      display: block;
    }
    
    .stat-label {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: #888;
      margin-top: 8px;
    }
    
    .section {
      margin: 40px 0;
    }
    
    .highlight-box {
      background: #2D5A43;
      color: white;
      padding: 30px;
      border-radius: 12px;
      margin: 30px 0;
    }
    
    .highlight-box h3 {
      color: white;
      margin-top: 0;
    }
    
    .highlight-box p {
      color: rgba(255,255,255,0.9);
    }
    
    .timeline {
      position: relative;
      padding-left: 30px;
      margin: 20px 0;
    }
    
    .timeline::before {
      content: '';
      position: absolute;
      left: 8px;
      top: 0;
      bottom: 0;
      width: 2px;
      background: #2D5A43;
    }
    
    .timeline-item {
      position: relative;
      margin-bottom: 25px;
      padding-left: 20px;
    }
    
    .timeline-item::before {
      content: '';
      position: absolute;
      left: -26px;
      top: 6px;
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background: #2D5A43;
    }
    
    .timeline-date {
      font-size: 12px;
      color: #2D5A43;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 1px;
    }
    
    .table {
      width: 100%;
      border-collapse: collapse;
      margin: 20px 0;
    }
    
    .table th, .table td {
      padding: 12px 15px;
      text-align: left;
      border-bottom: 1px solid #e5e5e5;
    }
    
    .table th {
      background: #f9f7f2;
      font-weight: 600;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: #666;
    }
    
    .table td {
      font-size: 14px;
    }
    
    .pillars {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 20px;
      margin: 30px 0;
    }
    
    .pillar {
      padding: 25px;
      border-radius: 12px;
      text-align: center;
    }
    
    .pillar.eliminate {
      background: #E3F2FD;
      border: 2px solid #2196F3;
    }
    
    .pillar.circulate {
      background: #E8F5E9;
      border: 2px solid #2D5A43;
    }
    
    .pillar.regenerate {
      background: #FFF8E1;
      border: 2px solid #FFA000;
    }
    
    .pillar-title {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 10px;
    }
    
    .pillar-desc {
      font-size: 13px;
      color: #666;
    }
    
    .footer {
      margin-top: 50px;
      padding-top: 20px;
      border-top: 1px solid #e5e5e5;
      font-size: 12px;
      color: #888;
      text-align: center;
    }
    
    .page-break {
      page-break-after: always;
    }
    
    @media print {
      body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }
      
      .page {
        margin: 0;
        padding: 15mm;
      }
      
      .cover {
        margin: -15mm;
        padding: 30mm 25mm;
      }
    }
  </style>
</head>
<body>
  <div class="page">
    <div class="cover">
      <div>
        <div class="cover-header">Annual Impact Report</div>
        <h1 class="cover-title">Moenviron<br/>Impact Report<br/>2025</h1>
        <p class="cover-subtitle">Transforming textile waste into opportunity through circular fashion solutions connecting the UK and Kenya.</p>
      </div>
      <div class="cover-footer">
        <div class="cover-logo">MOENVIRON</div>
        <div class="cover-date">January 2025</div>
      </div>
    </div>
  </div>
  
  <div class="page">
    <h1>Executive Summary</h1>
    
    <p class="intro">
      In 2025, Moenviron has made significant strides in our mission to create a truly circular textile economy. This report details our environmental impact, community empowerment initiatives, and the tangible progress we've made toward eliminating textile waste.
    </p>
    
    <div class="stats-grid">
      <div class="stat-card">
        <span class="stat-value">15.4t</span>
        <span class="stat-label">Textiles Recovered</span>
      </div>
      <div class="stat-card">
        <span class="stat-value">892kg</span>
        <span class="stat-label">CO₂ Offset</span>
      </div>
      <div class="stat-card">
        <span class="stat-value">45</span>
        <span class="stat-label">Jobs Created</span>
      </div>
    </div>
    
    <h2>Our Circular Model</h2>
    
    <div class="pillars">
      <div class="pillar eliminate">
        <div class="pillar-title">Eliminate</div>
        <p class="pillar-desc">Waste and pollution by design through source interception</p>
      </div>
      <div class="pillar circulate">
        <div class="pillar-title">Circulate</div>
        <p class="pillar-desc">Products and materials at their highest value</p>
      </div>
      <div class="pillar regenerate">
        <div class="pillar-title">Regenerate</div>
        <p class="pillar-desc">Nature and local ecosystems through restoration</p>
      </div>
    </div>
    
    <p>Our three-pillar approach, inspired by the Ellen MacArthur Foundation's circular economy principles, guides every aspect of our operations. From intercepting textiles before they reach landfills to empowering Kenyan artisans with dignified employment, we're building a system that benefits both people and planet.</p>
  </div>
  
  <div class="page">
    <h2>Environmental Impact</h2>
    
    <h3>Textile Recovery</h3>
    <p>Through our multi-point collection network spanning the UK and Kenya, we've intercepted 15.4 tonnes of textiles that would otherwise end up in landfills or waterways. Our Nairobi River Recovery initiative alone has prevented over 3 tonnes of textile waste from entering the ecosystem.</p>
    
    <table class="table">
      <thead>
        <tr>
          <th>Category</th>
          <th>Volume (tonnes)</th>
          <th>% of Total</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>Cotton & Natural Fibers</td>
          <td>6.2</td>
          <td>40%</td>
        </tr>
        <tr>
          <td>Synthetic Blends</td>
          <td>4.6</td>
          <td>30%</td>
        </tr>
        <tr>
          <td>Denim</td>
          <td>3.1</td>
          <td>20%</td>
        </tr>
        <tr>
          <td>Other Materials</td>
          <td>1.5</td>
          <td>10%</td>
        </tr>
      </tbody>
    </table>
    
    <h3>Carbon Footprint Reduction</h3>
    <p>By diverting textiles from landfill and enabling their reuse and recycling, we've prevented an estimated 892kg of CO₂ equivalent emissions. This is comparable to removing 194 cars from the road for a full day.</p>
    
    <div class="highlight-box">
      <h3>Water Conservation</h3>
      <p>Our closed-loop production processes have saved approximately 45,000 liters of water compared to virgin textile manufacturing. We've achieved this through:</p>
      <ul style="margin-top: 10px; padding-left: 20px;">
        <li>Waterless dyeing techniques where possible</li>
        <li>Greywater recycling at our Nairobi hub</li>
        <li>Elimination of toxic chemical runoff</li>
      </ul>
    </div>
  </div>
  
  <div class="page">
    <h2>Social Impact</h2>
    
    <h3>Employment & Livelihoods</h3>
    <p>At the heart of our mission is creating dignified employment for Kenyan artisans. Our Kibera Production Hub has become a center of innovation and skill development.</p>
    
    <div class="stats-grid">
      <div class="stat-card">
        <span class="stat-value">45</span>
        <span class="stat-label">Direct Jobs Created</span>
      </div>
      <div class="stat-card">
        <span class="stat-value">120+</span>
        <span class="stat-label">Indirect Beneficiaries</span>
      </div>
      <div class="stat-card">
        <span class="stat-value">67%</span>
        <span class="stat-label">Women Employed</span>
      </div>
    </div>
    
    <h3>Skills Development</h3>
    <p>We've invested in comprehensive training programs that preserve traditional Kenyan weaving techniques while introducing modern sustainable fashion practices.</p>
    
    <div class="timeline">
      <div class="timeline-item">
        <div class="timeline-date">Q1 2025</div>
        <p><strong>Artisan Certification Program</strong> — 25 artisans completed our 12-week intensive program in circular design principles.</p>
      </div>
      <div class="timeline-item">
        <div class="timeline-date">Q2 2025</div>
        <p><strong>Digital Skills Workshop</strong> — Introduction of product photography and e-commerce training for artisan entrepreneurs.</p>
      </div>
      <div class="timeline-item">
        <div class="timeline-date">Q3 2025</div>
        <p><strong>Youth Apprenticeship</strong> — Launch of 6-month apprenticeship program for 15 young people from Kibera.</p>
      </div>
    </div>
    
    <h3>Fair Wage Commitment</h3>
    <p>All Moenviron artisans receive wages that exceed the Kenyan living wage by at least 25%. We believe that sustainable fashion must also mean sustainable livelihoods for the people who create it.</p>
  </div>
  
  <div class="page">
    <h2>Traceability & Transparency</h2>
    
    <p>Every product that leaves our facility carries a complete history. Our digital passport system enables customers and partners to trace the journey of their garment from source to store.</p>
    
    <h3>Material Traceability</h3>
    <table class="table">
      <thead>
        <tr>
          <th>Tracking Point</th>
          <th>Data Captured</th>
          <th>Coverage</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>Collection Source</td>
          <td>Location, date, material type</td>
          <td>100%</td>
        </tr>
        <tr>
          <td>Sorting & Classification</td>
          <td>Material composition, quality grade</td>
          <td>100%</td>
        </tr>
        <tr>
          <td>Production</td>
          <td>Artisan ID, techniques used, hours</td>
          <td>100%</td>
        </tr>
        <tr>
          <td>Quality Assurance</td>
          <td>Inspection results, certifications</td>
          <td>100%</td>
        </tr>
      </tbody>
    </table>
    
    <h2>Looking Ahead: 2026 Goals</h2>
    
    <div class="highlight-box">
      <h3>Our Commitments for 2026</h3>
      <ul style="padding-left: 20px;">
        <li>Recover 25 tonnes of textile waste (62% increase)</li>
        <li>Create 30 additional artisan jobs</li>
        <li>Launch regenerative cotton pilot in Makueni County</li>
        <li>Achieve B Corp certification</li>
        <li>Expand brand partnerships to 15 UK retailers</li>
      </ul>
    </div>
    
    <div class="footer">
      <p><strong>Moenviron Ltd.</strong></p>
      <p>Connecting UK Fashion Waste to Kenyan Artisan Innovation</p>
      <p>www.moenviron.com | info@moenviron.com</p>
      <p style="margin-top: 15px; font-size: 10px;">© 2025 Moenviron. All rights reserved. This report contains verified impact data as of January 2025.</p>
    </div>
  </div>
</body>
</html>
  `,t=new Blob([s],{type:"text/html"}),r=URL.createObjectURL(t),a=window.open(r,"_blank");if(a)a.onload=()=>{setTimeout(()=>{a.print()},500)};else{const n=document.createElement("a");n.href=r,n.download="Moenviron-Impact-Report-2025.html",document.body.appendChild(n),n.click(),document.body.removeChild(n)}setTimeout(()=>URL.revokeObjectURL(r),1e4)}const ey=[{id:1,title:"Nairobi River Recovery",type:"image",url:"https://images.unsplash.com/photo-1530587191325-3db32d826c18?q=80&w=1200&auto=format&fit=crop",impact:"15 Tons Recovered",category:"Waste Interception",pillar:"Eliminate",description:"Intercepting textile waste before it enters the ecosystem. A critical first step in systemic circularity.",size:"large"},{id:2,title:"Artisan Empowerment Hub",type:"image",url:"https://images.unsplash.com/photo-1605000797499-95a51c5269ae?q=80&w=1200&auto=format&fit=crop",impact:"Fair Wage Certified",category:"Social Value",pillar:"Circulate",description:"Preserving traditional Kenyan weaving techniques while ensuring economic resilience for artisans.",size:"medium"},{id:3,title:"The Digital Passport",type:"image",url:"https://images.unsplash.com/photo-1518770660439-4636190af475?q=80&w=1200&auto=format&fit=crop",impact:"100% Traceable",category:"Traceability",pillar:"Circulate",description:"Implementing blockchain-backed documentation for every material recovered and repurposed.",size:"small"},{id:4,title:"Regenerative Cotton Flow",type:"image",url:"https://images.unsplash.com/photo-1523348837708-15d4a09cfac2?q=80&w=1200&auto=format&fit=crop",impact:"500 Acres",category:"Agriculture",pillar:"Regenerate",description:"Supporting Makueni County's transition to organic regenerative farming practices.",size:"medium"},{id:5,title:"Eco-System Restoration",type:"image",url:"https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?q=80&w=1200&auto=format&fit=crop",impact:"892kg CO₂ Offset",category:"Environment",pillar:"Regenerate",description:"Restoring local landscapes through community-led biodiversity initiatives.",size:"large"},{id:6,title:"Circular Design Details",type:"image",url:"https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?q=80&w=1200&auto=format&fit=crop",impact:"Design for Longevity",category:"Innovation",pillar:"Eliminate",description:"Technical exploration of mono-material construction to ensure future recyclability.",size:"small"},{id:7,title:"Kibera Production Hub",type:"image",url:"https://images.unsplash.com/photo-1441986300917-64674bd600d8?q=80&w=1200&auto=format&fit=crop",impact:"45 Jobs Created",category:"Livelihoods",pillar:"Circulate",description:"The systemic heartbeat of our local production, turning waste into high-value garments.",size:"medium"},{id:8,title:"Hydraulic Integrity",type:"image",url:"https://images.unsplash.com/photo-1439066615861-d1af74d74000?q=80&w=1200&auto=format&fit=crop",impact:"45k L Water Saved",category:"Resource Management",pillar:"Regenerate",description:"Protecting local water cycles by eliminating toxic runoff in production.",size:"small"}],ty=[{title:"Eliminate",icon:e.jsx($h,{className:"h-6 w-6"}),description:"Waste and pollution by design. We intercept textiles before they reach landfill or river systems.",accent:"text-blue-600"},{title:"Circulate",icon:e.jsx(Qh,{className:"h-6 w-6"}),description:"Products and materials at their highest value. We empower Kenyan artisans to upcycle with dignity.",accent:"text-[#2D5A43]"},{title:"Regenerate",icon:e.jsx(ft,{className:"h-6 w-6"}),description:"Nature and local ecosystems. We invest in regenerative farming and biodiversity restoration.",accent:"text-amber-600"}],sy=()=>{const[s,t]=d.useState(null),r=d.useRef(null),{toast:a}=mo(),n=()=>{var l;(l=r.current)==null||l.scrollIntoView({behavior:"smooth"})},i=l=>{a({title:`${l} Methodology`,description:"Technical documentation and impact verification reports will be available soon in our digital library."})},o=()=>{a({title:"Generating Report",description:"Your 2025 Impact & Traceability report is being prepared for download."}),Xg()};return e.jsxs("div",{className:"flex min-h-screen flex-col bg-[#F9F7F2]",children:[e.jsx(Ut,{title:"Projects & Initiatives",description:"Explore our systemic transformation initiatives bridging UK textile waste with Kenyan artisan innovation for genuine circular fashion impact."}),e.jsx(Ve,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx("section",{className:"relative pt-32 pb-24 border-b border-black/5",children:e.jsx("div",{className:"container px-6 lg:px-12",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-end",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-black/5 px-4 py-1.5 text-[10px] font-bold uppercase tracking-widest text-black/60 mb-8",children:[e.jsx(xa,{className:"h-3 w-3"}),"Impact Overview"]}),e.jsxs("h1",{className:"text-6xl md:text-8xl font-medium tracking-tight text-[#1A1A1A] font-display leading-[0.9] mb-8",children:["A Systemic ",e.jsx("br",{}),e.jsx("span",{className:"italic font-normal",children:"Transformation"})]})]}),e.jsxs("div",{className:"lg:max-w-md pb-2",children:[e.jsx("p",{className:"text-xl text-muted-foreground leading-relaxed font-light mb-8",children:'Moving beyond "sustainability" towards a circular economy that is regenerative by design. Our initiatives bridge the gap between UK waste and Kenyan artisan innovation.'}),e.jsx("div",{className:"flex items-center gap-6",children:e.jsxs(R,{variant:"link",className:"p-0 h-auto font-bold uppercase tracking-widest text-xs group",onClick:n,children:["Our Theory of Change ",e.jsx(ss,{className:"ml-2 h-4 w-4 transition-transform group-hover:translate-x-1"})]})})]})]})})}),e.jsx("section",{ref:r,className:"py-24 bg-white",children:e.jsxs("div",{className:"container px-6 lg:px-12",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-[0.3em] text-muted-foreground mb-4",children:"The Circular Model"}),e.jsx("h3",{className:"text-3xl font-display max-w-2xl",children:"Three principles driven by design to tackle our global environmental challenges."})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-12",children:ty.map(l=>e.jsxs("div",{className:"group cursor-default",children:[e.jsx("div",{className:"mb-6 p-4 rounded-2xl bg-black/[0.02] inline-block transition-colors group-hover:bg-black/[0.05]",children:l.icon}),e.jsx("h4",{className:"text-2xl font-bold mb-4 font-display",children:l.title}),e.jsx("p",{className:"text-muted-foreground leading-relaxed font-light mb-6",children:l.description}),e.jsx("div",{className:"h-1 w-0 bg-black transition-all duration-500 group-hover:w-12"})]},l.title))})]})}),e.jsx("section",{className:"py-24 bg-[#F9F7F2]",children:e.jsxs("div",{className:"container px-6 lg:px-12",children:[e.jsxs("div",{className:"mb-16 flex flex-col md:flex-row md:items-end justify-between gap-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-[0.3em] text-muted-foreground mb-4",children:"Case Studies"}),e.jsxs("h3",{className:"text-5xl font-display leading-tight",children:["Authentic ",e.jsx("br",{}),"Impact in Motion"]})]}),e.jsx("p",{className:"max-w-xs text-sm text-muted-foreground leading-relaxed italic",children:"A non-curated, raw look at the systems we are building on the ground in Nairobi and beyond."})]}),e.jsx("div",{className:"columns-1 sm:columns-2 lg:columns-3 gap-8 space-y-8",children:ey.map(l=>e.jsxs("div",{className:"relative group break-inside-avoid overflow-hidden bg-white border border-black/5 transition-all duration-700",onMouseEnter:()=>t(l.id),onMouseLeave:()=>t(null),children:[e.jsxs("div",{className:"p-5 flex justify-between items-center border-b border-black/5 bg-white",children:[e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-black/40",children:[l.pillar," — ",l.category]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-[#2D5A43]",children:[e.jsx(nd,{className:"h-3 w-3"}),l.impact]})]}),e.jsxs("div",{className:"relative overflow-hidden bg-black/[0.02]",children:[l.type==="video"?e.jsx("video",{src:l.url,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"w-full h-auto object-cover transition-all duration-700"}):e.jsx("img",{src:l.url,alt:l.title,className:"w-full h-auto object-cover transition-all duration-700",loading:"lazy"}),l.type==="video"&&e.jsx("div",{className:"absolute top-4 right-4 bg-white/10 backdrop-blur-sm p-1.5 rounded-full text-white pointer-events-none opacity-50",children:e.jsx(Gh,{className:"h-3 w-3 fill-white"})}),e.jsxs("div",{className:`absolute inset-0 bg-white/90 transition-all duration-500 p-8 flex flex-col justify-center items-center text-center ${s===l.id?"opacity-100":"opacity-0"}`,children:[e.jsx("h3",{className:"text-2xl font-bold mb-4 font-display text-[#1A1A1A]",children:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-6 font-light",children:l.description}),e.jsx(R,{variant:"outline",size:"sm",className:"rounded-none border-black/10 text-[10px] font-bold tracking-widest uppercase hover:bg-black hover:text-white px-6 h-10 transition-colors",onClick:()=>i(l.title),children:"Explore Methodology"})]})]})]},l.id))})]})}),e.jsxs("section",{className:"py-32 bg-[#1A1A1A] text-white overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none",style:{backgroundImage:"radial-gradient(circle, #ffffff 1px, transparent 1px)",backgroundSize:"40px 40px"}}),e.jsxs("div",{className:"container px-6 lg:px-12 relative z-10",children:[e.jsxs("div",{className:"max-w-3xl mb-24",children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-[0.3em] text-[#D97706] mb-6",children:"Material Sovereignty"}),e.jsxs("h3",{className:"text-5xl md:text-7xl font-display leading-[1.1] mb-8",children:["The Technical ",e.jsx("br",{}),e.jsx("span",{className:"italic font-normal",children:"Circular Loop"})]}),e.jsx("p",{className:"text-xl text-white/60 font-light leading-relaxed",children:"We've mapped every node of our ecosystem to ensure maximum resource recovery and artisan empowerment."})]}),e.jsxs("div",{className:"grid lg:grid-cols-4 gap-1 relative",children:[e.jsx("div",{className:"hidden lg:block absolute top-1/2 left-0 w-full h-px bg-white/10 -translate-y-1/2"}),[{step:"01",label:"Recovery",detail:"Multi-point textile interception at source."},{step:"02",label:"Classification",detail:"AI-assisted material sorting in Nairobi."},{step:"03",label:"Value Addition",detail:"Artisan-led upcycling and design."},{step:"04",label:"Circulation",detail:"Digital passporting for full lifecycle."}].map((l,c)=>e.jsxs("div",{className:"relative p-8 border border-white/5 bg-white/[0.02] hover:bg-white/[0.05] transition-colors group",children:[e.jsxs("div",{className:"mb-12 flex items-center justify-between",children:[e.jsx("span",{className:"text-5xl font-display font-light text-white/20 group-hover:text-[#D97706]/50 transition-colors",children:l.step}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-[#D97706]"})]}),e.jsx("h4",{className:"text-xl font-bold mb-4",children:l.label}),e.jsx("p",{className:"text-sm text-white/50 leading-relaxed font-light",children:l.detail})]},l.step))]}),e.jsxs("div",{className:"mt-24 pt-12 border-t border-white/10 flex flex-col md:flex-row justify-between items-center gap-8",children:[e.jsxs("div",{className:"flex items-center gap-12",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-bold mb-1",children:"100%"}),e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-white/40",children:"Traceable Materials"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-bold mb-1",children:"15.4t"}),e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-white/40",children:"Waste Diverted"})]})]}),e.jsx(R,{className:"bg-[#D97706] hover:bg-[#B45309] text-white rounded-none h-14 px-12 font-bold uppercase tracking-widest text-xs",onClick:o,children:"Download Impact Report"})]})]})]})]}),e.jsx(We,{})]})},ry=[{icon:yo,title:"EPR Compliance",description:"Meet Extended Producer Responsibility requirements with our verified textile recycling infrastructure. Full documentation for regulatory reporting."},{icon:_r,title:"ESG Reporting",description:"Access detailed impact metrics for your sustainability reports. Carbon data, job creation stats, and waste diversion figures on demand."},{icon:Vc,title:"Take-Back Programs",description:"Launch branded textile take-back schemes. We handle collection, processing, and can provide white-label resale options."},{icon:ho,title:"Impact Dashboard",description:"Real-time access to your partnership metrics. See exactly where your textiles go and the impact they create."}],ay=["Initial consultation to understand your sustainability goals","Custom partnership proposal with pricing and logistics","Pilot program with full impact tracking","Scale to full partnership with dedicated account management"],ny=()=>e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Partner With Us",description:"Join leading fashion brands using our UK-Kenya infrastructure for EPR compliance, ESG reporting, and genuine circular fashion impact."}),e.jsx(Ve,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx("section",{className:"bg-primary py-16 md:py-24",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"mx-auto max-w-3xl text-center text-primary-foreground",children:[e.jsx("span",{className:"mb-4 inline-block rounded-full bg-primary-foreground/10 px-4 py-2 text-sm font-medium",children:"For Brands & Retailers"}),e.jsx("h1",{className:"text-4xl font-bold md:text-5xl",children:"Partner With Moenviron"}),e.jsx("p",{className:"mt-4 text-lg opacity-90",children:"Join leading fashion brands using our UK-Kenya infrastructure for EPR compliance, ESG reporting, and genuine circular fashion impact."}),e.jsx(Oe,{to:"/contact",className:"mt-8 inline-block",children:e.jsxs(R,{size:"lg",variant:"secondary",className:"gap-2",children:["Start Conversation",e.jsx(ss,{className:"h-4 w-4"})]})})]})})}),e.jsx("section",{className:"py-16",children:e.jsxs("div",{className:"container",children:[e.jsx("h2",{className:"mb-12 text-center text-3xl font-bold text-foreground",children:"Partnership Benefits"}),e.jsx("div",{className:"grid gap-8 md:grid-cols-2",children:ry.map(s=>{const t=s.icon;return e.jsxs("div",{className:"flex gap-4 rounded-xl border border-border bg-card p-6",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(t,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-lg font-semibold text-foreground",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.description})]})]},s.title)})})]})}),e.jsx("section",{className:"bg-card py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"grid gap-12 lg:grid-cols-2 lg:items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-foreground",children:"How Partnership Works"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"From initial conversation to full-scale operation, we guide you through every step of building a genuine circular fashion program."}),e.jsx("ul",{className:"mt-8 space-y-4",children:ay.map((s,t)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Gc,{className:"mt-0.5 h-5 w-5 shrink-0 text-primary"}),e.jsx("span",{className:"text-foreground",children:s})]},t))})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-background p-8",children:[e.jsx("div",{className:"mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:e.jsx(wr,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"mb-4 text-xl font-semibold text-foreground",children:"Ready to Start?"}),e.jsx("p",{className:"mb-6 text-muted-foreground",children:"Whether you're exploring EPR compliance or ready to launch a full circular fashion program, we're here to help."}),e.jsx(Oe,{to:"/contact",children:e.jsxs(R,{className:"w-full gap-2",children:["Contact Our Team",e.jsx(ss,{className:"h-4 w-4"})]})})]})]})})}),e.jsx("section",{className:"py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Built for Enterprise Trust"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Our infrastructure runs on enterprise-grade systems. PostgreSQL database, Stripe-powered payments, and full GDPR compliance. Your brand's reputation is safe with us."})]})})})]}),e.jsx(We,{})]}),qt=d.forwardRef(({className:s,...t},r)=>e.jsx("textarea",{className:me("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));qt.displayName="Textarea";var iy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],oy=iy.reduce((s,t)=>{const r=qn(`Primitive.${t}`),a=d.forwardRef((n,i)=>{const{asChild:o,...l}=n,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...l,ref:i})});return a.displayName=`Primitive.${t}`,{...s,[t]:a}},{}),ly="Label",Kd=d.forwardRef((s,t)=>e.jsx(oy.label,{...s,ref:t,onMouseDown:r=>{var n;r.target.closest("button, input, select, textarea")||((n=s.onMouseDown)==null||n.call(s,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Kd.displayName=ly;var Gd=Kd;const cy=Wa("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),B=d.forwardRef(({className:s,...t},r)=>e.jsx(Gd,{ref:r,className:me(cy(),s),...t}));B.displayName=Gd.displayName;const dy=()=>{const[s,t]=d.useState(!1),[r,a]=d.useState({name:"",email:"",company:"",subject:"",message:""}),n=async i=>{i.preventDefault(),t(!0),await new Promise(o=>setTimeout(o,1e3)),C.success("Message sent! We'll get back to you within 24 hours."),a({name:"",email:"",company:"",subject:"",message:""}),t(!1)};return e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Contact Us",description:"Get in touch with Moenviron about our sustainable fashion products, partnership opportunities, or sustainability impact questions."}),e.jsx(Ve,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx("section",{className:"gradient-hero py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h1",{className:"text-4xl font-bold text-foreground",children:"Contact Us"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Have a question about our products, partnership opportunities, or sustainability impact? We'd love to hear from you."})]})})}),e.jsx("section",{className:"py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"grid gap-12 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-border bg-card p-8",children:[e.jsx("h2",{className:"mb-6 text-2xl font-bold text-foreground",children:"Send a Message"}),e.jsxs("form",{onSubmit:n,className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"name",children:"Full Name *"}),e.jsx(Q,{id:"name",required:!0,value:r.name,onChange:i=>a({...r,name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"email",children:"Email *"}),e.jsx(Q,{id:"email",type:"email",required:!0,value:r.email,onChange:i=>a({...r,email:i.target.value}),placeholder:"jane@company.com"})]})]}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"company",children:"Company"}),e.jsx(Q,{id:"company",value:r.company,onChange:i=>a({...r,company:i.target.value}),placeholder:"Your company"})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"subject",children:"Subject *"}),e.jsx(Q,{id:"subject",required:!0,value:r.subject,onChange:i=>a({...r,subject:i.target.value}),placeholder:"Partnership inquiry"})]})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"message",children:"Message *"}),e.jsx(qt,{id:"message",required:!0,rows:5,value:r.message,onChange:i=>a({...r,message:i.target.value}),placeholder:"Tell us how we can help..."})]}),e.jsxs(R,{type:"submit",className:"w-full gap-2",disabled:s,children:[s?"Sending...":"Send Message",e.jsx(In,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"mb-6 text-2xl font-bold text-foreground",children:"Get in Touch"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("a",{href:"mailto:info@moenviron.com",onClick:i=>{i.preventDefault(),window.location.href="mailto:info@moenviron.com"},className:"flex items-start gap-4 rounded-lg border border-border p-4 transition-colors hover:bg-muted",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:e.jsx(zt,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"Email"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"info@moenviron.com"})]})]}),e.jsxs("a",{href:"tel:+447394382060",onClick:i=>{i.preventDefault(),window.location.href="tel:+447394382060"},className:"flex items-start gap-4 rounded-lg border border-border p-4 transition-colors hover:bg-muted",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:e.jsx(sd,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"Phone"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"+44 7394 382060"})]})]}),e.jsxs("a",{href:"https://wa.me/447394382060",onClick:i=>{i.preventDefault(),window.parent.postMessage({type:"OPEN_EXTERNAL_URL",data:{url:"https://wa.me/447394382060"}},"*")},target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-4 rounded-lg border border-border p-4 transition-colors hover:bg-muted",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Vh,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"WhatsApp"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Chat with us directly"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 text-lg font-semibold text-foreground",children:"Our Offices"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(rs,{className:"mt-1 h-5 w-5 shrink-0 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"United Kingdom"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"SP11 9GP, Wiltshire"})]})]}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(rs,{className:"mt-1 h-5 w-5 shrink-0 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"Kenya"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Nairobi, Kenya"})]})]})]})]})]})]})})})]}),e.jsx(We,{})]})};function Po(s){const t=d.useRef({value:s,previous:s});return d.useMemo(()=>(t.current.value!==s&&(t.current.previous=t.current.value,t.current.value=s),t.current.previous),[s])}var Ao="Radio",[uy,Yd]=pa(Ao),[my,hy]=uy(Ao),Qd=d.forwardRef((s,t)=>{const{__scopeRadio:r,name:a,checked:n=!1,required:i,disabled:o,value:l="on",onCheck:c,form:m,...p}=s,[x,g]=d.useState(null),u=rt(t,f=>g(f)),y=d.useRef(!1),h=x?m||!!x.closest("form"):!0;return e.jsxs(my,{scope:r,checked:n,disabled:o,children:[e.jsx(Xe.button,{type:"button",role:"radio","aria-checked":n,"data-state":eu(n),"data-disabled":o?"":void 0,disabled:o,value:l,...p,ref:u,onClick:De(s.onClick,f=>{n||c==null||c(),h&&(y.current=f.isPropagationStopped(),y.current||f.stopPropagation())})}),h&&e.jsx(Xd,{control:x,bubbles:!y.current,name:a,value:l,checked:n,required:i,disabled:o,form:m,style:{transform:"translateX(-100%)"}})]})});Qd.displayName=Ao;var Zd="RadioIndicator",Jd=d.forwardRef((s,t)=>{const{__scopeRadio:r,forceMount:a,...n}=s,i=hy(Zd,r);return e.jsx(fa,{present:a||i.checked,children:e.jsx(Xe.span,{"data-state":eu(i.checked),"data-disabled":i.disabled?"":void 0,...n,ref:t})})});Jd.displayName=Zd;var py="RadioBubbleInput",Xd=d.forwardRef(({__scopeRadio:s,control:t,checked:r,bubbles:a=!0,...n},i)=>{const o=d.useRef(null),l=rt(o,i),c=Po(r),m=Dc(t);return d.useEffect(()=>{const p=o.current;if(!p)return;const x=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(x,"checked").set;if(c!==r&&u){const y=new Event("click",{bubbles:a});u.call(p,r),p.dispatchEvent(y)}},[c,r,a]),e.jsx(Xe.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...n,tabIndex:-1,ref:l,style:{...n.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Xd.displayName=py;function eu(s){return s?"checked":"unchecked"}var fy=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],zn="RadioGroup",[xy]=pa(zn,[Oc,Yd]),tu=Oc(),su=Yd(),[gy,yy]=xy(zn),ru=d.forwardRef((s,t)=>{const{__scopeRadioGroup:r,name:a,defaultValue:n,value:i,required:o=!1,disabled:l=!1,orientation:c,dir:m,loop:p=!0,onValueChange:x,...g}=s,u=tu(r),y=lo(m),[h,f]=un({prop:i,defaultProp:n??null,onChange:x,caller:zn});return e.jsx(gy,{scope:r,name:a,required:o,disabled:l,value:h,onValueChange:f,children:e.jsx(Um,{asChild:!0,...u,orientation:c,dir:y,loop:p,children:e.jsx(Xe.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:y,...g,ref:t})})})});ru.displayName=zn;var au="RadioGroupItem",nu=d.forwardRef((s,t)=>{const{__scopeRadioGroup:r,disabled:a,...n}=s,i=yy(au,r),o=i.disabled||a,l=tu(r),c=su(r),m=d.useRef(null),p=rt(t,m),x=i.value===n.value,g=d.useRef(!1);return d.useEffect(()=>{const u=h=>{fy.includes(h.key)&&(g.current=!0)},y=()=>g.current=!1;return document.addEventListener("keydown",u),document.addEventListener("keyup",y),()=>{document.removeEventListener("keydown",u),document.removeEventListener("keyup",y)}},[]),e.jsx(Hm,{asChild:!0,...l,focusable:!o,active:x,children:e.jsx(Qd,{disabled:o,required:i.required,checked:x,...c,...n,name:i.name,ref:p,onCheck:()=>i.onValueChange(n.value),onKeyDown:De(u=>{u.key==="Enter"&&u.preventDefault()}),onFocus:De(n.onFocus,()=>{var u;g.current&&((u=m.current)==null||u.click())})})})});nu.displayName=au;var by="RadioGroupIndicator",iu=d.forwardRef((s,t)=>{const{__scopeRadioGroup:r,...a}=s,n=su(r);return e.jsx(Jd,{...n,...a,ref:t})});iu.displayName=by;var ou=ru,lu=nu,vy=iu;const Ro=d.forwardRef(({className:s,...t},r)=>e.jsx(ou,{className:me("grid gap-2",s),...t,ref:r}));Ro.displayName=ou.displayName;const Ts=d.forwardRef(({className:s,...t},r)=>e.jsx(lu,{ref:r,className:me("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),...t,children:e.jsx(vy,{className:"flex items-center justify-center",children:e.jsx(Mh,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Ts.displayName=lu.displayName;const jy="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%20role='img'%20aria-label='Kenya%20flag'%3e%3c!--%20Stripes:%20Black%20/%20White%20/%20Red%20/%20White%20/%20Green%20--%3e%3crect%20width='64'%20height='64'%20fill='%23006600'/%3e%3crect%20width='64'%20height='40'%20y='0'%20fill='%23000000'/%3e%3crect%20width='64'%20height='6'%20y='18'%20fill='%23FFFFFF'/%3e%3crect%20width='64'%20height='16'%20y='24'%20fill='%23BB0000'/%3e%3crect%20width='64'%20height='6'%20y='40'%20fill='%23FFFFFF'/%3e%3c!--%20Crossed%20spears%20(simplified)%20--%3e%3cpath%20d='M16%2052%20L48%2012'%20stroke='%23FFFFFF'%20stroke-width='3'%20stroke-linecap='round'/%3e%3cpath%20d='M48%2052%20L16%2012'%20stroke='%23FFFFFF'%20stroke-width='3'%20stroke-linecap='round'/%3e%3c!--%20Maasai%20shield%20(simplified)%20--%3e%3cellipse%20cx='32'%20cy='32'%20rx='10'%20ry='16'%20fill='%23FFFFFF'/%3e%3cellipse%20cx='32'%20cy='32'%20rx='8'%20ry='14'%20fill='%23BB0000'/%3e%3cellipse%20cx='32'%20cy='32'%20rx='3.5'%20ry='14'%20fill='%23000000'/%3e%3ccircle%20cx='32'%20cy='22'%20r='2'%20fill='%23FFFFFF'/%3e%3ccircle%20cx='32'%20cy='42'%20r='2'%20fill='%23FFFFFF'/%3e%3c/svg%3e";function wy({className:s}){return e.jsx("span",{className:me("inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-full border border-border bg-background shadow-sm",s),"aria-hidden":"true",children:e.jsx("img",{src:jy,alt:"",className:"h-full w-full",loading:"lazy"})})}const Ia="/assets/stripe-logo-B6rGp_bH.webp",kl="/assets/mpesa-logo-D58-6ry-.webp",Oa="/assets/google-pay-logo-CkN7raRl.webp",Da="/assets/apple-pay-logo-CVixYgr_.webp",Ny="https://buy.stripe.com/dRm7sKgzH3qtapRg8wd3i00",_y=()=>{ns();const[s,t]=d.useState([]),[r,a]=d.useState(!1),[n,i]=d.useState(""),[o,l]=d.useState(""),[c,m]=d.useState("stripe");d.useEffect(()=>{const f=localStorage.getItem("moenviron-cart");f&&t(JSON.parse(f))},[]);const p=f=>{localStorage.setItem("moenviron-cart",JSON.stringify(f)),t(f),window.dispatchEvent(new CustomEvent("cart-updated"))},x=(f,b)=>{const v=s.map(j=>j.id===f?{...j,quantity:Math.max(0,j.quantity+b)}:j).filter(j=>j.quantity>0);p(v)},g=f=>{p(s.filter(b=>b.id!==f))},u=s.reduce((f,b)=>f+b.price*b.quantity,0),y=s.reduce((f,b)=>f+(b.carbon_offset_kg||0)*b.quantity,0),h=async()=>{if(s.length===0){C.error("Your cart is empty");return}if(c==="stripe"||c==="google_pay"){window.location.href=Ny;return}if(c==="mpesa"&&!n){C.error("Please enter your M-Pesa phone number");return}if(!o){C.error("Please enter your email address");return}a(!0);try{const f=c==="mpesa"?"mobile_money":"apple_pay",{data:b,error:v}=await M.functions.invoke("paystack-payment",{body:{items:s.map(j=>({id:j.id,name:j.name,price:Math.round(j.price*150),quantity:j.quantity})),customerEmail:o,customerPhone:c==="mpesa"?n:void 0,paymentMethod:f,currency:"KES",callbackUrl:`${window.location.origin}/checkout/success`}});if(v)throw v;if(b!=null&&b.authorization_url)localStorage.removeItem("moenviron-cart"),window.dispatchEvent(new CustomEvent("cart-updated")),window.location.href=b.authorization_url;else throw new Error("Failed to get payment URL")}catch(f){console.error("Checkout error:",f),C.error("Checkout failed. Please try again.")}finally{a(!1)}};return e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-12",children:e.jsxs("div",{className:"container",children:[e.jsx("h1",{className:"mb-8 text-3xl font-bold text-foreground",children:"Shopping Cart"}),s.length===0?e.jsxs("div",{className:"py-16 text-center",children:[e.jsx(As,{className:"mx-auto h-16 w-16 text-muted-foreground/30"}),e.jsx("h2",{className:"mt-4 text-xl font-semibold text-foreground",children:"Your cart is empty"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Start shopping our sustainable collection"}),e.jsx(Oe,{to:"/shop",className:"mt-6 inline-block",children:e.jsxs(R,{className:"gap-2",children:["Browse Products",e.jsx(ss,{className:"h-4 w-4"})]})})]}):e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsx("div",{className:"lg:col-span-2 space-y-4",children:s.map(f=>e.jsxs("div",{className:"flex gap-4 rounded-xl border border-border bg-card p-4",children:[e.jsx("div",{className:"h-24 w-24 shrink-0 overflow-hidden rounded-lg bg-muted",children:f.image_url?e.jsx("img",{src:f.image_url,alt:f.name,className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{className:"h-8 w-8 text-muted-foreground/30"})})}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-foreground",children:f.name}),f.carbon_offset_kg&&e.jsxs("span",{className:"mt-1 inline-flex items-center gap-1 text-xs text-primary",children:[e.jsx(ft,{className:"h-3 w-3"}),"-",f.carbon_offset_kg,"kg CO₂"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>x(f.id,-1),children:e.jsx(ed,{className:"h-4 w-4"})}),e.jsx("span",{className:"w-8 text-center font-medium",children:f.quantity}),e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>x(f.id,1),children:e.jsx(fs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"font-semibold text-foreground",children:["£",(f.price*f.quantity).toFixed(2)]}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>g(f.id),children:e.jsx(xs,{className:"h-4 w-4"})})]})]})]})]},f.id))}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-6",children:[e.jsx("h2",{className:"mb-6 text-xl font-semibold text-foreground",children:"Order Summary"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsxs("span",{className:"font-medium text-foreground",children:["£",u.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Shipping"}),e.jsx("span",{className:"font-medium text-foreground",children:"£5.00"})]}),y>0&&e.jsxs("div",{className:"flex justify-between text-sm text-primary",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ft,{className:"h-4 w-4"}),"Carbon Offset"]}),e.jsxs("span",{className:"font-medium",children:["-",y.toFixed(1),"kg CO₂"]})]}),e.jsx("div",{className:"border-t border-border pt-4",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-lg font-semibold text-foreground",children:"Total"}),e.jsxs("div",{className:"text-right",children:[e.jsxs("span",{className:"text-lg font-bold text-foreground",children:["£",(u+5).toFixed(2)]}),c!=="stripe"&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["≈ KES ",Math.round((u+5)*150).toLocaleString()]})]})]})})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"email",children:"Email Address *"}),e.jsx(Q,{id:"email",type:"email",value:o,onChange:f=>l(f.target.value),placeholder:"your@email.com",required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Order confirmation will be sent here"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{children:"Payment Method"}),e.jsxs(Ro,{value:c,onValueChange:f=>m(f),className:"grid grid-cols-2 gap-2",children:[e.jsxs(B,{htmlFor:"stripe-cart",className:`flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors ${c==="stripe"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"stripe",id:"stripe-cart"}),e.jsx("img",{src:Ia,alt:"Stripe",className:"h-4 w-auto"})]}),e.jsxs(B,{htmlFor:"mpesa-cart",className:`flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors ${c==="mpesa"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"mpesa",id:"mpesa-cart"}),e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:kl,alt:"M-Pesa",className:"h-5 w-auto"}),e.jsx(wy,{className:"absolute -top-1 -right-1 h-3 w-3"})]})]}),e.jsxs(B,{htmlFor:"google-pay-cart",className:`flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors ${c==="google_pay"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"google_pay",id:"google-pay-cart"}),e.jsx("img",{src:Oa,alt:"Google Pay",className:"h-4 w-auto"})]}),e.jsxs(B,{htmlFor:"apple-pay-cart",className:`flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors ${c==="apple_pay"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"apple_pay",id:"apple-pay-cart"}),e.jsx("img",{src:Da,alt:"Apple Pay",className:"h-4 w-auto"})]})]})]}),c==="mpesa"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"phone",children:"M-Pesa Phone Number *"}),e.jsx(Q,{id:"phone",type:"tel",value:n,onChange:f=>i(f.target.value),placeholder:"+254 712 345 678",required:!0})]})]}),e.jsx(R,{className:"mt-6 w-full gap-2",size:"lg",onClick:h,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):c==="stripe"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Ia,alt:"",className:"h-4 w-auto"}),"Proceed to Checkout"]}):c==="mpesa"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:kl,alt:"",className:"h-5 w-auto"}),"Pay with M-Pesa"]}):c==="google_pay"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Oa,alt:"",className:"h-4 w-auto"}),"Pay with Google Pay"]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Da,alt:"",className:"h-4 w-auto"}),"Pay with Apple Pay"]})}),e.jsxs("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:["Secure checkout powered by ",c==="stripe"?"Stripe":"Paystack"]})]})]})]})}),e.jsx(We,{})]})},Cl="https://buy.stripe.com/dRm7sKgzH3qtapRg8wd3i00",cu=(s,t)=>{const r=new URLSearchParams;s&&r.append("prefilled_email",s),t!==void 0&&t>0&&(r.append("amount",t.toString()),r.append("unit_amount",Math.round(t*100).toString()));const a=r.toString();return a?`${Cl}?${a}`:Cl},Wi=(s,t)=>{C.info("Redirecting to secure payment page...",{description:"Standard checkout unavailable. Using backup payment link.",duration:3e3});const r=cu(s,t);setTimeout(()=>{window.location.href=r},1500)},El="/assets/paypal-logo-Cyt9Ap35.webp",Sy="pk_live_51Su7CXAViLYdoyiZJ91xZSdxKC4E62c1qmH3nz9znmDIqZqfcQ5sJYhLvlMnr3G2BqN8gxq3wThfpRsj3Nm6vXPG00Pj7LQXfI",Tl=uh(Sy);function ky({cartItems:s,subtotal:t,clientSecret:r,paymentIntentId:a,customerEmail:n,customerName:i}){const o=hh(),l=ph(),c=ns(),[m,p]=d.useState(!1),[x,g]=d.useState(!1),[u,y]=d.useState(!1),[h,f]=d.useState(!1),[b,v]=d.useState(null),j=5,_=t+j,I=async E=>{if(E.preventDefault(),!o||!l||!b){C.error("Please complete all required fields");return}p(!0);try{const{error:O}=await l.submit();if(O){C.error(O.message||"Please check your payment details"),p(!1);return}const{error:D,paymentIntent:N}=await o.confirmPayment({elements:l,confirmParams:{receipt_email:n,shipping:{name:b.name,phone:b.phone,address:{line1:b.address.line1,line2:b.address.line2||"",city:b.address.city,state:b.address.state||"",postal_code:b.address.postal_code,country:b.address.country}}},redirect:"if_required"});if(D){C.error(D.message||"Payment failed"),p(!1);return}if((N==null?void 0:N.status)==="succeeded"){const{error:T}=await M.functions.invoke("stripe-webhook",{body:{paymentIntentId:N.id,shippingAddress:{name:b.name,phone:b.phone,line1:b.address.line1,line2:b.address.line2,city:b.address.city,state:b.address.state,postal_code:b.address.postal_code,country:b.address.country}}});T&&console.error("Order confirmation error:",T),localStorage.removeItem("moenviron-cart"),window.dispatchEvent(new CustomEvent("cart-updated")),g(!0),C.success("Payment successful!"),setTimeout(()=>{c(`/checkout/success?payment_intent=${N.id}`)},2e3)}}catch(O){console.error("Payment error:",O),C.error("An error occurred during payment")}finally{p(!1)}};return x?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/30",children:e.jsx(wt,{className:"h-10 w-10 text-green-600 dark:text-green-400"})}),e.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Payment Successful!"}),e.jsx("p",{className:"text-muted-foreground",children:"Redirecting to your order confirmation..."}),e.jsx(ue,{className:"mt-4 h-6 w-6 animate-spin text-primary"})]}):e.jsxs("form",{onSubmit:I,className:"space-y-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border pb-4",children:[e.jsx(rs,{className:"h-5 w-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Shipping Address"})]}),e.jsx("div",{className:"rounded-lg border border-border bg-background p-4",children:e.jsx(fh,{options:{mode:"shipping",autocomplete:{mode:"google_maps_api",apiKey:""},fields:{phone:"always"},validation:{phone:{required:"auto"}},defaultValues:{name:i}},onChange:E=>{y(E.complete),E.complete&&E.value&&v(E.value)}})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border pb-4",children:[e.jsx(Ka,{className:"h-5 w-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Payment Details"})]}),e.jsx("div",{className:"rounded-lg border border-border bg-background p-4",children:e.jsx(xh,{options:{layout:"tabs"},onChange:E=>f(E.complete)})})]}),e.jsx("div",{className:"rounded-lg border border-border bg-muted/50 p-4",children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsxs("span",{className:"font-medium",children:["£",t.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Shipping"}),e.jsxs("span",{className:"font-medium",children:["£",j.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between border-t border-border pt-2 text-base font-semibold",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["£",_.toFixed(2)]})]})]})}),e.jsx(R,{type:"submit",className:"w-full gap-2",size:"lg",disabled:!o||!l||m||!u||!h,children:m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Yo,{className:"h-4 w-4"}),"Pay £",_.toFixed(2)]})}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:[e.jsx(Yo,{className:"mr-1 inline h-3 w-3"}),"Secure payment powered by Stripe"]})]})}function Cy(){const s=ns(),[t,r]=d.useState([]),[a,n]=d.useState(""),[i,o]=d.useState(""),[l,c]=d.useState(""),[m,p]=d.useState(""),[x,g]=d.useState(!1),[u,y]=d.useState(!1),[h,f]=d.useState(!1),[b,v]=d.useState(null),[j,_]=d.useState(null),[I,E]=d.useState(""),[O,D]=d.useState("stripe"),N=()=>{g(!0),"geolocation"in navigator?navigator.geolocation.getCurrentPosition(async F=>{try{const{latitude:k,longitude:A}=F.coords,re=await(await fetch(`https://api.bigdatacloud.net/data/reverse-geocode-client?latitude=${k}&longitude=${A}&localityLanguage=en`)).json(),$=`${re.city||re.locality}, ${re.countryName}`;c($),C.success(`Location detected: ${$}`)}catch(k){console.error("Error reverse geocoding:",k),C.error("Could not determine city name, but location captured.")}finally{g(!1)}},F=>{console.error("Geolocation error:",F),C.error("Location access denied or unavailable."),g(!1)}):(C.error("Geolocation is not supported by your browser."),g(!1))};d.useEffect(()=>{const F=localStorage.getItem("moenviron-cart");if(F){const k=JSON.parse(F);k.length===0?s("/cart"):r(k)}else s("/cart")},[s]);const T=t.reduce((F,k)=>F+k.price*k.quantity,0),P=t.reduce((F,k)=>F+(k.carbon_offset_kg||0)*k.quantity,0),S=F=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(F),W=async()=>{if(!a){E("Email is required");return}if(!S(a)){E("Please enter a valid email");return}E(""),y(!0);try{const{data:F,error:k}=await M.functions.invoke("create-checkout",{body:{items:t.map(A=>({id:A.id,name:A.name,price:A.price,quantity:A.quantity})),customerEmail:a,customerName:i,mode:"payment_intent"}});if(k)throw k;if(F!=null&&F.clientSecret)v(F.clientSecret),_(F.paymentIntentId),f(!0);else throw new Error("Failed to create payment intent")}catch(F){console.error("Error creating payment:",F),Wi(a,total)}finally{y(!1)}},K=!!Tl;return e.jsxs("div",{className:"flex min-h-screen flex-col bg-gradient-to-b from-background to-muted/20",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-8",children:e.jsxs("div",{className:"container max-w-6xl",children:[e.jsxs(Oe,{to:"/cart",className:"mb-6 inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(Rn,{className:"h-4 w-4"}),"Back to cart"]}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-5",children:[e.jsx("div",{className:"lg:col-span-3",children:e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"mb-6 text-2xl font-bold text-foreground",children:"Checkout"}),h?b?e.jsx(mh,{stripe:Tl,options:{clientSecret:b,appearance:{theme:"stripe",variables:{colorPrimary:"#16a34a",borderRadius:"8px"}}},children:e.jsx(ky,{cartItems:t,subtotal:T,clientSecret:b,paymentIntentId:j||"",customerEmail:a,customerName:i})}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"email",className:"text-sm font-medium",children:"Email Address *"}),e.jsx(Q,{id:"email",type:"email",value:a,onChange:F=>{n(F.target.value),I&&E("")},placeholder:"you@example.com",className:I?"border-destructive":""}),I&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:I}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"We'll send your order confirmation here"})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"name",className:"text-sm font-medium",children:"Full Name"}),e.jsx(Q,{id:"name",value:i,onChange:F=>o(F.target.value),placeholder:"Your name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{htmlFor:"location",className:"text-sm font-medium flex items-center justify-between",children:[e.jsx("span",{children:"Delivery Location"}),e.jsxs(R,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-primary hover:text-primary hover:bg-primary/5",onClick:N,disabled:x,children:[x?e.jsx(ue,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(rs,{className:"mr-1 h-3 w-3"}),"Detect My Location"]})]}),e.jsx(Q,{id:"location",value:l,onChange:F=>c(F.target.value),placeholder:"City, Country"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Capturing your location helps us calculate environmental impact"})]}),e.jsxs("div",{className:"space-y-3 pt-4 border-t border-border",children:[e.jsx(B,{className:"text-sm font-medium",children:"Payment Method"}),e.jsxs(Ro,{value:O,onValueChange:F=>D(F),className:"grid gap-3",children:[e.jsxs("div",{className:`flex items-center space-x-3 rounded-lg border p-3 cursor-pointer transition-colors ${O==="stripe"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"stripe",id:"stripe"}),e.jsxs(B,{htmlFor:"stripe",className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("img",{src:Ia,alt:"Stripe",className:"h-6 w-auto object-contain"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Card Payment"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pay with Visa, Mastercard, or American Express"})]})]})]}),e.jsxs("div",{className:`flex items-center space-x-3 rounded-lg border p-3 cursor-pointer transition-colors ${O==="google_pay"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"google_pay",id:"google_pay"}),e.jsxs(B,{htmlFor:"google_pay",className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("img",{src:Oa,alt:"Google Pay",className:"h-6 w-auto object-contain"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Google Pay"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Fast checkout with Google Pay"})]})]})]}),e.jsxs("div",{className:`flex items-center space-x-3 rounded-lg border p-3 cursor-pointer transition-colors ${O==="apple_pay"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"apple_pay",id:"apple_pay"}),e.jsxs(B,{htmlFor:"apple_pay",className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("img",{src:Da,alt:"Apple Pay",className:"h-6 w-auto object-contain"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Apple Pay"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Quick and secure Apple Pay"})]})]})]}),e.jsxs("div",{className:`flex items-center space-x-3 rounded-lg border p-3 cursor-pointer transition-colors ${O==="paypal"?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Ts,{value:"paypal",id:"paypal"}),e.jsxs(B,{htmlFor:"paypal",className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("img",{src:El,alt:"PayPal",className:"h-6 w-auto object-contain"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"PayPal"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pay securely with PayPal"})]})]})]})]})]}),e.jsx(R,{onClick:W,className:"w-full gap-2",size:"lg",disabled:u||!K,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):O==="apple_pay"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Da,alt:"",className:"h-5 w-auto"}),"Pay with Apple Pay"]}):O==="google_pay"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Oa,alt:"",className:"h-5 w-auto"}),"Pay with Google Pay"]}):O==="paypal"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:El,alt:"",className:"h-5 w-auto"}),"Pay with PayPal"]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Ia,alt:"",className:"h-4 w-auto"}),"Continue to Payment"]})})]})]})}),e.jsx("div",{className:"lg:col-span-2",children:e.jsxs("div",{className:"sticky top-24 rounded-2xl border border-border bg-card p-6 shadow-sm",children:[e.jsxs("h2",{className:"mb-4 flex items-center gap-2 text-lg font-semibold text-foreground",children:[e.jsx(As,{className:"h-5 w-5"}),"Order Summary"]}),e.jsx("div",{className:"max-h-64 space-y-3 overflow-y-auto pr-2",children:t.map(F=>e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"h-16 w-16 shrink-0 overflow-hidden rounded-lg bg-muted",children:F.image_url?e.jsx("img",{src:F.image_url,alt:F.name,className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{className:"h-6 w-6 text-muted-foreground/30"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground line-clamp-1",children:F.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Qty: ",F.quantity]}),e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["£",(F.price*F.quantity).toFixed(2)]})]})]},F.id))}),e.jsxs("div",{className:"mt-4 space-y-2 border-t border-border pt-4 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsxs("span",{className:"font-medium",children:["£",T.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Shipping"}),e.jsx("span",{className:"font-medium",children:"£5.00"})]}),P>0&&e.jsxs("div",{className:"flex justify-between text-primary",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ft,{className:"h-3 w-3"}),"Carbon Offset"]}),e.jsxs("span",{className:"font-medium",children:["-",P.toFixed(1),"kg CO₂"]})]}),e.jsxs("div",{className:"flex justify-between border-t border-border pt-2 text-base font-bold",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["£",(T+5).toFixed(2)]})]})]}),e.jsx("div",{className:"mt-4 rounded-lg bg-primary/5 p-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ft,{className:"mt-0.5 h-4 w-4 text-primary"}),e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Sustainable Purchase"}),e.jsxs("p",{className:"text-muted-foreground",children:["Your order helps offset ",P.toFixed(1),"kg of CO₂ emissions"]})]})]})})]})})]})]})}),e.jsx(We,{})]})}const Ey=()=>{const[s]=rh(),t=s.get("session_id"),r=s.get("payment_intent"),a=t||r,[n,i]=d.useState(!0),[o,l]=d.useState(!1);return d.useEffect(()=>{localStorage.removeItem("moenviron-cart"),window.dispatchEvent(new CustomEvent("cart-updated"));async function c(){if(!a){i(!1),l(!0);return}try{const{data:m,error:p}=await M.functions.invoke("stripe-webhook",{body:t?{sessionId:t}:{paymentIntentId:r}});p?console.error("Error processing order:",p):(m!=null&&m.success,l(!0))}catch(m){console.error("Failed to process order:",m),l(!0)}finally{i(!1)}}c()},[a,t,r]),e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-16",children:e.jsx("div",{className:"container",children:e.jsx("div",{className:"mx-auto max-w-lg text-center",children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:e.jsx(ue,{className:"h-10 w-10 text-primary animate-spin"})}),e.jsx("h1",{className:"mb-4 text-3xl font-bold text-foreground",children:"Processing Your Order..."}),e.jsx("p",{className:"mb-8 text-muted-foreground",children:"Please wait while we confirm your payment."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Gc,{className:"h-10 w-10 text-primary"})}),e.jsx("h1",{className:"mb-4 text-3xl font-bold text-foreground",children:"Order Confirmed!"}),e.jsxs("p",{className:"mb-8 text-muted-foreground",children:["Thank you for shopping sustainably. ",o?"A confirmation email has been sent to your inbox.":"Your order has been received."]}),a&&e.jsxs("p",{className:"mb-8 text-sm text-muted-foreground",children:["Order reference: ",e.jsxs("code",{className:"rounded bg-muted px-2 py-1",children:[a.slice(0,20),"..."]})]}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:justify-center",children:[e.jsx(Oe,{to:"/shop",children:e.jsxs(R,{className:"gap-2",children:["Continue Shopping",e.jsx(As,{className:"h-4 w-4"})]})}),e.jsx(Oe,{to:"/impact",children:e.jsxs(R,{variant:"outline",className:"gap-2",children:["See Your Impact",e.jsx(ss,{className:"h-4 w-4"})]})})]})]})})})}),e.jsx(We,{})]})},Ir=Vm,ar=d.forwardRef(({className:s,...t},r)=>e.jsx(Lc,{ref:r,className:me("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",s),...t}));ar.displayName=Lc.displayName;const Ye=d.forwardRef(({className:s,...t},r)=>e.jsx(Fc,{ref:r,className:me("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",s),...t}));Ye.displayName=Fc.displayName;const $e=d.forwardRef(({className:s,...t},r)=>e.jsx(qc,{ref:r,className:me("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...t}));$e.displayName=qc.displayName;var qe;(function(s){s.assertEqual=n=>{};function t(n){}s.assertIs=t;function r(n){throw new Error}s.assertNever=r,s.arrayToEnum=n=>{const i={};for(const o of n)i[o]=o;return i},s.getValidEnumValues=n=>{const i=s.objectKeys(n).filter(l=>typeof n[n[l]]!="number"),o={};for(const l of i)o[l]=n[l];return s.objectValues(o)},s.objectValues=n=>s.objectKeys(n).map(function(i){return n[i]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},s.find=(n,i)=>{for(const o of n)if(i(o))return o},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}s.joinValues=a,s.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(qe||(qe={}));var Pl;(function(s){s.mergeShapes=(t,r)=>({...t,...r})})(Pl||(Pl={}));const oe=qe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Bs=s=>{switch(typeof s){case"undefined":return oe.undefined;case"string":return oe.string;case"number":return Number.isNaN(s)?oe.nan:oe.number;case"boolean":return oe.boolean;case"function":return oe.function;case"bigint":return oe.bigint;case"symbol":return oe.symbol;case"object":return Array.isArray(s)?oe.array:s===null?oe.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?oe.promise:typeof Map<"u"&&s instanceof Map?oe.map:typeof Set<"u"&&s instanceof Set?oe.set:typeof Date<"u"&&s instanceof Date?oe.date:oe.object;default:return oe.unknown}},U=qe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Rs extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},a={_errors:[]},n=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)a._errors.push(r(o));else{let l=a,c=0;for(;c<o.path.length;){const m=o.path[c];c===o.path.length-1?(l[m]=l[m]||{_errors:[]},l[m]._errors.push(r(o))):l[m]=l[m]||{_errors:[]},l=l[m],c++}}};return n(this),a}static assert(t){if(!(t instanceof Rs))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,qe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},a=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else a.push(t(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}Rs.create=s=>new Rs(s);const Ki=(s,t)=>{let r;switch(s.code){case U.invalid_type:s.received===oe.undefined?r="Required":r=`Expected ${s.expected}, received ${s.received}`;break;case U.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(s.expected,qe.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:r=`Unrecognized key(s) in object: ${qe.joinValues(s.keys,", ")}`;break;case U.invalid_union:r="Invalid input";break;case U.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${qe.joinValues(s.options)}`;break;case U.invalid_enum_value:r=`Invalid enum value. Expected ${qe.joinValues(s.options)}, received '${s.received}'`;break;case U.invalid_arguments:r="Invalid function arguments";break;case U.invalid_return_type:r="Invalid function return type";break;case U.invalid_date:r="Invalid date";break;case U.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(r=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?r=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?r=`Invalid input: must end with "${s.validation.endsWith}"`:qe.assertNever(s.validation):s.validation!=="regex"?r=`Invalid ${s.validation}`:r="Invalid";break;case U.too_small:s.type==="array"?r=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?r=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?r=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?r=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?r=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:r="Invalid input";break;case U.too_big:s.type==="array"?r=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?r=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?r=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?r=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?r=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:r="Invalid input";break;case U.custom:r="Invalid input";break;case U.invalid_intersection_types:r="Intersection results could not be merged";break;case U.not_multiple_of:r=`Number must be a multiple of ${s.multipleOf}`;break;case U.not_finite:r="Number must be finite";break;default:r=t.defaultError,qe.assertNever(s)}return{message:r}};let Ty=Ki;function Py(){return Ty}const Ay=s=>{const{data:t,path:r,errorMaps:a,issueData:n}=s,i=[...r,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let l="";const c=a.filter(m=>!!m).slice().reverse();for(const m of c)l=m(o,{data:t,defaultError:l}).message;return{...n,path:i,message:l}};function te(s,t){const r=Py(),a=Ay({issueData:t,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,r,r===Ki?void 0:Ki].filter(n=>!!n)});s.common.issues.push(a)}class Mt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const a=[];for(const n of r){if(n.status==="aborted")return _e;n.status==="dirty"&&t.dirty(),a.push(n.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){const a=[];for(const n of r){const i=await n.key,o=await n.value;a.push({key:i,value:o})}return Mt.mergeObjectSync(t,a)}static mergeObjectSync(t,r){const a={};for(const n of r){const{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return _e;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(a[i.value]=o.value)}return{status:t.value,value:a}}}const _e=Object.freeze({status:"aborted"}),Ta=s=>({status:"dirty",value:s}),Ht=s=>({status:"valid",value:s}),Al=s=>s.status==="aborted",Rl=s=>s.status==="dirty",ia=s=>s.status==="valid",jn=s=>typeof Promise<"u"&&s instanceof Promise;var ce;(function(s){s.errToObj=t=>typeof t=="string"?{message:t}:t||{},s.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ce||(ce={}));class tr{constructor(t,r,a,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ml=(s,t)=>{if(ia(t))return{success:!0,data:t.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Rs(s.common.issues);return this._error=r,this._error}}};function Re(s){if(!s)return{};const{errorMap:t,invalid_type_error:r,required_error:a,description:n}=s;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,l)=>{const{message:c}=s;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??a??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??r??l.defaultError}},description:n}}class Fe{get description(){return this._def.description}_getType(t){return Bs(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Bs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Mt,ctx:{common:t.parent.common,data:t.data,parsedType:Bs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if(jn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Bs(t)},n=this._parseSync({data:t,path:a.path,parent:a});return Ml(a,n)}"~validate"(t){var a,n;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Bs(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:r});return ia(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(n=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>ia(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){const a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Bs(t)},n=this._parse({data:t,path:a.path,parent:a}),i=await(jn(n)?n:Promise.resolve(n));return Ml(a,i)}refine(t,r){const a=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{const o=t(n),l=()=>i.addIssue({code:U.custom,...a(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,r){return this._refinement((a,n)=>t(a)?!0:(n.addIssue(typeof r=="function"?r(a,n):r),!1))}_refinement(t){return new la({schema:this,typeName:Se.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return er.create(this,this._def)}nullable(){return ca.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ps.create(this)}promise(){return Sn.create(this,this._def)}or(t){return Nn.create([this,t],this._def)}and(t){return _n.create(this,t,this._def)}transform(t){return new la({...Re(this._def),schema:this,typeName:Se.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new Yi({...Re(this._def),innerType:this,defaultValue:r,typeName:Se.ZodDefault})}brand(){return new eb({typeName:Se.ZodBranded,type:this,...Re(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new Qi({...Re(this._def),innerType:this,catchValue:r,typeName:Se.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Mo.create(this,t)}readonly(){return Zi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ry=/^c[^\s-]{8,}$/i,My=/^[0-9a-z]+$/,Iy=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Oy=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Dy=/^[a-z0-9_-]{21}$/i,Ly=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fy=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,qy=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mi;const $y=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,By=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Uy=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Hy=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vy=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wy=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,du="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Ky=new RegExp(`^${du}$`);function uu(s){let t="[0-5]\\d";s.precision?t=`${t}\\.\\d{${s.precision}}`:s.precision==null&&(t=`${t}(\\.\\d+)?`);const r=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Gy(s){return new RegExp(`^${uu(s)}$`)}function Yy(s){let t=`${du}T${uu(s)}`;const r=[];return r.push(s.local?"Z?":"Z"),s.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Qy(s,t){return!!((t==="v4"||!t)&&$y.test(s)||(t==="v6"||!t)&&Uy.test(s))}function Zy(s,t){if(!Ly.test(s))return!1;try{const[r]=s.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function Jy(s,t){return!!((t==="v4"||!t)&&By.test(s)||(t==="v6"||!t)&&Hy.test(s))}class Js extends Fe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==oe.string){const i=this._getOrReturnCtx(t);return te(i,{code:U.invalid_type,expected:oe.string,received:i.parsedType}),_e}const a=new Mt;let n;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(n=this._getOrReturnCtx(t,n),te(n,{code:U.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")t.data.length>i.value&&(n=this._getOrReturnCtx(t,n),te(n,{code:U.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(n=this._getOrReturnCtx(t,n),o?te(n,{code:U.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&te(n,{code:U.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")qy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"email",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")mi||(mi=new RegExp(zy,"u")),mi.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"emoji",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Oy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"uuid",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Dy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"nanoid",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Ry.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"cuid",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")My.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"cuid2",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Iy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"ulid",code:U.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),te(n,{validation:"url",code:U.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"regex",code:U.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(t,n),te(n,{code:U.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(n=this._getOrReturnCtx(t,n),te(n,{code:U.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(n=this._getOrReturnCtx(t,n),te(n,{code:U.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?Yy(i).test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{code:U.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Ky.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{code:U.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?Gy(i).test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{code:U.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?Fy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"duration",code:U.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?Qy(t.data,i.version)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"ip",code:U.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?Zy(t.data,i.alg)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"jwt",code:U.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?Jy(t.data,i.version)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"cidr",code:U.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?Vy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"base64",code:U.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Wy.test(t.data)||(n=this._getOrReturnCtx(t,n),te(n,{validation:"base64url",code:U.invalid_string,message:i.message}),a.dirty()):qe.assertNever(i);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(n=>t.test(n),{validation:r,code:U.invalid_string,...ce.errToObj(a)})}_addCheck(t){return new Js({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ce.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ce.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ce.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ce.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ce.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ce.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ce.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ce.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ce.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ce.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ce.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ce.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ce.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...ce.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...ce.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ce.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ce.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r==null?void 0:r.position,...ce.errToObj(r==null?void 0:r.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ce.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ce.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ce.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ce.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ce.errToObj(r)})}nonempty(t){return this.min(1,ce.errToObj(t))}trim(){return new Js({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Js({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Js({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}Js.create=s=>new Js({checks:[],typeName:Se.ZodString,coerce:(s==null?void 0:s.coerce)??!1,...Re(s)});function Xy(s,t){const r=(s.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=r>a?r:a,i=Number.parseInt(s.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return i%o/10**n}class La extends Fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==oe.number){const i=this._getOrReturnCtx(t);return te(i,{code:U.invalid_type,expected:oe.number,received:i.parsedType}),_e}let a;const n=new Mt;for(const i of this._def.checks)i.kind==="int"?qe.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),te(a,{code:U.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),te(a,{code:U.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),te(a,{code:U.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Xy(t.data,i.value)!==0&&(a=this._getOrReturnCtx(t,a),te(a,{code:U.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),te(a,{code:U.not_finite,message:i.message}),n.dirty()):qe.assertNever(i);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ce.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ce.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ce.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ce.toString(r))}setLimit(t,r,a,n){return new La({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:ce.toString(n)}]})}_addCheck(t){return new La({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ce.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ce.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ce.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ce.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ce.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ce.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ce.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ce.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ce.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&qe.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}}La.create=s=>new La({checks:[],typeName:Se.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...Re(s)});class Fa extends Fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==oe.bigint)return this._getInvalidInput(t);let a;const n=new Mt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),te(a,{code:U.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),te(a,{code:U.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),te(a,{code:U.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):qe.assertNever(i);return{status:n.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return te(r,{code:U.invalid_type,expected:oe.bigint,received:r.parsedType}),_e}gte(t,r){return this.setLimit("min",t,!0,ce.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ce.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ce.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ce.toString(r))}setLimit(t,r,a,n){return new Fa({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:ce.toString(n)}]})}_addCheck(t){return new Fa({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ce.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ce.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ce.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ce.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ce.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}Fa.create=s=>new Fa({checks:[],typeName:Se.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,...Re(s)});class Il extends Fe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==oe.boolean){const a=this._getOrReturnCtx(t);return te(a,{code:U.invalid_type,expected:oe.boolean,received:a.parsedType}),_e}return Ht(t.data)}}Il.create=s=>new Il({typeName:Se.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...Re(s)});class wn extends Fe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==oe.date){const i=this._getOrReturnCtx(t);return te(i,{code:U.invalid_type,expected:oe.date,received:i.parsedType}),_e}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return te(i,{code:U.invalid_date}),_e}const a=new Mt;let n;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(n=this._getOrReturnCtx(t,n),te(n,{code:U.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(n=this._getOrReturnCtx(t,n),te(n,{code:U.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):qe.assertNever(i);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new wn({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:ce.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ce.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}wn.create=s=>new wn({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:Se.ZodDate,...Re(s)});class Ol extends Fe{_parse(t){if(this._getType(t)!==oe.symbol){const a=this._getOrReturnCtx(t);return te(a,{code:U.invalid_type,expected:oe.symbol,received:a.parsedType}),_e}return Ht(t.data)}}Ol.create=s=>new Ol({typeName:Se.ZodSymbol,...Re(s)});class Dl extends Fe{_parse(t){if(this._getType(t)!==oe.undefined){const a=this._getOrReturnCtx(t);return te(a,{code:U.invalid_type,expected:oe.undefined,received:a.parsedType}),_e}return Ht(t.data)}}Dl.create=s=>new Dl({typeName:Se.ZodUndefined,...Re(s)});class Ll extends Fe{_parse(t){if(this._getType(t)!==oe.null){const a=this._getOrReturnCtx(t);return te(a,{code:U.invalid_type,expected:oe.null,received:a.parsedType}),_e}return Ht(t.data)}}Ll.create=s=>new Ll({typeName:Se.ZodNull,...Re(s)});class Fl extends Fe{constructor(){super(...arguments),this._any=!0}_parse(t){return Ht(t.data)}}Fl.create=s=>new Fl({typeName:Se.ZodAny,...Re(s)});class ql extends Fe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ht(t.data)}}ql.create=s=>new ql({typeName:Se.ZodUnknown,...Re(s)});class sr extends Fe{_parse(t){const r=this._getOrReturnCtx(t);return te(r,{code:U.invalid_type,expected:oe.never,received:r.parsedType}),_e}}sr.create=s=>new sr({typeName:Se.ZodNever,...Re(s)});class zl extends Fe{_parse(t){if(this._getType(t)!==oe.undefined){const a=this._getOrReturnCtx(t);return te(a,{code:U.invalid_type,expected:oe.void,received:a.parsedType}),_e}return Ht(t.data)}}zl.create=s=>new zl({typeName:Se.ZodVoid,...Re(s)});class ps extends Fe{_parse(t){const{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==oe.array)return te(r,{code:U.invalid_type,expected:oe.array,received:r.parsedType}),_e;if(n.exactLength!==null){const o=r.data.length>n.exactLength.value,l=r.data.length<n.exactLength.value;(o||l)&&(te(r,{code:o?U.too_big:U.too_small,minimum:l?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(te(r,{code:U.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(te(r,{code:U.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>n.type._parseAsync(new tr(r,o,r.path,l)))).then(o=>Mt.mergeArray(a,o));const i=[...r.data].map((o,l)=>n.type._parseSync(new tr(r,o,r.path,l)));return Mt.mergeArray(a,i)}get element(){return this._def.type}min(t,r){return new ps({...this._def,minLength:{value:t,message:ce.toString(r)}})}max(t,r){return new ps({...this._def,maxLength:{value:t,message:ce.toString(r)}})}length(t,r){return new ps({...this._def,exactLength:{value:t,message:ce.toString(r)}})}nonempty(t){return this.min(1,t)}}ps.create=(s,t)=>new ps({type:s,minLength:null,maxLength:null,exactLength:null,typeName:Se.ZodArray,...Re(t)});function qr(s){if(s instanceof ot){const t={};for(const r in s.shape){const a=s.shape[r];t[r]=er.create(qr(a))}return new ot({...s._def,shape:()=>t})}else return s instanceof ps?new ps({...s._def,type:qr(s.element)}):s instanceof er?er.create(qr(s.unwrap())):s instanceof ca?ca.create(qr(s.unwrap())):s instanceof Cr?Cr.create(s.items.map(t=>qr(t))):s}class ot extends Fe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),r=qe.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==oe.object){const m=this._getOrReturnCtx(t);return te(m,{code:U.invalid_type,expected:oe.object,received:m.parsedType}),_e}const{status:a,ctx:n}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof sr&&this._def.unknownKeys==="strip"))for(const m in n.data)o.includes(m)||l.push(m);const c=[];for(const m of o){const p=i[m],x=n.data[m];c.push({key:{status:"valid",value:m},value:p._parse(new tr(n,x,n.path,m)),alwaysSet:m in n.data})}if(this._def.catchall instanceof sr){const m=this._def.unknownKeys;if(m==="passthrough")for(const p of l)c.push({key:{status:"valid",value:p},value:{status:"valid",value:n.data[p]}});else if(m==="strict")l.length>0&&(te(n,{code:U.unrecognized_keys,keys:l}),a.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const p of l){const x=n.data[p];c.push({key:{status:"valid",value:p},value:m._parse(new tr(n,x,n.path,p)),alwaysSet:p in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const m=[];for(const p of c){const x=await p.key,g=await p.value;m.push({key:x,value:g,alwaysSet:p.alwaysSet})}return m}).then(m=>Mt.mergeObjectSync(a,m)):Mt.mergeObjectSync(a,c)}get shape(){return this._def.shape()}strict(t){return ce.errToObj,new ot({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{var i,o;const n=((o=(i=this._def).errorMap)==null?void 0:o.call(i,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:ce.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new ot({...this._def,unknownKeys:"strip"})}passthrough(){return new ot({...this._def,unknownKeys:"passthrough"})}extend(t){return new ot({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ot({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Se.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new ot({...this._def,catchall:t})}pick(t){const r={};for(const a of qe.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new ot({...this._def,shape:()=>r})}omit(t){const r={};for(const a of qe.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new ot({...this._def,shape:()=>r})}deepPartial(){return qr(this)}partial(t){const r={};for(const a of qe.objectKeys(this.shape)){const n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new ot({...this._def,shape:()=>r})}required(t){const r={};for(const a of qe.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof er;)i=i._def.innerType;r[a]=i}return new ot({...this._def,shape:()=>r})}keyof(){return mu(qe.objectKeys(this.shape))}}ot.create=(s,t)=>new ot({shape:()=>s,unknownKeys:"strip",catchall:sr.create(),typeName:Se.ZodObject,...Re(t)});ot.strictCreate=(s,t)=>new ot({shape:()=>s,unknownKeys:"strict",catchall:sr.create(),typeName:Se.ZodObject,...Re(t)});ot.lazycreate=(s,t)=>new ot({shape:s,unknownKeys:"strip",catchall:sr.create(),typeName:Se.ZodObject,...Re(t)});class Nn extends Fe{_parse(t){const{ctx:r}=this._processInputParams(t),a=this._def.options;function n(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new Rs(l.ctx.common.issues));return te(r,{code:U.invalid_union,unionErrors:o}),_e}if(r.common.async)return Promise.all(a.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let i;const o=[];for(const c of a){const m={...r,common:{...r.common,issues:[]},parent:null},p=c._parseSync({data:r.data,path:r.path,parent:m});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new Rs(c));return te(r,{code:U.invalid_union,unionErrors:l}),_e}}get options(){return this._def.options}}Nn.create=(s,t)=>new Nn({options:s,typeName:Se.ZodUnion,...Re(t)});function Gi(s,t){const r=Bs(s),a=Bs(t);if(s===t)return{valid:!0,data:s};if(r===oe.object&&a===oe.object){const n=qe.objectKeys(t),i=qe.objectKeys(s).filter(l=>n.indexOf(l)!==-1),o={...s,...t};for(const l of i){const c=Gi(s[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(r===oe.array&&a===oe.array){if(s.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<s.length;i++){const o=s[i],l=t[i],c=Gi(o,l);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===oe.date&&a===oe.date&&+s==+t?{valid:!0,data:s}:{valid:!1}}class _n extends Fe{_parse(t){const{status:r,ctx:a}=this._processInputParams(t),n=(i,o)=>{if(Al(i)||Al(o))return _e;const l=Gi(i.value,o.value);return l.valid?((Rl(i)||Rl(o))&&r.dirty(),{status:r.value,value:l.data}):(te(a,{code:U.invalid_intersection_types}),_e)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}_n.create=(s,t,r)=>new _n({left:s,right:t,typeName:Se.ZodIntersection,...Re(r)});class Cr extends Fe{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==oe.array)return te(a,{code:U.invalid_type,expected:oe.array,received:a.parsedType}),_e;if(a.data.length<this._def.items.length)return te(a,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_e;!this._def.rest&&a.data.length>this._def.items.length&&(te(a,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...a.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new tr(a,o,a.path,l)):null}).filter(o=>!!o);return a.common.async?Promise.all(i).then(o=>Mt.mergeArray(r,o)):Mt.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new Cr({...this._def,rest:t})}}Cr.create=(s,t)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Cr({items:s,typeName:Se.ZodTuple,rest:null,...Re(t)})};class $l extends Fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==oe.map)return te(a,{code:U.invalid_type,expected:oe.map,received:a.parsedType}),_e;const n=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([l,c],m)=>({key:n._parse(new tr(a,l,a.path,[m,"key"])),value:i._parse(new tr(a,c,a.path,[m,"value"]))}));if(a.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const m=await c.key,p=await c.value;if(m.status==="aborted"||p.status==="aborted")return _e;(m.status==="dirty"||p.status==="dirty")&&r.dirty(),l.set(m.value,p.value)}return{status:r.value,value:l}})}else{const l=new Map;for(const c of o){const m=c.key,p=c.value;if(m.status==="aborted"||p.status==="aborted")return _e;(m.status==="dirty"||p.status==="dirty")&&r.dirty(),l.set(m.value,p.value)}return{status:r.value,value:l}}}}$l.create=(s,t,r)=>new $l({valueType:t,keyType:s,typeName:Se.ZodMap,...Re(r)});class qa extends Fe{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==oe.set)return te(a,{code:U.invalid_type,expected:oe.set,received:a.parsedType}),_e;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(te(a,{code:U.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(te(a,{code:U.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const i=this._def.valueType;function o(c){const m=new Set;for(const p of c){if(p.status==="aborted")return _e;p.status==="dirty"&&r.dirty(),m.add(p.value)}return{status:r.value,value:m}}const l=[...a.data.values()].map((c,m)=>i._parse(new tr(a,c,a.path,m)));return a.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,r){return new qa({...this._def,minSize:{value:t,message:ce.toString(r)}})}max(t,r){return new qa({...this._def,maxSize:{value:t,message:ce.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}qa.create=(s,t)=>new qa({valueType:s,minSize:null,maxSize:null,typeName:Se.ZodSet,...Re(t)});class Bl extends Fe{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Bl.create=(s,t)=>new Bl({getter:s,typeName:Se.ZodLazy,...Re(t)});class Ul extends Fe{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return te(r,{received:r.data,code:U.invalid_literal,expected:this._def.value}),_e}return{status:"valid",value:t.data}}get value(){return this._def.value}}Ul.create=(s,t)=>new Ul({value:s,typeName:Se.ZodLiteral,...Re(t)});function mu(s,t){return new oa({values:s,typeName:Se.ZodEnum,...Re(t)})}class oa extends Fe{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),a=this._def.values;return te(r,{expected:qe.joinValues(a),received:r.parsedType,code:U.invalid_type}),_e}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),a=this._def.values;return te(r,{received:r.data,code:U.invalid_enum_value,options:a}),_e}return Ht(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return oa.create(t,{...this._def,...r})}exclude(t,r=this._def){return oa.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}}oa.create=mu;class Hl extends Fe{_parse(t){const r=qe.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==oe.string&&a.parsedType!==oe.number){const n=qe.objectValues(r);return te(a,{expected:qe.joinValues(n),received:a.parsedType,code:U.invalid_type}),_e}if(this._cache||(this._cache=new Set(qe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const n=qe.objectValues(r);return te(a,{received:a.data,code:U.invalid_enum_value,options:n}),_e}return Ht(t.data)}get enum(){return this._def.values}}Hl.create=(s,t)=>new Hl({values:s,typeName:Se.ZodNativeEnum,...Re(t)});class Sn extends Fe{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==oe.promise&&r.common.async===!1)return te(r,{code:U.invalid_type,expected:oe.promise,received:r.parsedType}),_e;const a=r.parsedType===oe.promise?r.data:Promise.resolve(r.data);return Ht(a.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Sn.create=(s,t)=>new Sn({type:s,typeName:Se.ZodPromise,...Re(t)});class la extends Fe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Se.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:a}=this._processInputParams(t),n=this._def.effect||null,i={addIssue:o=>{te(a,o),o.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){const o=n.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return _e;const c=await this._def.schema._parseAsync({data:l,path:a.path,parent:a});return c.status==="aborted"?_e:c.status==="dirty"||r.value==="dirty"?Ta(c.value):c});{if(r.value==="aborted")return _e;const l=this._def.schema._parseSync({data:o,path:a.path,parent:a});return l.status==="aborted"?_e:l.status==="dirty"||r.value==="dirty"?Ta(l.value):l}}if(n.type==="refinement"){const o=l=>{const c=n.refinement(l,i);if(a.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(a.common.async===!1){const l=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return l.status==="aborted"?_e:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(l=>l.status==="aborted"?_e:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(n.type==="transform")if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!ia(o))return _e;const l=n.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>ia(o)?Promise.resolve(n.transform(o.value,i)).then(l=>({status:r.value,value:l})):_e);qe.assertNever(n)}}la.create=(s,t,r)=>new la({schema:s,typeName:Se.ZodEffects,effect:t,...Re(r)});la.createWithPreprocess=(s,t,r)=>new la({schema:t,effect:{type:"preprocess",transform:s},typeName:Se.ZodEffects,...Re(r)});class er extends Fe{_parse(t){return this._getType(t)===oe.undefined?Ht(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}er.create=(s,t)=>new er({innerType:s,typeName:Se.ZodOptional,...Re(t)});class ca extends Fe{_parse(t){return this._getType(t)===oe.null?Ht(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ca.create=(s,t)=>new ca({innerType:s,typeName:Se.ZodNullable,...Re(t)});class Yi extends Fe{_parse(t){const{ctx:r}=this._processInputParams(t);let a=r.data;return r.parsedType===oe.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Yi.create=(s,t)=>new Yi({innerType:s,typeName:Se.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Re(t)});class Qi extends Fe{_parse(t){const{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return jn(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Rs(a.common.issues)},input:a.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Rs(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Qi.create=(s,t)=>new Qi({innerType:s,typeName:Se.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Re(t)});class Vl extends Fe{_parse(t){if(this._getType(t)!==oe.nan){const a=this._getOrReturnCtx(t);return te(a,{code:U.invalid_type,expected:oe.nan,received:a.parsedType}),_e}return{status:"valid",value:t.data}}}Vl.create=s=>new Vl({typeName:Se.ZodNaN,...Re(s)});class eb extends Fe{_parse(t){const{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class Mo extends Fe{_parse(t){const{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?_e:i.status==="dirty"?(r.dirty(),Ta(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?_e:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(t,r){return new Mo({in:t,out:r,typeName:Se.ZodPipeline})}}class Zi extends Fe{_parse(t){const r=this._def.innerType._parse(t),a=n=>(ia(n)&&(n.value=Object.freeze(n.value)),n);return jn(r)?r.then(n=>a(n)):a(r)}unwrap(){return this._def.innerType}}Zi.create=(s,t)=>new Zi({innerType:s,typeName:Se.ZodReadonly,...Re(t)});var Se;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(Se||(Se={}));const da=Js.create;sr.create;ps.create;const Io=ot.create;Nn.create;_n.create;Cr.create;oa.create;Sn.create;er.create;ca.create;const tb=Io({email:da().email("Please enter a valid email address"),password:da().min(6,"Password must be at least 6 characters")}),sb=()=>{const s=ns(),{user:t,isLoading:r,isAdmin:a,signIn:n,signUp:i}=Bt(),[o,l]=d.useState(""),[c,m]=d.useState(""),[p,x]=d.useState(!1),[g,u]=d.useState({});d.useEffect(()=>{t&&!r&&s(a?"/admin":"/")},[t,r,a,s]);const y=()=>{const b=tb.safeParse({email:o,password:c});if(!b.success){const v={};return b.error.errors.forEach(j=>{j.path[0]==="email"&&(v.email=j.message),j.path[0]==="password"&&(v.password=j.message)}),u(v),!1}return u({}),!0},h=async b=>{if(b.preventDefault(),!y())return;x(!0);const{error:v}=await n(o,c);x(!1),v?v.message.includes("Invalid login credentials")?C.error("Invalid email or password"):v.message.includes("Email not confirmed")?C.warning("Email not confirmed. Please check your inbox for a verification link.",{duration:8e3,description:"Check your spam folder if you don't see it."}):C.error(v.message):(C.success("Welcome back!"),s("/"))},f=async b=>{if(b.preventDefault(),!y())return;x(!0);const{error:v}=await i(o,c);x(!1),v?v.message.includes("already registered")?C.error("This email is already registered. Please sign in instead."):v.message.includes("Email not confirmed")?C.info("Please check your email for a confirmation link to verify your account.",{duration:8e3,description:"A verification email has been sent to "+o}):C.error(v.message):C.success("Account created! Please check your email for a confirmation link.",{duration:8e3,description:"We've sent a verification email to "+o})};return r?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center py-12",children:e.jsx("div",{className:"container max-w-md",children:e.jsxs(X,{className:"border-border/50",children:[e.jsxs(ye,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary",children:e.jsx(ft,{className:"h-6 w-6 text-primary-foreground"})}),e.jsx(be,{className:"text-2xl",children:"Welcome to Moenviron"}),e.jsx(Be,{children:"Sign in to track your orders and impact"})]}),e.jsxs(ee,{children:[e.jsxs(Ir,{defaultValue:"signin",className:"w-full",children:[e.jsxs(ar,{className:"grid w-full grid-cols-2",children:[e.jsx(Ye,{value:"signin",children:"Sign In"}),e.jsx(Ye,{value:"signup",children:"Sign Up"})]}),e.jsx($e,{value:"signin",children:e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"signin-email",children:"Email"}),e.jsx(Q,{id:"signin-email",type:"email",value:o,onChange:b=>l(b.target.value),placeholder:"you@example.com",disabled:p}),g.email&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:g.email})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"signin-password",children:"Password"}),e.jsx(Q,{id:"signin-password",type:"password",value:c,onChange:b=>m(b.target.value),placeholder:"••••••••",disabled:p}),g.password&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:g.password})]}),e.jsx(R,{type:"submit",className:"w-full",disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})}),e.jsx($e,{value:"signup",children:e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"signup-email",children:"Email"}),e.jsx(Q,{id:"signup-email",type:"email",value:o,onChange:b=>l(b.target.value),placeholder:"you@example.com",disabled:p}),g.email&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:g.email})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"signup-password",children:"Password"}),e.jsx(Q,{id:"signup-password",type:"password",value:c,onChange:b=>m(b.target.value),placeholder:"••••••••",disabled:p}),g.password&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:g.password})]}),e.jsx(R,{type:"submit",className:"w-full",disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]}),e.jsx("div",{className:"mt-6 text-center border-t pt-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Are you an administrator?"," ",e.jsx(R,{variant:"link",className:"p-0 h-auto",onClick:()=>s("/admin-login"),children:"Admin Sign In"})]})})]})]})})}),e.jsx(We,{})]})},rb=Wa("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ur=d.forwardRef(({className:s,variant:t,...r},a)=>e.jsx("div",{ref:a,role:"alert",className:me(rb({variant:t}),s),...r}));Ur.displayName="Alert";const cn=d.forwardRef(({className:s,...t},r)=>e.jsx("h5",{ref:r,className:me("mb-1 font-medium leading-none tracking-tight",s),...t}));cn.displayName="AlertTitle";const Hr=d.forwardRef(({className:s,...t},r)=>e.jsx("div",{ref:r,className:me("text-sm [&_p]:leading-relaxed",s),...t}));Hr.displayName="AlertDescription";const ab=Io({email:da().email("Please enter a valid email address"),password:da().min(6,"Password must be at least 6 characters")}),nb=()=>{const s=ns(),{user:t,isLoading:r,isAdmin:a,signIn:n}=Bt(),[i,o]=d.useState(""),[l,c]=d.useState(""),[m,p]=d.useState(!1),[x,g]=d.useState({}),[u,y]=d.useState(null);d.useEffect(()=>{t&&!r&&a&&s("/admin")},[t,r,a,s]);const h=()=>{const b=ab.safeParse({email:i,password:l});if(!b.success){const v={};return b.error.errors.forEach(j=>{j.path[0]==="email"&&(v.email=j.message),j.path[0]==="password"&&(v.password=j.message)}),g(v),!1}return g({}),!0},f=async b=>{if(b.preventDefault(),!h())return;p(!0),y(null);const{error:v}=await n(i,l);if(v){p(!1),v.message.includes("Invalid login credentials")?y("Invalid email or password"):y(v.message);return}const{data:j}=await M.auth.getUser();if(j.user){const{data:_}=await M.from("user_roles").select("role").eq("user_id",j.user.id).in("role",["admin","marketing","shipping","support","content"]).maybeSingle();_?(C.success("Welcome, Admin!"),s("/admin")):(await M.auth.signOut(),y("Access denied. This account does not have admin privileges."))}p(!1)};return r?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center py-12",children:e.jsx("div",{className:"container max-w-md",children:e.jsxs(X,{className:"border-border/50",children:[e.jsxs(ye,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary",children:e.jsx(Nr,{className:"h-6 w-6 text-primary-foreground"})}),e.jsx(be,{className:"text-2xl",children:"Admin Portal"}),e.jsx(Be,{children:"Sign in with your administrator credentials"})]}),e.jsxs(ee,{children:[u&&e.jsxs(Ur,{variant:"destructive",className:"mb-4",children:[e.jsx(po,{className:"h-4 w-4"}),e.jsx(Hr,{children:u})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"admin-email",children:"Email"}),e.jsx(Q,{id:"admin-email",type:"email",value:i,onChange:b=>o(b.target.value),placeholder:"admin@example.com",disabled:m}),x.email&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:x.email})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"admin-password",children:"Password"}),e.jsx(Q,{id:"admin-password",type:"password",value:l,onChange:b=>c(b.target.value),placeholder:"••••••••",disabled:m}),x.password&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:x.password})]}),e.jsx(R,{type:"submit",className:"w-full",disabled:m,children:m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In as Admin"})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Not an admin?"," ",e.jsx(R,{variant:"link",className:"p-0 h-auto",onClick:()=>s("/auth"),children:"Sign in as customer"})]})})]})]})})}),e.jsx(We,{})]})};function Ji({onUpload:s,currentUrl:t,label:r="Image"}){const[a,n]=d.useState(!1),[i,o]=d.useState(t||null),[l,c]=d.useState(t||null),[m,p]=d.useState(!1),x=d.useCallback(async h=>{var b;const f=(b=h.target.files)==null?void 0:b[0];if(f){if(!f.type.startsWith("image/")){C.error("Please select an image file");return}if(f.size>5*1024*1024){C.error("Image must be less than 5MB");return}n(!0),o(URL.createObjectURL(f));try{const v=f.name.split(".").pop(),_=`uploads/${`${Date.now()}-${Math.random().toString(36).substring(7)}.${v}`}`,{error:I}=await M.storage.from("site-assets").upload(_,f);if(I)throw I;const{data:{publicUrl:E}}=M.storage.from("site-assets").getPublicUrl(_);c(E),s==null||s(E),C.success("Image uploaded successfully!")}catch(v){console.error("Upload error:",v),C.error("Failed to upload image"),o(null)}finally{n(!1)}}},[s]),g=d.useCallback(h=>{var b;h.preventDefault();const f=(b=h.dataTransfer.files)==null?void 0:b[0];if(f){const v=document.createElement("input");v.type="file";const j=new DataTransfer;j.items.add(f),v.files=j.files,x({target:v})}},[x]),u=()=>{l&&(navigator.clipboard.writeText(l),p(!0),setTimeout(()=>p(!1),2e3),C.success("URL copied to clipboard"))},y=()=>{o(null),c(null),s==null||s("")};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{children:r}),e.jsx("div",{onDrop:g,onDragOver:h=>h.preventDefault(),className:`relative rounded-lg border-2 border-dashed transition-colors ${a?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:i?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:i,alt:"Preview",className:"h-40 w-full rounded-lg object-cover"}),e.jsx(R,{type:"button",variant:"destructive",size:"icon",className:"absolute right-2 top-2 h-8 w-8",onClick:y,children:e.jsx(Dn,{className:"h-4 w-4"})}),a&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-background/80",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})})]}):e.jsxs("label",{className:"flex cursor-pointer flex-col items-center gap-2 p-8",children:[e.jsx("div",{className:"rounded-full bg-muted p-3",children:e.jsx(op,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Click to upload or drag and drop"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, JPG, WebP up to 5MB"}),e.jsx(Q,{type:"file",accept:"image/*",onChange:x,className:"hidden"})]})}),l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{value:l,readOnly:!0,className:"flex-1 text-xs"}),e.jsx(R,{type:"button",variant:"outline",size:"icon",onClick:u,children:m?e.jsx(pn,{className:"h-4 w-4"}):e.jsx(fn,{className:"h-4 w-4"})})]})]})}function Xi(s,[t,r]){return Math.min(r,Math.max(t,s))}function ib(s){const t=ob(s),r=d.forwardRef((a,n)=>{const{children:i,...o}=a,l=d.Children.toArray(i),c=l.find(cb);if(c){const m=c.props.children,p=l.map(x=>x===c?d.Children.count(m)>1?d.Children.only(null):d.isValidElement(m)?m.props.children:null:x);return e.jsx(t,{...o,ref:n,children:d.isValidElement(m)?d.cloneElement(m,void 0,p):null})}return e.jsx(t,{...o,ref:n,children:i})});return r.displayName=`${s}.Slot`,r}function ob(s){const t=d.forwardRef((r,a)=>{const{children:n,...i}=r;if(d.isValidElement(n)){const o=ub(n),l=db(i,n.props);return n.type!==d.Fragment&&(l.ref=a?Pc(a,o):o),d.cloneElement(n,l)}return d.Children.count(n)>1?d.Children.only(null):null});return t.displayName=`${s}.SlotClone`,t}var lb=Symbol("radix.slottable");function cb(s){return d.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===lb}function db(s,t){const r={...t};for(const a in t){const n=s[a],i=t[a];/^on[A-Z]/.test(a)?n&&i?r[a]=(...l)=>{const c=i(...l);return n(...l),c}:n&&(r[a]=n):a==="style"?r[a]={...n,...i}:a==="className"&&(r[a]=[n,i].filter(Boolean).join(" "))}return{...s,...r}}function ub(s){var a,n;let t=(a=Object.getOwnPropertyDescriptor(s.props,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?s.ref:(t=(n=Object.getOwnPropertyDescriptor(s,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?s.props.ref:s.props.ref||s.ref)}var mb=[" ","Enter","ArrowUp","ArrowDown"],hb=[" ","Enter"],Er="Select",[$n,Bn,pb]=Wm(Er),[ba]=pa(Er,[pb,Pn]),Un=Pn(),[fb,nr]=ba(Er),[xb,gb]=ba(Er),hu=s=>{const{__scopeSelect:t,children:r,open:a,defaultOpen:n,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:m,name:p,autoComplete:x,disabled:g,required:u,form:y}=s,h=Un(t),[f,b]=d.useState(null),[v,j]=d.useState(null),[_,I]=d.useState(!1),E=lo(m),[O,D]=un({prop:a,defaultProp:n??!1,onChange:i,caller:Er}),[N,T]=un({prop:o,defaultProp:l,onChange:c,caller:Er}),P=d.useRef(null),S=f?y||!!f.closest("form"):!0,[W,K]=d.useState(new Set),F=Array.from(W).map(k=>k.props.value).join(";");return e.jsx(Jm,{...h,children:e.jsxs(fb,{required:u,scope:t,trigger:f,onTriggerChange:b,valueNode:v,onValueNodeChange:j,valueNodeHasChildren:_,onValueNodeHasChildrenChange:I,contentId:co(),value:N,onValueChange:T,open:O,onOpenChange:D,dir:E,triggerPointerDownPosRef:P,disabled:g,children:[e.jsx($n.Provider,{scope:t,children:e.jsx(xb,{scope:s.__scopeSelect,onNativeOptionAdd:d.useCallback(k=>{K(A=>new Set(A).add(k))},[]),onNativeOptionRemove:d.useCallback(k=>{K(A=>{const q=new Set(A);return q.delete(k),q})},[]),children:r})}),S?e.jsxs(Lu,{"aria-hidden":!0,required:u,tabIndex:-1,name:p,autoComplete:x,value:N,onChange:k=>T(k.target.value),disabled:g,form:y,children:[N===void 0?e.jsx("option",{value:""}):null,Array.from(W)]},F):null]})})};hu.displayName=Er;var pu="SelectTrigger",fu=d.forwardRef((s,t)=>{const{__scopeSelect:r,disabled:a=!1,...n}=s,i=Un(r),o=nr(pu,r),l=o.disabled||a,c=rt(t,o.onTriggerChange),m=Bn(r),p=d.useRef("touch"),[x,g,u]=qu(h=>{const f=m().filter(j=>!j.disabled),b=f.find(j=>j.value===o.value),v=zu(f,h,b);v!==void 0&&o.onValueChange(v.value)}),y=h=>{l||(o.onOpenChange(!0),u()),h&&(o.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return e.jsx(Ec,{asChild:!0,...i,children:e.jsx(Xe.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Fu(o.value)?"":void 0,...n,ref:c,onClick:De(n.onClick,h=>{h.currentTarget.focus(),p.current!=="mouse"&&y(h)}),onPointerDown:De(n.onPointerDown,h=>{p.current=h.pointerType;const f=h.target;f.hasPointerCapture(h.pointerId)&&f.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(y(h),h.preventDefault())}),onKeyDown:De(n.onKeyDown,h=>{const f=x.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&g(h.key),!(f&&h.key===" ")&&mb.includes(h.key)&&(y(),h.preventDefault())})})})});fu.displayName=pu;var xu="SelectValue",gu=d.forwardRef((s,t)=>{const{__scopeSelect:r,className:a,style:n,children:i,placeholder:o="",...l}=s,c=nr(xu,r),{onValueNodeHasChildrenChange:m}=c,p=i!==void 0,x=rt(t,c.onValueNodeChange);return $t(()=>{m(p)},[m,p]),e.jsx(Xe.span,{...l,ref:x,style:{pointerEvents:"none"},children:Fu(c.value)?e.jsx(e.Fragment,{children:o}):i})});gu.displayName=xu;var yb="SelectIcon",yu=d.forwardRef((s,t)=>{const{__scopeSelect:r,children:a,...n}=s;return e.jsx(Xe.span,{"aria-hidden":!0,...n,ref:t,children:a||"▼"})});yu.displayName=yb;var bb="SelectPortal",bu=s=>e.jsx(Km,{asChild:!0,...s});bu.displayName=bb;var Tr="SelectContent",vu=d.forwardRef((s,t)=>{const r=nr(Tr,s.__scopeSelect),[a,n]=d.useState();if($t(()=>{n(new DocumentFragment)},[]),!r.open){const i=a;return i?$c.createPortal(e.jsx(ju,{scope:s.__scopeSelect,children:e.jsx($n.Slot,{scope:s.__scopeSelect,children:e.jsx("div",{children:s.children})})}),i):null}return e.jsx(wu,{...s,ref:t})});vu.displayName=Tr;var Jt=10,[ju,ir]=ba(Tr),vb="SelectContentImpl",jb=ib("SelectContent.RemoveScroll"),wu=d.forwardRef((s,t)=>{const{__scopeSelect:r,position:a="item-aligned",onCloseAutoFocus:n,onEscapeKeyDown:i,onPointerDownOutside:o,side:l,sideOffset:c,align:m,alignOffset:p,arrowPadding:x,collisionBoundary:g,collisionPadding:u,sticky:y,hideWhenDetached:h,avoidCollisions:f,...b}=s,v=nr(Tr,r),[j,_]=d.useState(null),[I,E]=d.useState(null),O=rt(t,Z=>_(Z)),[D,N]=d.useState(null),[T,P]=d.useState(null),S=Bn(r),[W,K]=d.useState(!1),F=d.useRef(!1);d.useEffect(()=>{if(j)return Gm(j)},[j]),Ym();const k=d.useCallback(Z=>{const[ze,...V]=S().map(Ce=>Ce.ref.current),[je]=V.slice(-1),xe=document.activeElement;for(const Ce of Z)if(Ce===xe||(Ce==null||Ce.scrollIntoView({block:"nearest"}),Ce===ze&&I&&(I.scrollTop=0),Ce===je&&I&&(I.scrollTop=I.scrollHeight),Ce==null||Ce.focus(),document.activeElement!==xe))return},[S,I]),A=d.useCallback(()=>k([D,j]),[k,D,j]);d.useEffect(()=>{W&&A()},[W,A]);const{onOpenChange:q,triggerPointerDownPosRef:re}=v;d.useEffect(()=>{if(j){let Z={x:0,y:0};const ze=je=>{var xe,Ce;Z={x:Math.abs(Math.round(je.pageX)-(((xe=re.current)==null?void 0:xe.x)??0)),y:Math.abs(Math.round(je.pageY)-(((Ce=re.current)==null?void 0:Ce.y)??0))}},V=je=>{Z.x<=10&&Z.y<=10?je.preventDefault():j.contains(je.target)||q(!1),document.removeEventListener("pointermove",ze),re.current=null};return re.current!==null&&(document.addEventListener("pointermove",ze),document.addEventListener("pointerup",V,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ze),document.removeEventListener("pointerup",V,{capture:!0})}}},[j,q,re]),d.useEffect(()=>{const Z=()=>q(!1);return window.addEventListener("blur",Z),window.addEventListener("resize",Z),()=>{window.removeEventListener("blur",Z),window.removeEventListener("resize",Z)}},[q]);const[$,Te]=qu(Z=>{const ze=S().filter(xe=>!xe.disabled),V=ze.find(xe=>xe.ref.current===document.activeElement),je=zu(ze,Z,V);je&&setTimeout(()=>je.ref.current.focus())}),fe=d.useCallback((Z,ze,V)=>{const je=!F.current&&!V;(v.value!==void 0&&v.value===ze||je)&&(N(Z),je&&(F.current=!0))},[v.value]),we=d.useCallback(()=>j==null?void 0:j.focus(),[j]),ke=d.useCallback((Z,ze,V)=>{const je=!F.current&&!V;(v.value!==void 0&&v.value===ze||je)&&P(Z)},[v.value]),Ze=a==="popper"?eo:Nu,st=Ze===eo?{side:l,sideOffset:c,align:m,alignOffset:p,arrowPadding:x,collisionBoundary:g,collisionPadding:u,sticky:y,hideWhenDetached:h,avoidCollisions:f}:{};return e.jsx(ju,{scope:r,content:j,viewport:I,onViewportChange:E,itemRefCallback:fe,selectedItem:D,onItemLeave:we,itemTextRefCallback:ke,focusSelectedItem:A,selectedItemText:T,position:a,isPositioned:W,searchRef:$,children:e.jsx(Qm,{as:jb,allowPinchZoom:!0,children:e.jsx(Zm,{asChild:!0,trapped:v.open,onMountAutoFocus:Z=>{Z.preventDefault()},onUnmountAutoFocus:De(n,Z=>{var ze;(ze=v.trigger)==null||ze.focus({preventScroll:!0}),Z.preventDefault()}),children:e.jsx(kc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:Z=>Z.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:e.jsx(Ze,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:Z=>Z.preventDefault(),...b,...st,onPlaced:()=>K(!0),ref:O,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:De(b.onKeyDown,Z=>{const ze=Z.ctrlKey||Z.altKey||Z.metaKey;if(Z.key==="Tab"&&Z.preventDefault(),!ze&&Z.key.length===1&&Te(Z.key),["ArrowUp","ArrowDown","Home","End"].includes(Z.key)){let je=S().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);if(["ArrowUp","End"].includes(Z.key)&&(je=je.slice().reverse()),["ArrowUp","ArrowDown"].includes(Z.key)){const xe=Z.target,Ce=je.indexOf(xe);je=je.slice(Ce+1)}setTimeout(()=>k(je)),Z.preventDefault()}})})})})})})});wu.displayName=vb;var wb="SelectItemAlignedPosition",Nu=d.forwardRef((s,t)=>{const{__scopeSelect:r,onPlaced:a,...n}=s,i=nr(Tr,r),o=ir(Tr,r),[l,c]=d.useState(null),[m,p]=d.useState(null),x=rt(t,O=>p(O)),g=Bn(r),u=d.useRef(!1),y=d.useRef(!0),{viewport:h,selectedItem:f,selectedItemText:b,focusSelectedItem:v}=o,j=d.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&m&&h&&f&&b){const O=i.trigger.getBoundingClientRect(),D=m.getBoundingClientRect(),N=i.valueNode.getBoundingClientRect(),T=b.getBoundingClientRect();if(i.dir!=="rtl"){const xe=T.left-D.left,Ce=N.left-xe,xt=O.left-Ce,ut=O.width+xt,Wt=Math.max(ut,D.width),L=window.innerWidth-Jt,ge=Xi(Ce,[Jt,Math.max(Jt,L-Wt)]);l.style.minWidth=ut+"px",l.style.left=ge+"px"}else{const xe=D.right-T.right,Ce=window.innerWidth-N.right-xe,xt=window.innerWidth-O.right-Ce,ut=O.width+xt,Wt=Math.max(ut,D.width),L=window.innerWidth-Jt,ge=Xi(Ce,[Jt,Math.max(Jt,L-Wt)]);l.style.minWidth=ut+"px",l.style.right=ge+"px"}const P=g(),S=window.innerHeight-Jt*2,W=h.scrollHeight,K=window.getComputedStyle(m),F=parseInt(K.borderTopWidth,10),k=parseInt(K.paddingTop,10),A=parseInt(K.borderBottomWidth,10),q=parseInt(K.paddingBottom,10),re=F+k+W+q+A,$=Math.min(f.offsetHeight*5,re),Te=window.getComputedStyle(h),fe=parseInt(Te.paddingTop,10),we=parseInt(Te.paddingBottom,10),ke=O.top+O.height/2-Jt,Ze=S-ke,st=f.offsetHeight/2,Z=f.offsetTop+st,ze=F+k+Z,V=re-ze;if(ze<=ke){const xe=P.length>0&&f===P[P.length-1].ref.current;l.style.bottom="0px";const Ce=m.clientHeight-h.offsetTop-h.offsetHeight,xt=Math.max(Ze,st+(xe?we:0)+Ce+A),ut=ze+xt;l.style.height=ut+"px"}else{const xe=P.length>0&&f===P[0].ref.current;l.style.top="0px";const xt=Math.max(ke,F+h.offsetTop+(xe?fe:0)+st)+V;l.style.height=xt+"px",h.scrollTop=ze-ke+h.offsetTop}l.style.margin=`${Jt}px 0`,l.style.minHeight=$+"px",l.style.maxHeight=S+"px",a==null||a(),requestAnimationFrame(()=>u.current=!0)}},[g,i.trigger,i.valueNode,l,m,h,f,b,i.dir,a]);$t(()=>j(),[j]);const[_,I]=d.useState();$t(()=>{m&&I(window.getComputedStyle(m).zIndex)},[m]);const E=d.useCallback(O=>{O&&y.current===!0&&(j(),v==null||v(),y.current=!1)},[j,v]);return e.jsx(_b,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:u,onScrollButtonChange:E,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:e.jsx(Xe.div,{...n,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...n.style}})})})});Nu.displayName=wb;var Nb="SelectPopperPosition",eo=d.forwardRef((s,t)=>{const{__scopeSelect:r,align:a="start",collisionPadding:n=Jt,...i}=s,o=Un(r);return e.jsx(Cc,{...o,...i,ref:t,align:a,collisionPadding:n,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});eo.displayName=Nb;var[_b,Oo]=ba(Tr,{}),to="SelectViewport",_u=d.forwardRef((s,t)=>{const{__scopeSelect:r,nonce:a,...n}=s,i=ir(to,r),o=Oo(to,r),l=rt(t,i.onViewportChange),c=d.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx($n.Slot,{scope:r,children:e.jsx(Xe.div,{"data-radix-select-viewport":"",role:"presentation",...n,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...n.style},onScroll:De(n.onScroll,m=>{const p=m.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:g}=o;if(g!=null&&g.current&&x){const u=Math.abs(c.current-p.scrollTop);if(u>0){const y=window.innerHeight-Jt*2,h=parseFloat(x.style.minHeight),f=parseFloat(x.style.height),b=Math.max(h,f);if(b<y){const v=b+u,j=Math.min(y,v),_=v-j;x.style.height=j+"px",x.style.bottom==="0px"&&(p.scrollTop=_>0?_:0,x.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});_u.displayName=to;var Su="SelectGroup",[Sb,kb]=ba(Su),Cb=d.forwardRef((s,t)=>{const{__scopeSelect:r,...a}=s,n=co();return e.jsx(Sb,{scope:r,id:n,children:e.jsx(Xe.div,{role:"group","aria-labelledby":n,...a,ref:t})})});Cb.displayName=Su;var ku="SelectLabel",Cu=d.forwardRef((s,t)=>{const{__scopeSelect:r,...a}=s,n=kb(ku,r);return e.jsx(Xe.div,{id:n.id,...a,ref:t})});Cu.displayName=ku;var kn="SelectItem",[Eb,Eu]=ba(kn),Tu=d.forwardRef((s,t)=>{const{__scopeSelect:r,value:a,disabled:n=!1,textValue:i,...o}=s,l=nr(kn,r),c=ir(kn,r),m=l.value===a,[p,x]=d.useState(i??""),[g,u]=d.useState(!1),y=rt(t,v=>{var j;return(j=c.itemRefCallback)==null?void 0:j.call(c,v,a,n)}),h=co(),f=d.useRef("touch"),b=()=>{n||(l.onValueChange(a),l.onOpenChange(!1))};if(a==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(Eb,{scope:r,value:a,disabled:n,textId:h,isSelected:m,onItemTextChange:d.useCallback(v=>{x(j=>j||((v==null?void 0:v.textContent)??"").trim())},[]),children:e.jsx($n.ItemSlot,{scope:r,value:a,disabled:n,textValue:p,children:e.jsx(Xe.div,{role:"option","aria-labelledby":h,"data-highlighted":g?"":void 0,"aria-selected":m&&g,"data-state":m?"checked":"unchecked","aria-disabled":n||void 0,"data-disabled":n?"":void 0,tabIndex:n?void 0:-1,...o,ref:y,onFocus:De(o.onFocus,()=>u(!0)),onBlur:De(o.onBlur,()=>u(!1)),onClick:De(o.onClick,()=>{f.current!=="mouse"&&b()}),onPointerUp:De(o.onPointerUp,()=>{f.current==="mouse"&&b()}),onPointerDown:De(o.onPointerDown,v=>{f.current=v.pointerType}),onPointerMove:De(o.onPointerMove,v=>{var j;f.current=v.pointerType,n?(j=c.onItemLeave)==null||j.call(c):f.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:De(o.onPointerLeave,v=>{var j;v.currentTarget===document.activeElement&&((j=c.onItemLeave)==null||j.call(c))}),onKeyDown:De(o.onKeyDown,v=>{var _;((_=c.searchRef)==null?void 0:_.current)!==""&&v.key===" "||(hb.includes(v.key)&&b(),v.key===" "&&v.preventDefault())})})})})});Tu.displayName=kn;var Pa="SelectItemText",Pu=d.forwardRef((s,t)=>{const{__scopeSelect:r,className:a,style:n,...i}=s,o=nr(Pa,r),l=ir(Pa,r),c=Eu(Pa,r),m=gb(Pa,r),[p,x]=d.useState(null),g=rt(t,b=>x(b),c.onItemTextChange,b=>{var v;return(v=l.itemTextRefCallback)==null?void 0:v.call(l,b,c.value,c.disabled)}),u=p==null?void 0:p.textContent,y=d.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:u},c.value),[c.disabled,c.value,u]),{onNativeOptionAdd:h,onNativeOptionRemove:f}=m;return $t(()=>(h(y),()=>f(y)),[h,f,y]),e.jsxs(e.Fragment,{children:[e.jsx(Xe.span,{id:c.textId,...i,ref:g}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?$c.createPortal(i.children,o.valueNode):null]})});Pu.displayName=Pa;var Au="SelectItemIndicator",Ru=d.forwardRef((s,t)=>{const{__scopeSelect:r,...a}=s;return Eu(Au,r).isSelected?e.jsx(Xe.span,{"aria-hidden":!0,...a,ref:t}):null});Ru.displayName=Au;var so="SelectScrollUpButton",Mu=d.forwardRef((s,t)=>{const r=ir(so,s.__scopeSelect),a=Oo(so,s.__scopeSelect),[n,i]=d.useState(!1),o=rt(t,a.onScrollButtonChange);return $t(()=>{if(r.viewport&&r.isPositioned){let l=function(){const m=c.scrollTop>0;i(m)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),n?e.jsx(Ou,{...s,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Mu.displayName=so;var ro="SelectScrollDownButton",Iu=d.forwardRef((s,t)=>{const r=ir(ro,s.__scopeSelect),a=Oo(ro,s.__scopeSelect),[n,i]=d.useState(!1),o=rt(t,a.onScrollButtonChange);return $t(()=>{if(r.viewport&&r.isPositioned){let l=function(){const m=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)<m;i(p)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),n?e.jsx(Ou,{...s,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Iu.displayName=ro;var Ou=d.forwardRef((s,t)=>{const{__scopeSelect:r,onAutoScroll:a,...n}=s,i=ir("SelectScrollButton",r),o=d.useRef(null),l=Bn(r),c=d.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return d.useEffect(()=>()=>c(),[c]),$t(()=>{var p;const m=l().find(x=>x.ref.current===document.activeElement);(p=m==null?void 0:m.ref.current)==null||p.scrollIntoView({block:"nearest"})},[l]),e.jsx(Xe.div,{"aria-hidden":!0,...n,ref:t,style:{flexShrink:0,...n.style},onPointerDown:De(n.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(a,50))}),onPointerMove:De(n.onPointerMove,()=>{var m;(m=i.onItemLeave)==null||m.call(i),o.current===null&&(o.current=window.setInterval(a,50))}),onPointerLeave:De(n.onPointerLeave,()=>{c()})})}),Tb="SelectSeparator",Du=d.forwardRef((s,t)=>{const{__scopeSelect:r,...a}=s;return e.jsx(Xe.div,{"aria-hidden":!0,...a,ref:t})});Du.displayName=Tb;var ao="SelectArrow",Pb=d.forwardRef((s,t)=>{const{__scopeSelect:r,...a}=s,n=Un(r),i=nr(ao,r),o=ir(ao,r);return i.open&&o.position==="popper"?e.jsx(Tc,{...n,...a,ref:t}):null});Pb.displayName=ao;var Ab="SelectBubbleInput",Lu=d.forwardRef(({__scopeSelect:s,value:t,...r},a)=>{const n=d.useRef(null),i=rt(a,n),o=Po(t);return d.useEffect(()=>{const l=n.current;if(!l)return;const c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&p){const x=new Event("change",{bubbles:!0});p.call(l,t),l.dispatchEvent(x)}},[o,t]),e.jsx(Xe.select,{...r,style:{...Xm,...r.style},ref:i,defaultValue:t})});Lu.displayName=Ab;function Fu(s){return s===""||s===void 0}function qu(s){const t=Es(s),r=d.useRef(""),a=d.useRef(0),n=d.useCallback(o=>{const l=r.current+o;t(l),(function c(m){r.current=m,window.clearTimeout(a.current),m!==""&&(a.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),i=d.useCallback(()=>{r.current="",window.clearTimeout(a.current)},[]);return d.useEffect(()=>()=>window.clearTimeout(a.current),[]),[r,n,i]}function zu(s,t,r){const n=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,i=r?s.indexOf(r):-1;let o=Rb(s,Math.max(i,0));n.length===1&&(o=o.filter(m=>m!==r));const c=o.find(m=>m.textValue.toLowerCase().startsWith(n.toLowerCase()));return c!==r?c:void 0}function Rb(s,t){return s.map((r,a)=>s[(t+a)%s.length])}var Mb=hu,$u=fu,Ib=gu,Ob=yu,Db=bu,Bu=vu,Lb=_u,Uu=Cu,Hu=Tu,Fb=Pu,qb=Ru,Vu=Mu,Wu=Iu,Ku=Du;const ua=Mb,ma=Ib,Pr=d.forwardRef(({className:s,children:t,...r},a)=>e.jsxs($u,{ref:a,className:me("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...r,children:[t,e.jsx(Ob,{asChild:!0,children:e.jsx(Kc,{className:"h-4 w-4 opacity-50"})})]}));Pr.displayName=$u.displayName;const Gu=d.forwardRef(({className:s,...t},r)=>e.jsx(Vu,{ref:r,className:me("flex cursor-default items-center justify-center py-1",s),...t,children:e.jsx(Rh,{className:"h-4 w-4"})}));Gu.displayName=Vu.displayName;const Yu=d.forwardRef(({className:s,...t},r)=>e.jsx(Wu,{ref:r,className:me("flex cursor-default items-center justify-center py-1",s),...t,children:e.jsx(Kc,{className:"h-4 w-4"})}));Yu.displayName=Wu.displayName;const Ar=d.forwardRef(({className:s,children:t,position:r="popper",...a},n)=>e.jsx(Db,{children:e.jsxs(Bu,{ref:n,className:me("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:r,...a,children:[e.jsx(Gu,{}),e.jsx(Lb,{className:me("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(Yu,{})]})}));Ar.displayName=Bu.displayName;const zb=d.forwardRef(({className:s,...t},r)=>e.jsx(Uu,{ref:r,className:me("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...t}));zb.displayName=Uu.displayName;const nt=d.forwardRef(({className:s,children:t,...r},a)=>e.jsxs(Hu,{ref:a,className:me("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(qb,{children:e.jsx(pn,{className:"h-4 w-4"})})}),e.jsx(Fb,{children:t})]}));nt.displayName=Hu.displayName;const $b=d.forwardRef(({className:s,...t},r)=>e.jsx(Ku,{ref:r,className:me("-mx-1 my-1 h-px bg-muted",s),...t}));$b.displayName=Ku.displayName;const Bb={"home/hero":[{key:"badge",type:"text",label:"Hero Badge"},{key:"headline",type:"textarea",label:"Headline (HTML supported)"},{key:"subheadline",type:"textarea",label:"Subheadline"},{key:"cta_primary_text",type:"text",label:"Primary CTA Text"},{key:"cta_primary_link",type:"text",label:"Primary CTA Link"},{key:"cta_secondary_text",type:"text",label:"Secondary CTA Text"},{key:"cta_secondary_link",type:"text",label:"Secondary CTA Link"},{key:"video_url",type:"text",label:"Background Video URL"},{key:"poster_url",type:"image",label:"Video Poster Image"}],"home/impact-counter":[{key:"title",type:"text",label:"Section Title"},{key:"subtitle",type:"textarea",label:"Section Subtitle"},{key:"stats",type:"array",label:"Stats (JSON array of {value, label, icon})"}],"home/how-it-works":[{key:"title",type:"text",label:"Section Title"},{key:"subtitle",type:"textarea",label:"Section Subtitle"},{key:"steps",type:"array",label:"Steps (JSON array of {icon, title, description})"}],"home/impact-collage":[{key:"title",type:"text",label:"Section Title"},{key:"subtitle",type:"textarea",label:"Section Subtitle"},{key:"images",type:"array",label:"Images (JSON array of {url, title, subtitle, size})"}],"home/sdg-badges":[{key:"title",type:"text",label:"Section Title"},{key:"subtitle",type:"textarea",label:"Section Subtitle"},{key:"badges",type:"array",label:"Badges (JSON array of {number, title, color, description, icon})"}],"home/partner-cta":[{key:"title",type:"text",label:"Title"},{key:"description",type:"textarea",label:"Description"},{key:"cta_text",type:"text",label:"Button Text"},{key:"cta_link",type:"text",label:"Button Link"},{key:"image",type:"image",label:"Background Image"}],"home/features":[{key:"title",type:"text",label:"Section Title"},{key:"subtitle",type:"textarea",label:"Section Subtitle"},{key:"features",type:"array",label:"Features (JSON array of {icon, title, description})"}],"home/about":[{key:"title",type:"text",label:"Title"},{key:"description",type:"textarea",label:"Description"},{key:"image",type:"image",label:"About Image"}],"global/footer":[{key:"tagline",type:"textarea",label:"Footer Tagline"},{key:"address",type:"textarea",label:"Office Address"},{key:"email",type:"text",label:"Contact Email"},{key:"phone",type:"text",label:"Contact Phone"},{key:"social_links",type:"array",label:"Social Links (JSON array of {platform, url})"},{key:"copyright",type:"text",label:"Copyright Text"}],"global/settings":[{key:"siteName",type:"text",label:"Site Name"},{key:"logoUrl",type:"image",label:"Logo URL"},{key:"contactEmail",type:"text",label:"Contact Email"},{key:"contactPhone",type:"text",label:"Contact Phone"},{key:"address",type:"textarea",label:"Address"},{key:"footerText",type:"textarea",label:"Footer Tagline"}],"global/navigation":[{key:"links",type:"array",label:"Navigation Links (JSON array of {label, href})"}],"global/social":[{key:"facebook",type:"text",label:"Facebook URL"},{key:"instagram",type:"text",label:"Instagram URL"},{key:"twitter",type:"text",label:"Twitter/X URL"},{key:"linkedin",type:"text",label:"LinkedIn URL"},{key:"tiktok",type:"text",label:"TikTok URL"}],"global/seo":[{key:"title",type:"text",label:"Default Page Title"},{key:"description",type:"textarea",label:"Meta Description"},{key:"keywords",type:"text",label:"Keywords (comma separated)"}],"global/newsletter":[{key:"title",type:"text",label:"Newsletter Title"},{key:"subtitle",type:"textarea",label:"Newsletter Subtitle"},{key:"cta_text",type:"text",label:"Button Text"},{key:"discount_text",type:"text",label:"Discount/Incentive Text"}],"global/email-templates":[{key:"order_confirmation",type:"array",label:"Order Confirmation (JSON {subject, greeting})"},{key:"order_shipped",type:"array",label:"Order Shipped (JSON {subject, greeting})"},{key:"order_delivered",type:"array",label:"Order Delivered (JSON {subject, greeting})"},{key:"welcome",type:"array",label:"Welcome Email (JSON {subject, greeting})"}],"about/hero":[{key:"title",type:"text",label:"Page Title"},{key:"subtitle",type:"textarea",label:"Page Subtitle"}],"about/story":[{key:"title",type:"text",label:"Section Title"},{key:"content",type:"textarea",label:"Story Content"},{key:"image",type:"image",label:"Story Image"}],"about/team":[{key:"title",type:"text",label:"Section Title"},{key:"members",type:"array",label:"Team Members (JSON array of {name, role, image, bio})"}],"about/values":[{key:"title",type:"text",label:"Section Title"},{key:"values",type:"array",label:"Values (JSON array of {title, description})"}],"contact/hero":[{key:"title",type:"text",label:"Page Title"},{key:"subtitle",type:"textarea",label:"Page Subtitle"}],"contact/info":[{key:"email",type:"text",label:"Contact Email"},{key:"phone",type:"text",label:"Contact Phone"},{key:"address",type:"textarea",label:"Office Address"},{key:"hours",type:"text",label:"Business Hours"}],"shop/hero":[{key:"title",type:"text",label:"Page Title"},{key:"subtitle",type:"textarea",label:"Page Subtitle"}],"shop/categories":[{key:"title",type:"text",label:"Section Title"},{key:"categories",type:"array",label:"Categories (JSON array of {name, image, link})"}],"impact/hero":[{key:"title",type:"text",label:"Page Title"},{key:"subtitle",type:"textarea",label:"Page Subtitle"}],"impact/metrics":[{key:"title",type:"text",label:"Section Title"},{key:"description",type:"textarea",label:"Section Description"}],"faq/hero":[{key:"title",type:"text",label:"Page Title"},{key:"subtitle",type:"textarea",label:"Page Subtitle"}],"faq/questions":[{key:"questions",type:"array",label:"FAQ Items (JSON array of {question, answer})"}],"privacy/content":[{key:"title",type:"text",label:"Page Title"},{key:"last_updated",type:"text",label:"Last Updated Date"},{key:"content",type:"textarea",label:"Privacy Policy Content"}],"terms/content":[{key:"title",type:"text",label:"Page Title"},{key:"last_updated",type:"text",label:"Last Updated Date"},{key:"content",type:"textarea",label:"Terms of Service Content"}]},Ub=s=>{if(typeof s=="string")try{return JSON.parse(s)}catch{return{}}return s||{}};function Hb(){const s=is(),[t,r]=d.useState(""),[a,n]=d.useState(""),[i,o]=d.useState({}),[l,c]=d.useState("form"),[m,p]=d.useState(""),[x,g]=d.useState(!1),[u,y]=d.useState({page:"",section:""}),[h,f]=d.useState("all"),{data:b,isLoading:v}=os({queryKey:["admin-cms-all"],queryFn:async()=>{const{data:k,error:A}=await M.from("site_content").select("*").order("page_name",{ascending:!0}).order("section_key",{ascending:!0});if(A)throw A;return(k||[]).map(q=>({...q,content:Ub(q.content)}))}}),j=b==null?void 0:b.find(k=>k.id===t),_=j?`${j.page_name}/${j.section_key}`:"",I=Bb[_],E=it({mutationFn:async({id:k,content:A})=>{const{error:q}=await M.from("site_content").update({content:JSON.stringify(A),updated_at:new Date().toISOString()}).eq("id",k);if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-cms-all"]}),s.invalidateQueries({queryKey:["cms-content"]}),C.success("Content updated successfully")},onError:k=>{C.error("Failed to update content: "+k.message)}}),O=it({mutationFn:async({page:k,section:A})=>{const{error:q}=await M.from("site_content").insert({page_name:k,section_key:A,content:JSON.stringify({})});if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-cms-all"]}),g(!1),y({page:"",section:""}),C.success("New section created")},onError:k=>{C.error("Failed to create section: "+k.message)}}),D=it({mutationFn:async k=>{const{error:A}=await M.from("site_content").delete().eq("id",k);if(A)throw A},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-cms-all"]}),r(""),C.success("Section deleted")},onError:k=>{C.error("Failed to delete section: "+k.message)}}),N=k=>{const A=b==null?void 0:b.find(q=>q.id===k);A&&(r(k),n(JSON.stringify(A.content,null,2)),o(A.content||{}))},T=(k,A)=>{const q={...i,[k]:A};o(q),n(JSON.stringify(q,null,2))},P=()=>{try{const k=l==="json"?JSON.parse(a):i;E.mutate({id:t,content:k})}catch{C.error("Invalid JSON format")}},S=()=>{window.confirm("Are you sure you want to delete this section? This cannot be undone.")&&D.mutate(t)};d.useEffect(()=>{if(l==="json"&&t&&a)try{const k=JSON.parse(a);o(k)}catch{}},[a,l,t]);const W=Array.from(new Set((b==null?void 0:b.map(k=>k.page_name))||[])),K=b==null?void 0:b.filter(k=>{const A=k.page_name.toLowerCase().includes(m.toLowerCase())||k.section_key.toLowerCase().includes(m.toLowerCase()),q=h==="all"||k.page_name===h;return A&&q}),F=k=>{const A=i[k.key]??"";switch(k.type){case"image":return e.jsx(Ji,{label:k.label,currentUrl:A,onUpload:q=>T(k.key,q)},k.key);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:k.label}),e.jsx(qt,{value:A,onChange:q=>T(k.key,q.target.value),rows:4})]},k.key);case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:k.label}),e.jsx(Q,{type:"number",value:A,onChange:q=>T(k.key,parseFloat(q.target.value))})]},k.key);case"boolean":return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx("input",{type:"checkbox",id:k.key,checked:!!A,onChange:q=>T(k.key,q.target.checked),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"}),e.jsx(B,{htmlFor:k.key,children:k.label})]},k.key);case"array":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:k.label}),e.jsx(qt,{value:typeof A=="object"?JSON.stringify(A,null,2):A,onChange:q=>{try{T(k.key,JSON.parse(q.target.value))}catch{T(k.key,q.target.value)}},className:"font-mono text-xs",rows:6})]},k.key);default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:k.label}),e.jsx(Q,{value:A,onChange:q=>T(k.key,q.target.value)})]},k.key)}};return v?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"grid gap-6 lg:grid-cols-4",children:[e.jsxs(X,{className:"lg:col-span-1 h-fit",children:[e.jsxs(ye,{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-lg",children:"CMS Sections"}),e.jsxs(Ms,{open:x,onOpenChange:g,children:[e.jsx(Mr,{asChild:!0,children:e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",children:e.jsx(fs,{className:"h-4 w-4"})})}),e.jsxs(gs,{children:[e.jsxs(Is,{children:[e.jsx(Os,{children:"Create New Section"}),e.jsx(Ya,{children:"Add a new editable section to your site."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Page Name (e.g., home, global, contact)"}),e.jsx(Q,{placeholder:"home",value:u.page,onChange:k=>y({...u,page:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Section Key (e.g., hero, features, footer)"}),e.jsx(Q,{placeholder:"hero",value:u.section,onChange:k=>y({...u,section:k.target.value})})]})]}),e.jsx(Eo,{children:e.jsxs(R,{onClick:()=>O.mutate(u),disabled:!u.page||!u.section||O.isPending,children:[O.isPending?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(fs,{className:"h-4 w-4 mr-2"}),"Create Section"]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ua,{value:h,onValueChange:f,children:[e.jsx(Pr,{className:"h-9",children:e.jsx(ma,{placeholder:"All Pages"})}),e.jsxs(Ar,{children:[e.jsx(nt,{value:"all",children:"All Pages"}),W.map(k=>e.jsx(nt,{value:k,children:k},k))]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(vo,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Q,{placeholder:"Search sections...",className:"pl-8 h-9",value:m,onChange:k=>p(k.target.value)})]})]})]}),e.jsx(ee,{className:"p-0 border-t max-h-[600px] overflow-y-auto",children:e.jsx("div",{className:"flex flex-col",children:K==null?void 0:K.map(k=>e.jsxs("button",{onClick:()=>N(k.id),className:`flex flex-col items-start px-4 py-3 text-left transition-colors hover:bg-muted/50 border-b border-border/50 ${t===k.id?"bg-primary/5 border-l-4 border-l-primary":""}`,children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[k.page_name==="global"?e.jsx(xa,{className:"h-3 w-3"}):e.jsx(Xc,{className:"h-3 w-3"}),k.page_name]}),e.jsx("span",{className:"text-sm font-medium mt-0.5",children:k.section_key})]},k.id))})})]}),e.jsxs(X,{className:"lg:col-span-3",children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between border-b pb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{children:"Content Editor"}),(j==null?void 0:j.page_name)==="global"&&e.jsx(Jn,{className:"h-4 w-4 text-primary"})]}),e.jsx(Be,{children:j?e.jsxs("span",{className:"font-mono text-xs bg-muted px-2 py-0.5 rounded",children:[j.page_name,"/",j.section_key]}):"Select a section from the list to begin editing."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsx(R,{variant:"ghost",size:"icon",onClick:S,className:"text-destructive hover:bg-destructive/10",children:e.jsx(xs,{className:"h-4 w-4"})}),e.jsxs(R,{onClick:P,disabled:!t||E.isPending,className:"gap-2",children:[E.isPending?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsx(Zh,{className:"h-4 w-4"}),"Save Changes"]})]})]}),e.jsx(ee,{className:"pt-6",children:t?e.jsxs(Ir,{value:l,onValueChange:k=>c(k),className:"space-y-6",children:[e.jsxs(ar,{className:"bg-muted/50 p-1",children:[e.jsxs(Ye,{value:"form",className:"gap-2 px-4",children:[e.jsx(ip,{className:"h-4 w-4"}),"Visual Editor"]}),e.jsxs(Ye,{value:"json",className:"gap-2 px-4",children:[e.jsx(Ih,{className:"h-4 w-4"}),"JSON Editor"]})]}),e.jsx($e,{value:"form",className:"animate-in fade-in slide-in-from-bottom-2 duration-300",children:I?e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx("div",{className:"space-y-6 md:col-span-1",children:I.filter((k,A)=>A%2===0).map(F)}),e.jsx("div",{className:"space-y-6 md:col-span-1",children:I.filter((k,A)=>A%2!==0).map(F)})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg bg-primary/5 p-4 border border-primary/10 flex items-start gap-3",children:[e.jsx(Jn,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-primary",children:"Dynamic Field Recognition"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["This section's structure is learned dynamically from the database. If you need to add a new field (e.g., a new image or text block), switch to the ",e.jsx("strong",{children:"JSON Editor"})," tab, add it there, and save. It will then appear here as a form field."]})]})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:Object.entries(i).map(([k,A])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"capitalize text-xs font-semibold tracking-wide text-muted-foreground",children:k.replace(/_/g," ")}),typeof A=="string"&&(A.startsWith("http")||A.includes("supabase"))?e.jsx(Ji,{currentUrl:A,onUpload:q=>T(k,q)}):typeof A=="string"&&A.length>100?e.jsx(qt,{value:A,onChange:q=>T(k,q.target.value),rows:4}):typeof A=="string"?e.jsx(Q,{value:A,onChange:q=>T(k,q.target.value)}):typeof A=="number"?e.jsx(Q,{type:"number",value:A,onChange:q=>T(k,parseFloat(q.target.value))}):typeof A=="boolean"?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:q=>T(k,q.target.checked),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"}),e.jsx("span",{className:"text-sm",children:"Enabled"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(qt,{value:JSON.stringify(A,null,2),onChange:q=>{try{T(k,JSON.parse(q.target.value))}catch{}},className:"font-mono text-[10px] bg-muted/30",rows:6}),e.jsx("p",{className:"text-[10px] text-muted-foreground italic text-right",children:"JSON Object"})]})]},k))})]})}),e.jsx($e,{value:"json",className:"animate-in fade-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground font-mono bg-muted p-2 rounded",children:[e.jsx("span",{children:"Editor Mode: Raw JSON"}),e.jsx("span",{children:"Valid JSON Required"})]}),e.jsx(qt,{value:a,onChange:k=>n(k.target.value),className:"min-h-[500px] font-mono text-sm leading-relaxed border-2 focus-visible:ring-primary",placeholder:"{ 'key': 'value' }"})]})})]}):e.jsxs("div",{className:"flex h-[400px] flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted bg-muted/5 text-muted-foreground",children:[e.jsx("div",{className:"bg-primary/10 p-4 rounded-full mb-4",children:e.jsx(Jn,{className:"h-10 w-10 text-primary opacity-50"})}),e.jsx("h3",{className:"text-lg font-medium",children:"No Section Selected"}),e.jsx("p",{className:"max-w-xs text-center mt-2",children:"Choose a page section from the sidebar to manage its text, images, and settings."})]})})]})]})}function Vb(){var g,u,y;const[s,t]=d.useState(!0),[r,a]=d.useState("7"),[n,i]=d.useState(null),[o,l]=d.useState(!1);d.useEffect(()=>{c()},[r]);const c=async(h=!1)=>{h?l(!0):t(!0);try{const f=parseInt(r),b=new Date;b.setDate(b.getDate()-f);const{data:v,error:j}=await M.from("page_views").select("*").gte("created_at",b.toISOString()).order("created_at",{ascending:!1});if(j){console.error("Error fetching page views:",j),i({totalVisits:0,uniqueVisitors:0,topPages:[],deviceBreakdown:[],visitsByDay:[],visitorLocations:[],recentVisitors:[]});return}const _=v||[],I=_.length,O=new Set(_.map(A=>A.session_id||A.ip_hash).filter(Boolean)).size,D={};_.forEach(A=>{D[A.page_path]=(D[A.page_path]||0)+1});const N=Object.entries(D).map(([A,q])=>({path:A,count:q})).sort((A,q)=>q.count-A.count).slice(0,10),T={};_.forEach(A=>{const q=A.device_type||"desktop";T[q]=(T[q]||0)+1});const P=Object.entries(T).map(([A,q])=>({device:A,count:q})).sort((A,q)=>q.count-A.count),S={};_.forEach(A=>{const q=new Date(A.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric"});S[q]=(S[q]||0)+1});const W=Object.entries(S).map(([A,q])=>({date:A,count:q})).slice(-7),K={};_.forEach(A=>{if(A.city||A.country){const q=A.city?`${A.city}, ${A.country||"Unknown"}`:A.country||"Unknown";K[q]||(K[q]={country:A.country||"Unknown",count:0}),K[q].count++}});const F=Object.entries(K).map(([A,q])=>({location:A,country:q.country,count:q.count})).sort((A,q)=>q.count-A.count).slice(0,10),k=_.slice(0,10).map(A=>({created_at:A.created_at,page_path:A.page_path,country:A.country||"Unknown",city:A.city||"Unknown"}));i({totalVisits:I,uniqueVisitors:O,topPages:N,deviceBreakdown:P,visitsByDay:W,visitorLocations:F,recentVisitors:k})}catch(f){console.error("Failed to fetch analytics:",f),C.error("Failed to load analytics")}finally{t(!1),l(!1)}},m=h=>{switch(h){case"mobile":return e.jsx(ep,{className:"h-4 w-4"});case"tablet":return e.jsx(sp,{className:"h-4 w-4"});default:return e.jsx(Wh,{className:"h-4 w-4"})}};if(s)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})});if(!n)return null;const p=Math.max(...((g=n.visitsByDay)==null?void 0:g.length)>0?n.visitsByDay.map(h=>h.count):[1],1),x=(n.totalVisits||0)>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Analytics"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(R,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>c(!0),disabled:o,children:[e.jsx(aa,{className:`h-4 w-4 ${o?"animate-spin":""}`}),"Refresh"]}),e.jsxs(ua,{value:r,onValueChange:a,children:[e.jsx(Pr,{className:"w-40",children:e.jsx(ma,{})}),e.jsxs(Ar,{children:[e.jsx(nt,{value:"7",children:"Last 7 days"}),e.jsx(nt,{value:"14",children:"Last 14 days"}),e.jsx(nt,{value:"30",children:"Last 30 days"}),e.jsx(nt,{value:"90",children:"Last 90 days"})]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsx(X,{children:e.jsx(ee,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-3",children:e.jsx(Ga,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:n.totalVisits}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Page Views"})]})]})})}),e.jsx(X,{children:e.jsx(ee,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:e.jsx(rr,{className:"h-6 w-6 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:n.uniqueVisitors}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unique Visitors"})]})]})})}),e.jsx(X,{children:e.jsx(ee,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"rounded-full bg-purple-500/10 p-3",children:e.jsx(xa,{className:"h-6 w-6 text-purple-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:((u=n.visitorLocations)==null?void 0:u.length)||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Countries/Cities"})]})]})})}),e.jsx(X,{children:e.jsx(ee,{className:"p-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"rounded-full bg-green-500/10 p-3",children:e.jsx(_r,{className:"h-6 w-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:((y=n.topPages)==null?void 0:y.length)>0?n.topPages[0].count:0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Top Page Views"})]})]})})})]}),x?e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Page Views Over Time"}),e.jsx(Be,{children:"Daily page visits"})]}),e.jsx(ee,{children:n.visitsByDay.length>0?e.jsx("div",{className:"space-y-2",children:n.visitsByDay.map(h=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-20 text-sm text-muted-foreground",children:h.date}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"h-6 rounded bg-primary/80 transition-all",style:{width:`${Math.max(h.count/p*100,5)}%`}})}),e.jsx("span",{className:"w-10 text-right text-sm font-medium",children:h.count})]},h.date))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No visit data for this period"})})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Top Pages"}),e.jsx(Be,{children:"Most visited pages"})]}),e.jsx(ee,{children:n.topPages.length>0?e.jsx("div",{className:"space-y-3",children:n.topPages.map((h,f)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium",children:f+1}),e.jsx("span",{className:"text-sm font-medium",children:h.path})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.count," views"]})]},h.path))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No page data yet"})})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Device Breakdown"}),e.jsx(Be,{children:"Visitors by device type"})]}),e.jsx(ee,{children:n.deviceBreakdown.length>0?e.jsx("div",{className:"space-y-3",children:n.deviceBreakdown.map(h=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m(h.device),e.jsx("span",{className:"text-sm font-medium capitalize",children:h.device})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:h.count}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",n.totalVisits>0?Math.round(h.count/n.totalVisits*100):0,"%)"]})]})]},h.device))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No device data yet"})})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"h-5 w-5"}),"Visitor Locations"]}),e.jsx(Be,{children:"Where your visitors are browsing from"})]}),e.jsx(ee,{children:n.visitorLocations.length>0?e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.visitorLocations.map((h,f)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary",children:f+1}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium block truncate",children:h.location}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[h.count," views"]})]})]},h.location))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No visitor location data yet."})})]})]}):e.jsx(X,{children:e.jsxs(ee,{className:"p-12 text-center",children:[e.jsx("div",{className:"mx-auto w-fit rounded-full bg-muted p-4 mb-4",children:e.jsx(_r,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No Analytics Data Yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Analytics data will appear here as visitors browse your website. Enable Cloud to track page views, device types, and product interactions automatically."})]})})]})}function Wb(){const[s,t]=d.useState(!0),[r,a]=d.useState([]);d.useEffect(()=>{n()},[]);const n=async()=>{try{t(!0);const{data:i,error:o}=await M.from("product_performance_stats").select("product_id, views, add_to_cart, purchases, revenue");if(o){console.error("Error fetching product stats:",o),t(!1);return}if(!i||i.length===0){a([]),t(!1);return}const l={};i.forEach(m=>{l[m.product_id]||(l[m.product_id]={views:0,add_to_cart:0,purchases:0,revenue:0}),l[m.product_id].views+=m.views||0,l[m.product_id].add_to_cart+=m.add_to_cart||0,l[m.product_id].purchases+=m.purchases||0,l[m.product_id].revenue+=Number(m.revenue)||0});const c=Object.entries(l).map(([m,p])=>({product_id:m,product_name:`Product ${m.slice(0,8)}...`,views:p.views,add_to_cart:p.add_to_cart,purchases:p.purchases,revenue:p.revenue,conversion_rate:p.views>0?p.purchases/p.views*100:0}));c.sort((m,p)=>p.views-m.views),a(c)}catch(i){console.error("Error in fetchProductStats:",i)}finally{t(!1)}};return s?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(X,{children:[e.jsx(ye,{className:"pb-2",children:e.jsxs(be,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Ga,{className:"h-4 w-4"}),"Total Product Views"]})}),e.jsx(ee,{children:e.jsx("div",{className:"text-2xl font-bold",children:r.reduce((i,o)=>i+o.views,0).toLocaleString()})})]}),e.jsxs(X,{children:[e.jsx(ye,{className:"pb-2",children:e.jsxs(be,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(gn,{className:"h-4 w-4"}),"Total Cart Adds"]})}),e.jsx(ee,{children:e.jsx("div",{className:"text-2xl font-bold",children:r.reduce((i,o)=>i+o.add_to_cart,0).toLocaleString()})})]}),e.jsxs(X,{children:[e.jsx(ye,{className:"pb-2",children:e.jsxs(be,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(rp,{className:"h-4 w-4"}),"Average Conversion"]})}),e.jsx(ee,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[(r.reduce((i,o)=>i+o.conversion_rate,0)/(r.length||1)).toFixed(1),"%"]})})]})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Product Performance Breakdown"}),e.jsx(Be,{children:"Tracking views, cart adds, purchases, and revenue per product."})]}),e.jsx(ee,{children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Product ID"}),e.jsx(ae,{className:"text-right",children:"Views"}),e.jsx(ae,{className:"text-right",children:"Cart Adds"}),e.jsx(ae,{className:"text-right",children:"Purchases"}),e.jsx(ae,{className:"text-right",children:"Revenue"}),e.jsx(ae,{className:"text-right",children:"Conversion"})]})}),e.jsxs(Rt,{children:[r.map(i=>e.jsxs(Qe,{children:[e.jsxs(se,{className:"font-mono text-sm",children:[i.product_id.slice(0,8),"..."]}),e.jsx(se,{className:"text-right",children:i.views.toLocaleString()}),e.jsx(se,{className:"text-right",children:i.add_to_cart.toLocaleString()}),e.jsx(se,{className:"text-right",children:e.jsx(Le,{variant:i.purchases>0?"default":"secondary",children:i.purchases})}),e.jsxs(se,{className:"text-right",children:["£",i.revenue.toFixed(2)]}),e.jsx(se,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("span",{className:"font-mono",children:[i.conversion_rate.toFixed(1),"%"]}),i.conversion_rate>10&&e.jsx(Ch,{className:"h-3 w-3 text-green-500"})]})})]},i.product_id)),r.length===0&&e.jsx(Qe,{children:e.jsx(se,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No product data tracked yet. Browse products to start tracking."})})]})]})})]})]})}function Kb(){const[s,t]=d.useState(!1),[r,a]=d.useState(null),[n,i]=d.useState(null),o=async()=>{t(!0);try{const{error:m}=await M.from("products").select("id",{count:"exact",head:!0}),{data:p}=await M.auth.getSession(),{data:x,error:g}=await M.storage.listBuckets();i({db:!m,auth:!!p,storage:!g}),C.success("System health check completed")}catch{C.error("Health check failed")}finally{t(!1)}},l=async()=>{var m;a("full");try{const p=await fetch("/api/export-data?format=download");if(!p.ok)throw new Error("Export failed");const x=await p.json(),g=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),u=URL.createObjectURL(g),y=document.createElement("a");y.href=u,y.download=`moenviron-backup-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(u),C.success(`Backup downloaded! ${((m=x._meta)==null?void 0:m.total_records)||0} records exported`)}catch(p){C.error("Backup failed: "+(p instanceof Error?p.message:"Unknown error"))}finally{a(null)}},c=async m=>{a(m);try{const p=await fetch(`/api/export-csv?table=${m}`);if(!p.ok)throw new Error("Export failed");const x=await p.text(),g=new Blob([x],{type:"text/csv"}),u=URL.createObjectURL(g),y=document.createElement("a");y.href=u,y.download=`${m}-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(u),C.success(`${m} exported to CSV`)}catch{C.error("CSV export failed")}finally{a(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"System Tools"}),e.jsxs(R,{onClick:o,disabled:s,className:"gap-2",children:[e.jsx(aa,{className:`h-4 w-4 ${s?"animate-spin":""}`}),"Run Health Check"]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Database Status"}),e.jsx(Oh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ee,{children:n?e.jsx(Le,{variant:n.db?"default":"destructive",children:n.db?"Healthy":"Error"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not checked"})})]}),e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Auth Service"}),e.jsx(Xh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ee,{children:n?e.jsx(Le,{variant:n.auth?"default":"destructive",children:n.auth?"Connected":"Error"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not checked"})})]}),e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Storage Buckets"}),e.jsx(Jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ee,{children:n?e.jsx(Le,{variant:n.storage?"default":"destructive",children:n.storage?"Accessible":"Error"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not checked"})})]})]}),e.jsxs(X,{className:"border-emerald-200 bg-emerald-50/50",children:[e.jsxs(ye,{children:[e.jsxs(be,{className:"flex items-center gap-2 text-emerald-800",children:[e.jsx(Lh,{className:"h-5 w-5"}),"Data Backup & Export"]}),e.jsx(Be,{children:"Download your data to protect against service interruptions or for offline analysis"})]}),e.jsxs(ee,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border border-emerald-200 rounded-lg bg-white",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium flex items-center gap-2",children:[e.jsx(Xc,{className:"h-4 w-4 text-emerald-600"}),"Full Database Backup"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Export all tables (orders, products, subscribers, settings)"})]}),e.jsxs(R,{onClick:l,disabled:r==="full",className:"gap-2 bg-emerald-600 hover:bg-emerald-700",children:[e.jsx(Zc,{className:`h-4 w-4 ${r==="full"?"animate-bounce":""}`}),r==="full"?"Exporting...":"Download JSON"]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col items-center justify-between p-4 border rounded-lg bg-white",children:[e.jsx(Zn,{className:"h-8 w-8 text-blue-500 mb-2"}),e.jsx("p",{className:"font-medium text-sm",children:"Orders"}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>c("orders"),disabled:r==="orders",className:"mt-2 w-full",children:r==="orders"?"Exporting...":"Export CSV"})]}),e.jsxs("div",{className:"flex flex-col items-center justify-between p-4 border rounded-lg bg-white",children:[e.jsx(Zn,{className:"h-8 w-8 text-purple-500 mb-2"}),e.jsx("p",{className:"font-medium text-sm",children:"Products"}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>c("products"),disabled:r==="products",className:"mt-2 w-full",children:r==="products"?"Exporting...":"Export CSV"})]}),e.jsxs("div",{className:"flex flex-col items-center justify-between p-4 border rounded-lg bg-white",children:[e.jsx(Zn,{className:"h-8 w-8 text-orange-500 mb-2"}),e.jsx("p",{className:"font-medium text-sm",children:"Subscribers"}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>c("newsletter_subscribers"),disabled:r==="newsletter_subscribers",className:"mt-2 w-full",children:r==="newsletter_subscribers"?"Exporting...":"Export CSV"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center mt-2",children:"Tip: Download regular backups to protect your data from service disruptions"})]})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(rd,{className:"h-5 w-5"}),"Maintenance Tasks"]}),e.jsx(Be,{children:"Common admin maintenance operations"})]}),e.jsxs(ee,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Clear Site Cache"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Force refresh of content cache for all users"})]}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>C.info("Cache cleared successfully"),children:"Execute"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Re-sync Products"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verify stock levels and sync with stripe catalog"})]}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>C.info("Product sync started"),children:"Execute"})]})]})]})]})}const Wl={metric_name:"",metric_value:"",unit:"kg",notes:null};function Gb(){const s=is(),[t,r]=d.useState(!1),[a,n]=d.useState(null),[i,o]=d.useState(Wl),{data:l,isLoading:c}=os({queryKey:["impact-metrics"],queryFn:async()=>{const{data:h,error:f}=await M.from("impact_metrics").select("id, metric_name, metric_value, unit, notes, recorded_at").order("recorded_at",{ascending:!1});if(f)throw f;return h}}),m=it({mutationFn:async h=>{const{error:f}=await M.from("impact_metrics").insert({metric_name:h.metric_name,metric_value:parseFloat(h.metric_value),unit:h.unit,notes:h.notes});if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["impact-metrics"]}),C.success("Metric created successfully"),g()},onError:h=>C.error("Failed to create: "+h.message)}),p=it({mutationFn:async({id:h,data:f})=>{const{error:b}=await M.from("impact_metrics").update({metric_name:f.metric_name,metric_value:parseFloat(f.metric_value),unit:f.unit,notes:f.notes}).eq("id",h);if(b)throw b},onSuccess:()=>{s.invalidateQueries({queryKey:["impact-metrics"]}),C.success("Metric updated successfully"),g()},onError:h=>C.error("Failed to update: "+h.message)}),x=it({mutationFn:async h=>{const{error:f}=await M.from("impact_metrics").delete().eq("id",h);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["impact-metrics"]}),C.success("Metric deleted successfully")},onError:h=>C.error("Failed to delete: "+h.message)}),g=()=>{o(Wl),n(null),r(!1)},u=h=>{n(h),o({metric_name:h.metric_name,metric_value:String(h.metric_value),unit:h.unit,notes:h.notes}),r(!0)},y=()=>{if(!i.metric_name||!i.metric_value){C.error("Name and value are required");return}a?p.mutate({id:a.id,data:i}):m.mutate(i)};return c?e.jsx(ue,{className:"h-8 w-8 animate-spin"}):e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(_r,{className:"h-5 w-5"}),"Impact Metrics"]}),e.jsx(Be,{children:"Manage environmental impact data"})]}),e.jsxs(Ms,{open:t,onOpenChange:h=>{r(h),h||g()},children:[e.jsx(Mr,{asChild:!0,children:e.jsxs(R,{className:"gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Add Metric"]})}),e.jsxs(gs,{className:"max-w-lg",children:[e.jsx(Is,{children:e.jsx(Os,{children:a?"Edit Metric":"Add New Metric"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Metric Name *"}),e.jsx(Q,{value:i.metric_name,onChange:h=>o({...i,metric_name:h.target.value}),placeholder:"e.g. tonnes_recycled, carbon_offset"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Value *"}),e.jsx(Q,{type:"number",value:i.metric_value,onChange:h=>o({...i,metric_value:h.target.value}),placeholder:"500"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Unit"}),e.jsx(Q,{value:i.unit,onChange:h=>o({...i,unit:h.target.value}),placeholder:"kg"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Notes"}),e.jsx(qt,{value:i.notes||"",onChange:h=>o({...i,notes:h.target.value}),placeholder:"Additional notes...",rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:g,children:"Cancel"}),e.jsxs(R,{onClick:y,disabled:m.isPending||p.isPending,children:[(m.isPending||p.isPending)&&e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Update":"Create"]})]})]})]})]})]}),e.jsx(ee,{children:l&&l.length>0?e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Metric"}),e.jsx(ae,{children:"Value"}),e.jsx(ae,{children:"Notes"}),e.jsx(ae,{className:"w-24",children:"Actions"})]})}),e.jsx(Rt,{children:l.map(h=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium",children:h.metric_name}),e.jsxs(se,{children:[h.metric_value," ",h.unit]}),e.jsx(se,{children:h.notes||"-"}),e.jsx(se,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>u(h),children:e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>x.mutate(h.id),children:e.jsx(xs,{className:"h-4 w-4"})})]})})]},h.id))})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No metrics yet. Add your first one!"})})]})}function Yb(){const s=is(),[t,r]=d.useState(""),[a,n]=d.useState("admin"),[i,o]=d.useState(""),{data:l,isLoading:c}=os({queryKey:["admin-users"],queryFn:async()=>{const{data:u,error:y}=await M.from("user_roles").select("id, user_id, role, responsibilities, created_at").neq("role","user");if(y)throw y;let h=[];if(u&&u.length>0){const v=u.map(I=>I.user_id),{data:j}=await M.from("profiles").select("user_id, email, full_name").in("user_id",v),_=new Map((j||[]).map(I=>[I.user_id,I]));h=u.map(I=>{const E=_.get(I.user_id);return{id:I.id,user_id:I.user_id,email:(E==null?void 0:E.email)||"Unknown",full_name:(E==null?void 0:E.full_name)||null,role:I.role,responsibilities:I.responsibilities||null,created_at:I.created_at,status:"active"}})}const{data:f}=await M.from("site_content").select("content").eq("section_key","pending_invitations").maybeSingle();let b=[];if(f!=null&&f.content)try{const v=typeof f.content=="string"?JSON.parse(f.content):f.content;b=(Array.isArray(v)?v:[]).map((_,I)=>({id:`invite-${I}`,user_id:`pending-${I}`,email:_.email,full_name:null,role:_.role,responsibilities:_.responsibilities,created_at:_.created_at,status:"pending"}))}catch(v){console.error("Failed to parse invitations",v)}return[...h,...b].sort((v,j)=>new Date(j.created_at).getTime()-new Date(v.created_at).getTime())}}),m=it({mutationFn:async({userEmail:u,role:y,resp:h})=>{var v;const f=u.toLowerCase(),{data:b}=await M.from("profiles").select("user_id").eq("email",f).maybeSingle();if(b){const{data:j}=await M.from("user_roles").select("id").eq("user_id",b.user_id).eq("role",y).maybeSingle();if(j)throw new Error("User already has this role");const{error:_}=await M.from("user_roles").insert({user_id:b.user_id,role:y,responsibilities:h||null});if(_)throw _;return{success:!0,type:"assigned"}}else{const{data:j}=await M.from("site_content").select("content, id").eq("section_key","pending_invitations").maybeSingle();let _=[],I=j==null?void 0:j.id;if(j!=null&&j.content)try{const N=typeof j.content=="string"?JSON.parse(j.content):j.content;_=Array.isArray(N)?N:[]}catch{_=[]}if(_.some(N=>N.email.toLowerCase()===f&&N.role===y))throw new Error("User already has a pending invitation for this role");const{data:E}=await M.auth.getUser(),O={email:f,role:y,responsibilities:h||null,created_at:new Date().toISOString(),invited_by:((v=E.user)==null?void 0:v.id)||"system"},D=[..._,O];if(I){const{error:N}=await M.from("site_content").update({content:JSON.stringify(D),updated_at:new Date().toISOString()}).eq("id",I);if(N)throw N}else{const{error:N}=await M.from("site_content").insert({section_key:"pending_invitations",page_name:"admin",content:JSON.stringify(D)});if(N)throw N}try{const{error:N}=await M.functions.invoke("send-invite-email",{body:{email:f,role:y,responsibilities:h}});N&&(console.error("Failed to send invite email:",N),C.error("Invitation saved but email failed to send. Please ensure 'send-invite-email' function is deployed."))}catch(N){console.error("Failed to send invite email:",N)}return{success:!0,type:"invited"}}},onSuccess:u=>{s.invalidateQueries({queryKey:["admin-users"]}),C.success(u.type==="assigned"?"Admin role assigned successfully":"Invitation sent successfully"),r(""),o("")},onError:u=>{C.error(u.message||"Failed to process request")}}),p=it({mutationFn:async u=>{if(u.status==="active"){const{error:y}=await M.from("user_roles").delete().eq("id",u.id);if(y)throw y}else{const{data:y}=await M.from("site_content").select("content, id").eq("section_key","pending_invitations").single();if(!y)return;let h=[];try{const v=typeof y.content=="string"?JSON.parse(y.content):y.content;h=Array.isArray(v)?v:[]}catch{return}const f=h.filter(v=>!(v.email.toLowerCase()===u.email.toLowerCase()&&v.role===u.role)),{error:b}=await M.from("site_content").update({content:JSON.stringify(f),updated_at:new Date().toISOString()}).eq("id",y.id);if(b)throw b}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users"]}),C.success("Role removed successfully")},onError:u=>{C.error(u.message||"Failed to remove role")}}),x=u=>{u.preventDefault(),t&&m.mutate({userEmail:t,role:a,resp:i})},g=u=>{switch(u){case"admin":return"default";case"moderator":return"outline";case"marketing":return"secondary";case"shipping":return"secondary";case"support":return"secondary";case"content":return"secondary";default:return"secondary"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(ad,{className:"h-5 w-5"}),"Add New Admin Role"]}),e.jsx(Be,{children:"Assign administrative roles by email. If the user doesn't have an account, they will be invited."})]}),e.jsx(ee,{children:e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"email",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(zt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Q,{id:"email",type:"email",placeholder:"admin@example.com",className:"pl-9",value:t,onChange:u=>r(u.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"role",children:"Admin Role"}),e.jsxs(ua,{value:a,onValueChange:u=>n(u),children:[e.jsx(Pr,{id:"role",children:e.jsx(ma,{placeholder:"Select a role"})}),e.jsxs(Ar,{children:[e.jsx(nt,{value:"admin",children:"Admin"}),e.jsx(nt,{value:"moderator",children:"Moderator"}),e.jsx(nt,{value:"marketing",children:"Marketing"}),e.jsx(nt,{value:"shipping",children:"Shipping"}),e.jsx(nt,{value:"support",children:"Support"}),e.jsx(nt,{value:"content",children:"Content"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"responsibilities",children:"Responsibilities"}),e.jsxs("div",{className:"relative",children:[e.jsx(Th,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(qt,{id:"responsibilities",placeholder:"Describe this admin's responsibilities...",className:"pl-9 min-h-[80px]",value:i,onChange:u=>o(u.target.value)})]})]}),e.jsxs(R,{type:"submit",className:"w-full sm:w-auto",disabled:m.isPending,children:[m.isPending&&e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Assign / Invite"]})]})})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Nr,{className:"h-5 w-5"}),"Current Administrators"]}),e.jsx(Be,{children:"A list of all users with administrative privileges. Pending users are shown with a clock icon."})]}),e.jsx(ee,{children:c?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Admin / Role"}),e.jsx(ae,{children:"Responsibilities"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{children:"Joined / Invited"}),e.jsx(ae,{className:"text-right",children:"Actions"})]})}),e.jsxs(Rt,{children:[l==null?void 0:l.map(u=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium align-top",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-semibold truncate max-w-[200px]",title:u.email,children:u.email}),e.jsx(Le,{variant:g(u.role),className:"text-[10px] font-bold uppercase tracking-wider",children:u.role.replace("_"," ")})]})}),e.jsx(se,{className:"max-w-[250px] text-sm text-muted-foreground align-top",children:u.responsibilities||"No specific responsibilities assigned."}),e.jsx(se,{className:"align-top",children:u.status==="active"?e.jsxs(Le,{variant:"outline",className:"text-green-600 border-green-200 bg-green-50",children:[e.jsx(wt,{className:"h-3 w-3 mr-1"}),"Active"]}):e.jsxs(Le,{variant:"outline",className:"text-amber-600 border-amber-200 bg-amber-50",children:[e.jsx(xo,{className:"h-3 w-3 mr-1"}),"Pending"]})}),e.jsx(se,{className:"text-sm text-muted-foreground align-top whitespace-nowrap",children:new Date(u.created_at).toLocaleDateString()}),e.jsx(se,{className:"text-right align-top",children:e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>p.mutate(u),disabled:p.isPending,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",title:"Remove role or invitation",children:e.jsx(xs,{className:"h-4 w-4"})})})]},`${u.id}-${u.role}`)),(l==null?void 0:l.length)===0&&e.jsx(Qe,{children:e.jsx(se,{colSpan:5,className:"h-24 text-center text-muted-foreground",children:"No administrators found."})})]})]})})})]})]})}function Qb(s,t){return d.useReducer((r,a)=>t[r][a]??r,s)}var Do="ScrollArea",[Qu]=pa(Do),[Zb,Vt]=Qu(Do),Zu=d.forwardRef((s,t)=>{const{__scopeScrollArea:r,type:a="hover",dir:n,scrollHideDelay:i=600,...o}=s,[l,c]=d.useState(null),[m,p]=d.useState(null),[x,g]=d.useState(null),[u,y]=d.useState(null),[h,f]=d.useState(null),[b,v]=d.useState(0),[j,_]=d.useState(0),[I,E]=d.useState(!1),[O,D]=d.useState(!1),N=rt(t,P=>c(P)),T=lo(n);return e.jsx(Zb,{scope:r,type:a,dir:T,scrollHideDelay:i,scrollArea:l,viewport:m,onViewportChange:p,content:x,onContentChange:g,scrollbarX:u,onScrollbarXChange:y,scrollbarXEnabled:I,onScrollbarXEnabledChange:E,scrollbarY:h,onScrollbarYChange:f,scrollbarYEnabled:O,onScrollbarYEnabledChange:D,onCornerWidthChange:v,onCornerHeightChange:_,children:e.jsx(Xe.div,{dir:T,...o,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":j+"px",...s.style}})})});Zu.displayName=Do;var Ju="ScrollAreaViewport",Xu=d.forwardRef((s,t)=>{const{__scopeScrollArea:r,children:a,nonce:n,...i}=s,o=Vt(Ju,r),l=d.useRef(null),c=rt(t,l,o.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(Xe.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...s.style},children:e.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:a})})]})});Xu.displayName=Ju;var ys="ScrollAreaScrollbar",Lo=d.forwardRef((s,t)=>{const{forceMount:r,...a}=s,n=Vt(ys,s.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=n,l=s.orientation==="horizontal";return d.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),n.type==="hover"?e.jsx(Jb,{...a,ref:t,forceMount:r}):n.type==="scroll"?e.jsx(Xb,{...a,ref:t,forceMount:r}):n.type==="auto"?e.jsx(em,{...a,ref:t,forceMount:r}):n.type==="always"?e.jsx(Fo,{...a,ref:t}):null});Lo.displayName=ys;var Jb=d.forwardRef((s,t)=>{const{forceMount:r,...a}=s,n=Vt(ys,s.__scopeScrollArea),[i,o]=d.useState(!1);return d.useEffect(()=>{const l=n.scrollArea;let c=0;if(l){const m=()=>{window.clearTimeout(c),o(!0)},p=()=>{c=window.setTimeout(()=>o(!1),n.scrollHideDelay)};return l.addEventListener("pointerenter",m),l.addEventListener("pointerleave",p),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",m),l.removeEventListener("pointerleave",p)}}},[n.scrollArea,n.scrollHideDelay]),e.jsx(fa,{present:r||i,children:e.jsx(em,{"data-state":i?"visible":"hidden",...a,ref:t})})}),Xb=d.forwardRef((s,t)=>{const{forceMount:r,...a}=s,n=Vt(ys,s.__scopeScrollArea),i=s.orientation==="horizontal",o=Vn(()=>c("SCROLL_END"),100),[l,c]=Qb("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return d.useEffect(()=>{if(l==="idle"){const m=window.setTimeout(()=>c("HIDE"),n.scrollHideDelay);return()=>window.clearTimeout(m)}},[l,n.scrollHideDelay,c]),d.useEffect(()=>{const m=n.viewport,p=i?"scrollLeft":"scrollTop";if(m){let x=m[p];const g=()=>{const u=m[p];x!==u&&(c("SCROLL"),o()),x=u};return m.addEventListener("scroll",g),()=>m.removeEventListener("scroll",g)}},[n.viewport,i,c,o]),e.jsx(fa,{present:r||l!=="hidden",children:e.jsx(Fo,{"data-state":l==="hidden"?"hidden":"visible",...a,ref:t,onPointerEnter:De(s.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:De(s.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),em=d.forwardRef((s,t)=>{const r=Vt(ys,s.__scopeScrollArea),{forceMount:a,...n}=s,[i,o]=d.useState(!1),l=s.orientation==="horizontal",c=Vn(()=>{if(r.viewport){const m=r.viewport.offsetWidth<r.viewport.scrollWidth,p=r.viewport.offsetHeight<r.viewport.scrollHeight;o(l?m:p)}},10);return ha(r.viewport,c),ha(r.content,c),e.jsx(fa,{present:a||i,children:e.jsx(Fo,{"data-state":i?"visible":"hidden",...n,ref:t})})}),Fo=d.forwardRef((s,t)=>{const{orientation:r="vertical",...a}=s,n=Vt(ys,s.__scopeScrollArea),i=d.useRef(null),o=d.useRef(0),[l,c]=d.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=nm(l.viewport,l.content),p={...a,sizes:l,onSizesChange:c,hasThumb:m>0&&m<1,onThumbChange:g=>i.current=g,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:g=>o.current=g};function x(g,u){return nv(g,o.current,l,u)}return r==="horizontal"?e.jsx(ev,{...p,ref:t,onThumbPositionChange:()=>{if(n.viewport&&i.current){const g=n.viewport.scrollLeft,u=Kl(g,l,n.dir);i.current.style.transform=`translate3d(${u}px, 0, 0)`}},onWheelScroll:g=>{n.viewport&&(n.viewport.scrollLeft=g)},onDragScroll:g=>{n.viewport&&(n.viewport.scrollLeft=x(g,n.dir))}}):r==="vertical"?e.jsx(tv,{...p,ref:t,onThumbPositionChange:()=>{if(n.viewport&&i.current){const g=n.viewport.scrollTop,u=Kl(g,l);i.current.style.transform=`translate3d(0, ${u}px, 0)`}},onWheelScroll:g=>{n.viewport&&(n.viewport.scrollTop=g)},onDragScroll:g=>{n.viewport&&(n.viewport.scrollTop=x(g))}}):null}),ev=d.forwardRef((s,t)=>{const{sizes:r,onSizesChange:a,...n}=s,i=Vt(ys,s.__scopeScrollArea),[o,l]=d.useState(),c=d.useRef(null),m=rt(t,c,i.onScrollbarXChange);return d.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),e.jsx(sm,{"data-orientation":"horizontal",...n,ref:m,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Hn(r)+"px",...s.style},onThumbPointerDown:p=>s.onThumbPointerDown(p.x),onDragScroll:p=>s.onDragScroll(p.x),onWheelScroll:(p,x)=>{if(i.viewport){const g=i.viewport.scrollLeft+p.deltaX;s.onWheelScroll(g),om(g,x)&&p.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&a({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:En(o.paddingLeft),paddingEnd:En(o.paddingRight)}})}})}),tv=d.forwardRef((s,t)=>{const{sizes:r,onSizesChange:a,...n}=s,i=Vt(ys,s.__scopeScrollArea),[o,l]=d.useState(),c=d.useRef(null),m=rt(t,c,i.onScrollbarYChange);return d.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),e.jsx(sm,{"data-orientation":"vertical",...n,ref:m,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Hn(r)+"px",...s.style},onThumbPointerDown:p=>s.onThumbPointerDown(p.y),onDragScroll:p=>s.onDragScroll(p.y),onWheelScroll:(p,x)=>{if(i.viewport){const g=i.viewport.scrollTop+p.deltaY;s.onWheelScroll(g),om(g,x)&&p.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&a({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:En(o.paddingTop),paddingEnd:En(o.paddingBottom)}})}})}),[sv,tm]=Qu(ys),sm=d.forwardRef((s,t)=>{const{__scopeScrollArea:r,sizes:a,hasThumb:n,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:m,onWheelScroll:p,onResize:x,...g}=s,u=Vt(ys,r),[y,h]=d.useState(null),f=rt(t,N=>h(N)),b=d.useRef(null),v=d.useRef(""),j=u.viewport,_=a.content-a.viewport,I=Es(p),E=Es(c),O=Vn(x,10);function D(N){if(b.current){const T=N.clientX-b.current.left,P=N.clientY-b.current.top;m({x:T,y:P})}}return d.useEffect(()=>{const N=T=>{const P=T.target;(y==null?void 0:y.contains(P))&&I(T,_)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[j,y,_,I]),d.useEffect(E,[a,E]),ha(y,O),ha(u.content,O),e.jsx(sv,{scope:r,scrollbar:y,hasThumb:n,onThumbChange:Es(i),onThumbPointerUp:Es(o),onThumbPositionChange:E,onThumbPointerDown:Es(l),children:e.jsx(Xe.div,{...g,ref:f,style:{position:"absolute",...g.style},onPointerDown:De(s.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),b.current=y.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",u.viewport&&(u.viewport.style.scrollBehavior="auto"),D(N))}),onPointerMove:De(s.onPointerMove,D),onPointerUp:De(s.onPointerUp,N=>{const T=N.target;T.hasPointerCapture(N.pointerId)&&T.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=v.current,u.viewport&&(u.viewport.style.scrollBehavior=""),b.current=null})})})}),Cn="ScrollAreaThumb",rm=d.forwardRef((s,t)=>{const{forceMount:r,...a}=s,n=tm(Cn,s.__scopeScrollArea);return e.jsx(fa,{present:r||n.hasThumb,children:e.jsx(rv,{ref:t,...a})})}),rv=d.forwardRef((s,t)=>{const{__scopeScrollArea:r,style:a,...n}=s,i=Vt(Cn,r),o=tm(Cn,r),{onThumbPositionChange:l}=o,c=rt(t,x=>o.onThumbChange(x)),m=d.useRef(void 0),p=Vn(()=>{m.current&&(m.current(),m.current=void 0)},100);return d.useEffect(()=>{const x=i.viewport;if(x){const g=()=>{if(p(),!m.current){const u=iv(x,l);m.current=u,l()}};return l(),x.addEventListener("scroll",g),()=>x.removeEventListener("scroll",g)}},[i.viewport,p,l]),e.jsx(Xe.div,{"data-state":o.hasThumb?"visible":"hidden",...n,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...a},onPointerDownCapture:De(s.onPointerDownCapture,x=>{const u=x.target.getBoundingClientRect(),y=x.clientX-u.left,h=x.clientY-u.top;o.onThumbPointerDown({x:y,y:h})}),onPointerUp:De(s.onPointerUp,o.onThumbPointerUp)})});rm.displayName=Cn;var qo="ScrollAreaCorner",am=d.forwardRef((s,t)=>{const r=Vt(qo,s.__scopeScrollArea),a=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&a?e.jsx(av,{...s,ref:t}):null});am.displayName=qo;var av=d.forwardRef((s,t)=>{const{__scopeScrollArea:r,...a}=s,n=Vt(qo,r),[i,o]=d.useState(0),[l,c]=d.useState(0),m=!!(i&&l);return ha(n.scrollbarX,()=>{var x;const p=((x=n.scrollbarX)==null?void 0:x.offsetHeight)||0;n.onCornerHeightChange(p),c(p)}),ha(n.scrollbarY,()=>{var x;const p=((x=n.scrollbarY)==null?void 0:x.offsetWidth)||0;n.onCornerWidthChange(p),o(p)}),m?e.jsx(Xe.div,{...a,ref:t,style:{width:i,height:l,position:"absolute",right:n.dir==="ltr"?0:void 0,left:n.dir==="rtl"?0:void 0,bottom:0,...s.style}}):null});function En(s){return s?parseInt(s,10):0}function nm(s,t){const r=s/t;return isNaN(r)?0:r}function Hn(s){const t=nm(s.viewport,s.content),r=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,a=(s.scrollbar.size-r)*t;return Math.max(a,18)}function nv(s,t,r,a="ltr"){const n=Hn(r),i=n/2,o=t||i,l=n-o,c=r.scrollbar.paddingStart+o,m=r.scrollbar.size-r.scrollbar.paddingEnd-l,p=r.content-r.viewport,x=a==="ltr"?[0,p]:[p*-1,0];return im([c,m],x)(s)}function Kl(s,t,r="ltr"){const a=Hn(t),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-n,o=t.content-t.viewport,l=i-a,c=r==="ltr"?[0,o]:[o*-1,0],m=Xi(s,c);return im([0,o],[0,l])(m)}function im(s,t){return r=>{if(s[0]===s[1]||t[0]===t[1])return t[0];const a=(t[1]-t[0])/(s[1]-s[0]);return t[0]+a*(r-s[0])}}function om(s,t){return s>0&&s<t}var iv=(s,t=()=>{})=>{let r={left:s.scrollLeft,top:s.scrollTop},a=0;return(function n(){const i={left:s.scrollLeft,top:s.scrollTop},o=r.left!==i.left,l=r.top!==i.top;(o||l)&&t(),r=i,a=window.requestAnimationFrame(n)})(),()=>window.cancelAnimationFrame(a)};function Vn(s,t){const r=Es(s),a=d.useRef(0);return d.useEffect(()=>()=>window.clearTimeout(a.current),[]),d.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(r,t)},[r,t])}function ha(s,t){const r=Es(t);$t(()=>{let a=0;if(s){const n=new ResizeObserver(()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(r)});return n.observe(s),()=>{window.cancelAnimationFrame(a),n.unobserve(s)}}},[s,r])}var lm=Zu,ov=Xu,lv=am;const cm=d.forwardRef(({className:s,children:t,...r},a)=>e.jsxs(lm,{ref:a,className:me("relative overflow-hidden",s),...r,children:[e.jsx(ov,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(dm,{}),e.jsx(lv,{})]}));cm.displayName=lm.displayName;const dm=d.forwardRef(({className:s,orientation:t="vertical",...r},a)=>e.jsx(Lo,{ref:a,orientation:t,className:me("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...r,children:e.jsx(rm,{className:"relative flex-1 rounded-full bg-border"})}));dm.displayName=Lo.displayName;function cv(s,t=[]){let r=[];function a(i,o){const l=d.createContext(o);l.displayName=i+"Context";const c=r.length;r=[...r,o];const m=x=>{var b;const{scope:g,children:u,...y}=x,h=((b=g==null?void 0:g[s])==null?void 0:b[c])||l,f=d.useMemo(()=>y,Object.values(y));return e.jsx(h.Provider,{value:f,children:u})};m.displayName=i+"Provider";function p(x,g){var h;const u=((h=g==null?void 0:g[s])==null?void 0:h[c])||l,y=d.useContext(u);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${x}\` must be used within \`${i}\``)}return[m,p]}const n=()=>{const i=r.map(o=>d.createContext(o));return function(l){const c=(l==null?void 0:l[s])||i;return d.useMemo(()=>({[`__scope${s}`]:{...l,[s]:c}}),[l,c])}};return n.scopeName=s,[a,dv(n,...t)]}function dv(...s){const t=s[0];if(s.length===1)return t;const r=()=>{const a=s.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const o=a.reduce((l,{useScope:c,scopeName:m})=>{const x=c(i)[`__scope${m}`];return{...l,...x}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}var uv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zo=uv.reduce((s,t)=>{const r=qn(`Primitive.${t}`),a=d.forwardRef((n,i)=>{const{asChild:o,...l}=n,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...l,ref:i})});return a.displayName=`Primitive.${t}`,{...s,[t]:a}},{}),hi={exports:{}},pi={};/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Gl;function mv(){if(Gl)return pi;Gl=1;var s=ah();function t(x,g){return x===g&&(x!==0||1/x===1/g)||x!==x&&g!==g}var r=typeof Object.is=="function"?Object.is:t,a=s.useState,n=s.useEffect,i=s.useLayoutEffect,o=s.useDebugValue;function l(x,g){var u=g(),y=a({inst:{value:u,getSnapshot:g}}),h=y[0].inst,f=y[1];return i(function(){h.value=u,h.getSnapshot=g,c(h)&&f({inst:h})},[x,u,g]),n(function(){return c(h)&&f({inst:h}),x(function(){c(h)&&f({inst:h})})},[x]),o(u),u}function c(x){var g=x.getSnapshot;x=x.value;try{var u=g();return!r(x,u)}catch{return!0}}function m(x,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:l;return pi.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:p,pi}var Yl;function hv(){return Yl||(Yl=1,hi.exports=mv()),hi.exports}var pv=hv();function fv(){return pv.useSyncExternalStore(xv,()=>!0,()=>!1)}function xv(){return()=>{}}var $o="Avatar",[gv]=cv($o),[yv,um]=gv($o),mm=d.forwardRef((s,t)=>{const{__scopeAvatar:r,...a}=s,[n,i]=d.useState("idle");return e.jsx(yv,{scope:r,imageLoadingStatus:n,onImageLoadingStatusChange:i,children:e.jsx(zo.span,{...a,ref:t})})});mm.displayName=$o;var hm="AvatarImage",pm=d.forwardRef((s,t)=>{const{__scopeAvatar:r,src:a,onLoadingStatusChange:n=()=>{},...i}=s,o=um(hm,r),l=bv(a,i),c=Es(m=>{n(m),o.onImageLoadingStatusChange(m)});return $t(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?e.jsx(zo.img,{...i,ref:t,src:a}):null});pm.displayName=hm;var fm="AvatarFallback",xm=d.forwardRef((s,t)=>{const{__scopeAvatar:r,delayMs:a,...n}=s,i=um(fm,r),[o,l]=d.useState(a===void 0);return d.useEffect(()=>{if(a!==void 0){const c=window.setTimeout(()=>l(!0),a);return()=>window.clearTimeout(c)}},[a]),o&&i.imageLoadingStatus!=="loaded"?e.jsx(zo.span,{...n,ref:t}):null});xm.displayName=fm;function Ql(s,t){return s?t?(s.src!==t&&(s.src=t),s.complete&&s.naturalWidth>0?"loaded":"loading"):"error":"idle"}function bv(s,{referrerPolicy:t,crossOrigin:r}){const a=fv(),n=d.useRef(null),i=a?(n.current||(n.current=new window.Image),n.current):null,[o,l]=d.useState(()=>Ql(i,s));return $t(()=>{l(Ql(i,s))},[i,s]),$t(()=>{const c=x=>()=>{l(x)};if(!i)return;const m=c("loaded"),p=c("error");return i.addEventListener("load",m),i.addEventListener("error",p),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",m),i.removeEventListener("error",p)}},[i,r,t]),o}var gm=mm,ym=pm,bm=xm;const no=d.forwardRef(({className:s,...t},r)=>e.jsx(gm,{ref:r,className:me("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...t}));no.displayName=gm.displayName;const vv=d.forwardRef(({className:s,...t},r)=>e.jsx(ym,{ref:r,className:me("aspect-square h-full w-full",s),...t}));vv.displayName=ym.displayName;const io=d.forwardRef(({className:s,...t},r)=>e.jsx(bm,{ref:r,className:me("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...t}));io.displayName=bm.displayName;function ls(s){const t=Object.prototype.toString.call(s);return s instanceof Date||typeof s=="object"&&t==="[object Date]"?new s.constructor(+s):typeof s=="number"||t==="[object Number]"||typeof s=="string"||t==="[object String]"?new Date(s):new Date(NaN)}function Rr(s,t){return s instanceof Date?new s.constructor(t):new Date(t)}const vm=6048e5,jv=864e5;let wv={};function Wn(){return wv}function za(s,t){var l,c,m,p;const r=Wn(),a=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(m=r.locale)==null?void 0:m.options)==null?void 0:p.weekStartsOn)??0,n=ls(s),i=n.getDay(),o=(i<a?7:0)+i-a;return n.setDate(n.getDate()-o),n.setHours(0,0,0,0),n}function Tn(s){return za(s,{weekStartsOn:1})}function jm(s){const t=ls(s),r=t.getFullYear(),a=Rr(s,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const n=Tn(a),i=Rr(s,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=Tn(i);return t.getTime()>=n.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function Zl(s){const t=ls(s);return t.setHours(0,0,0,0),t}function Jl(s){const t=ls(s),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+s-+r}function Nv(s,t){const r=Zl(s),a=Zl(t),n=+r-Jl(r),i=+a-Jl(a);return Math.round((n-i)/jv)}function _v(s){const t=jm(s),r=Rr(s,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),Tn(r)}function Sv(s){return s instanceof Date||typeof s=="object"&&Object.prototype.toString.call(s)==="[object Date]"}function kv(s){if(!Sv(s)&&typeof s!="number")return!1;const t=ls(s);return!isNaN(Number(t))}function Cv(s){const t=ls(s),r=Rr(s,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}const Ev={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"}},Tv=(s,t,r)=>{let a;const n=Ev[s];return typeof n=="string"?a=n:t===1?a=n.one:a=n.other.replace("{{count}}",t.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+a:a+" ago":a};function fi(s){return(t={})=>{const r=t.width?String(t.width):s.defaultWidth;return s.formats[r]||s.formats[s.defaultWidth]}}const Pv={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Av={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Rv={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Mv={date:fi({formats:Pv,defaultWidth:"full"}),time:fi({formats:Av,defaultWidth:"full"}),dateTime:fi({formats:Rv,defaultWidth:"full"})},Iv={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ov=(s,t,r,a)=>Iv[s];function ka(s){return(t,r)=>{const a=r!=null&&r.context?String(r.context):"standalone";let n;if(a==="formatting"&&s.formattingValues){const o=s.defaultFormattingWidth||s.defaultWidth,l=r!=null&&r.width?String(r.width):o;n=s.formattingValues[l]||s.formattingValues[o]}else{const o=s.defaultWidth,l=r!=null&&r.width?String(r.width):s.defaultWidth;n=s.values[l]||s.values[o]}const i=s.argumentCallback?s.argumentCallback(t):t;return n[i]}}const Dv={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Lv={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Fv={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"]},qv={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"]},zv={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"}},$v={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"}},Bv=(s,t)=>{const r=Number(s),a=r%100;if(a>20||a<10)switch(a%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},Uv={ordinalNumber:Bv,era:ka({values:Dv,defaultWidth:"wide"}),quarter:ka({values:Lv,defaultWidth:"wide",argumentCallback:s=>s-1}),month:ka({values:Fv,defaultWidth:"wide"}),day:ka({values:qv,defaultWidth:"wide"}),dayPeriod:ka({values:zv,defaultWidth:"wide",formattingValues:$v,defaultFormattingWidth:"wide"})};function Ca(s){return(t,r={})=>{const a=r.width,n=a&&s.matchPatterns[a]||s.matchPatterns[s.defaultMatchWidth],i=t.match(n);if(!i)return null;const o=i[0],l=a&&s.parsePatterns[a]||s.parsePatterns[s.defaultParseWidth],c=Array.isArray(l)?Vv(l,x=>x.test(o)):Hv(l,x=>x.test(o));let m;m=s.valueCallback?s.valueCallback(c):c,m=r.valueCallback?r.valueCallback(m):m;const p=t.slice(o.length);return{value:m,rest:p}}}function Hv(s,t){for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)&&t(s[r]))return r}function Vv(s,t){for(let r=0;r<s.length;r++)if(t(s[r]))return r}function Wv(s){return(t,r={})=>{const a=t.match(s.matchPattern);if(!a)return null;const n=a[0],i=t.match(s.parsePattern);if(!i)return null;let o=s.valueCallback?s.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;const l=t.slice(n.length);return{value:o,rest:l}}}const Kv=/^(\d+)(th|st|nd|rd)?/i,Gv=/\d+/i,Yv={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},Qv={any:[/^b/i,/^(a|c)/i]},Zv={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Jv={any:[/1/i,/2/i,/3/i,/4/i]},Xv={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},e0={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]},t0={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},s0={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]},r0={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},a0={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}},n0={ordinalNumber:Wv({matchPattern:Kv,parsePattern:Gv,valueCallback:s=>parseInt(s,10)}),era:Ca({matchPatterns:Yv,defaultMatchWidth:"wide",parsePatterns:Qv,defaultParseWidth:"any"}),quarter:Ca({matchPatterns:Zv,defaultMatchWidth:"wide",parsePatterns:Jv,defaultParseWidth:"any",valueCallback:s=>s+1}),month:Ca({matchPatterns:Xv,defaultMatchWidth:"wide",parsePatterns:e0,defaultParseWidth:"any"}),day:Ca({matchPatterns:t0,defaultMatchWidth:"wide",parsePatterns:s0,defaultParseWidth:"any"}),dayPeriod:Ca({matchPatterns:r0,defaultMatchWidth:"any",parsePatterns:a0,defaultParseWidth:"any"})},i0={code:"en-US",formatDistance:Tv,formatLong:Mv,formatRelative:Ov,localize:Uv,match:n0,options:{weekStartsOn:0,firstWeekContainsDate:1}};function o0(s){const t=ls(s);return Nv(t,Cv(t))+1}function l0(s){const t=ls(s),r=+Tn(t)-+_v(t);return Math.round(r/vm)+1}function wm(s,t){var p,x,g,u;const r=ls(s),a=r.getFullYear(),n=Wn(),i=(t==null?void 0:t.firstWeekContainsDate)??((x=(p=t==null?void 0:t.locale)==null?void 0:p.options)==null?void 0:x.firstWeekContainsDate)??n.firstWeekContainsDate??((u=(g=n.locale)==null?void 0:g.options)==null?void 0:u.firstWeekContainsDate)??1,o=Rr(s,0);o.setFullYear(a+1,0,i),o.setHours(0,0,0,0);const l=za(o,t),c=Rr(s,0);c.setFullYear(a,0,i),c.setHours(0,0,0,0);const m=za(c,t);return r.getTime()>=l.getTime()?a+1:r.getTime()>=m.getTime()?a:a-1}function c0(s,t){var l,c,m,p;const r=Wn(),a=(t==null?void 0:t.firstWeekContainsDate)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(m=r.locale)==null?void 0:m.options)==null?void 0:p.firstWeekContainsDate)??1,n=wm(s,t),i=Rr(s,0);return i.setFullYear(n,0,a),i.setHours(0,0,0,0),za(i,t)}function d0(s,t){const r=ls(s),a=+za(r,t)-+c0(r,t);return Math.round(a/vm)+1}function He(s,t){const r=s<0?"-":"",a=Math.abs(s).toString().padStart(t,"0");return r+a}const zs={y(s,t){const r=s.getFullYear(),a=r>0?r:1-r;return He(t==="yy"?a%100:a,t.length)},M(s,t){const r=s.getMonth();return t==="M"?String(r+1):He(r+1,2)},d(s,t){return He(s.getDate(),t.length)},a(s,t){const r=s.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(s,t){return He(s.getHours()%12||12,t.length)},H(s,t){return He(s.getHours(),t.length)},m(s,t){return He(s.getMinutes(),t.length)},s(s,t){return He(s.getSeconds(),t.length)},S(s,t){const r=t.length,a=s.getMilliseconds(),n=Math.trunc(a*Math.pow(10,r-3));return He(n,t.length)}},Fr={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Xl={G:function(s,t,r){const a=s.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(a,{width:"abbreviated"});case"GGGGG":return r.era(a,{width:"narrow"});case"GGGG":default:return r.era(a,{width:"wide"})}},y:function(s,t,r){if(t==="yo"){const a=s.getFullYear(),n=a>0?a:1-a;return r.ordinalNumber(n,{unit:"year"})}return zs.y(s,t)},Y:function(s,t,r,a){const n=wm(s,a),i=n>0?n:1-n;if(t==="YY"){const o=i%100;return He(o,2)}return t==="Yo"?r.ordinalNumber(i,{unit:"year"}):He(i,t.length)},R:function(s,t){const r=jm(s);return He(r,t.length)},u:function(s,t){const r=s.getFullYear();return He(r,t.length)},Q:function(s,t,r){const a=Math.ceil((s.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return He(a,2);case"Qo":return r.ordinalNumber(a,{unit:"quarter"});case"QQQ":return r.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(a,{width:"wide",context:"formatting"})}},q:function(s,t,r){const a=Math.ceil((s.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return He(a,2);case"qo":return r.ordinalNumber(a,{unit:"quarter"});case"qqq":return r.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(a,{width:"wide",context:"standalone"})}},M:function(s,t,r){const a=s.getMonth();switch(t){case"M":case"MM":return zs.M(s,t);case"Mo":return r.ordinalNumber(a+1,{unit:"month"});case"MMM":return r.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(a,{width:"wide",context:"formatting"})}},L:function(s,t,r){const a=s.getMonth();switch(t){case"L":return String(a+1);case"LL":return He(a+1,2);case"Lo":return r.ordinalNumber(a+1,{unit:"month"});case"LLL":return r.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(a,{width:"wide",context:"standalone"})}},w:function(s,t,r,a){const n=d0(s,a);return t==="wo"?r.ordinalNumber(n,{unit:"week"}):He(n,t.length)},I:function(s,t,r){const a=l0(s);return t==="Io"?r.ordinalNumber(a,{unit:"week"}):He(a,t.length)},d:function(s,t,r){return t==="do"?r.ordinalNumber(s.getDate(),{unit:"date"}):zs.d(s,t)},D:function(s,t,r){const a=o0(s);return t==="Do"?r.ordinalNumber(a,{unit:"dayOfYear"}):He(a,t.length)},E:function(s,t,r){const a=s.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(a,{width:"short",context:"formatting"});case"EEEE":default:return r.day(a,{width:"wide",context:"formatting"})}},e:function(s,t,r,a){const n=s.getDay(),i=(n-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return He(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(n,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(n,{width:"short",context:"formatting"});case"eeee":default:return r.day(n,{width:"wide",context:"formatting"})}},c:function(s,t,r,a){const n=s.getDay(),i=(n-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return He(i,t.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(n,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(n,{width:"narrow",context:"standalone"});case"cccccc":return r.day(n,{width:"short",context:"standalone"});case"cccc":default:return r.day(n,{width:"wide",context:"standalone"})}},i:function(s,t,r){const a=s.getDay(),n=a===0?7:a;switch(t){case"i":return String(n);case"ii":return He(n,t.length);case"io":return r.ordinalNumber(n,{unit:"day"});case"iii":return r.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(a,{width:"short",context:"formatting"});case"iiii":default:return r.day(a,{width:"wide",context:"formatting"})}},a:function(s,t,r){const n=s.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(s,t,r){const a=s.getHours();let n;switch(a===12?n=Fr.noon:a===0?n=Fr.midnight:n=a/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(s,t,r){const a=s.getHours();let n;switch(a>=17?n=Fr.evening:a>=12?n=Fr.afternoon:a>=4?n=Fr.morning:n=Fr.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(s,t,r){if(t==="ho"){let a=s.getHours()%12;return a===0&&(a=12),r.ordinalNumber(a,{unit:"hour"})}return zs.h(s,t)},H:function(s,t,r){return t==="Ho"?r.ordinalNumber(s.getHours(),{unit:"hour"}):zs.H(s,t)},K:function(s,t,r){const a=s.getHours()%12;return t==="Ko"?r.ordinalNumber(a,{unit:"hour"}):He(a,t.length)},k:function(s,t,r){let a=s.getHours();return a===0&&(a=24),t==="ko"?r.ordinalNumber(a,{unit:"hour"}):He(a,t.length)},m:function(s,t,r){return t==="mo"?r.ordinalNumber(s.getMinutes(),{unit:"minute"}):zs.m(s,t)},s:function(s,t,r){return t==="so"?r.ordinalNumber(s.getSeconds(),{unit:"second"}):zs.s(s,t)},S:function(s,t){return zs.S(s,t)},X:function(s,t,r){const a=s.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return tc(a);case"XXXX":case"XX":return dr(a);case"XXXXX":case"XXX":default:return dr(a,":")}},x:function(s,t,r){const a=s.getTimezoneOffset();switch(t){case"x":return tc(a);case"xxxx":case"xx":return dr(a);case"xxxxx":case"xxx":default:return dr(a,":")}},O:function(s,t,r){const a=s.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+ec(a,":");case"OOOO":default:return"GMT"+dr(a,":")}},z:function(s,t,r){const a=s.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+ec(a,":");case"zzzz":default:return"GMT"+dr(a,":")}},t:function(s,t,r){const a=Math.trunc(s.getTime()/1e3);return He(a,t.length)},T:function(s,t,r){const a=s.getTime();return He(a,t.length)}};function ec(s,t=""){const r=s>0?"-":"+",a=Math.abs(s),n=Math.trunc(a/60),i=a%60;return i===0?r+String(n):r+String(n)+t+He(i,2)}function tc(s,t){return s%60===0?(s>0?"-":"+")+He(Math.abs(s)/60,2):dr(s,t)}function dr(s,t=""){const r=s>0?"-":"+",a=Math.abs(s),n=He(Math.trunc(a/60),2),i=He(a%60,2);return r+n+t+i}const sc=(s,t)=>{switch(s){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"})}},Nm=(s,t)=>{switch(s){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"})}},u0=(s,t)=>{const r=s.match(/(P+)(p+)?/)||[],a=r[1],n=r[2];if(!n)return sc(s,t);let i;switch(a){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",sc(a,t)).replace("{{time}}",Nm(n,t))},m0={p:Nm,P:u0},h0=/^D+$/,p0=/^Y+$/,f0=["D","DD","YY","YYYY"];function x0(s){return h0.test(s)}function g0(s){return p0.test(s)}function y0(s,t,r){const a=b0(s,t,r);if(console.warn(a),f0.includes(s))throw new RangeError(a)}function b0(s,t,r){const a=s[0]==="Y"?"years":"days of the month";return`Use \`${s.toLowerCase()}\` instead of \`${s}\` (in \`${t}\`) for formatting ${a} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const v0=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,j0=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,w0=/^'([^]*?)'?$/,N0=/''/g,_0=/[a-zA-Z]/;function S0(s,t,r){var p,x,g,u;const a=Wn(),n=a.locale??i0,i=a.firstWeekContainsDate??((x=(p=a.locale)==null?void 0:p.options)==null?void 0:x.firstWeekContainsDate)??1,o=a.weekStartsOn??((u=(g=a.locale)==null?void 0:g.options)==null?void 0:u.weekStartsOn)??0,l=ls(s);if(!kv(l))throw new RangeError("Invalid time value");let c=t.match(j0).map(y=>{const h=y[0];if(h==="p"||h==="P"){const f=m0[h];return f(y,n.formatLong)}return y}).join("").match(v0).map(y=>{if(y==="''")return{isToken:!1,value:"'"};const h=y[0];if(h==="'")return{isToken:!1,value:k0(y)};if(Xl[h])return{isToken:!0,value:y};if(h.match(_0))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:y}});n.localize.preprocessor&&(c=n.localize.preprocessor(l,c));const m={firstWeekContainsDate:i,weekStartsOn:o,locale:n};return c.map(y=>{if(!y.isToken)return y.value;const h=y.value;(g0(h)||x0(h))&&y0(h,t,String(s));const f=Xl[h[0]];return f(l,h,n.localize,m)}).join("")}function k0(s){const t=s.match(w0);return t?t[1].replace(N0,"'"):s}function _m(){const{user:s}=Bt(),[t,r]=d.useState([]),[a,n]=d.useState([]),[i,o]=d.useState(null),[l,c]=d.useState(""),[m,p]=d.useState(!0),[x,g]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{y(),h();const v=M.channel("admin_messages").on("postgres_changes",{event:"INSERT",schema:"public",table:"admin_messages"},async j=>{const _=j.new;if(!(!_.recipient_id||_.sender_id===(s==null?void 0:s.id)||_.recipient_id===(s==null?void 0:s.id)))return;const{data:E}=await M.from("profiles").select("email, full_name").eq("user_id",_.sender_id).single();r(O=>[...O,{..._,sender_email:E==null?void 0:E.email,sender_name:E==null?void 0:E.full_name}])}).subscribe();return()=>{M.removeChannel(v)}},[i,s==null?void 0:s.id]),d.useEffect(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[t]);const y=async()=>{try{const{data:v,error:j}=await M.from("user_roles").select("user_id, role");if(j)throw j;const _=(v||[]).map(D=>D.user_id).filter(D=>D!==(s==null?void 0:s.id)),{data:I}=await M.from("profiles").select("user_id, email, full_name").in("user_id",_),E=new Map((I||[]).map(D=>[D.user_id,D])),O=(v||[]).filter(D=>D.user_id!==(s==null?void 0:s.id)).map(D=>{const N=E.get(D.user_id);return{user_id:D.user_id,role:D.role,email:N==null?void 0:N.email,full_name:N==null?void 0:N.full_name}});n(O)}catch(v){console.error("Error fetching admin users:",v)}},h=async()=>{try{p(!0);let v=M.from("admin_messages").select("*");i?v=v.or(`and(sender_id.eq.${s==null?void 0:s.id},recipient_id.eq.${i.user_id}),and(sender_id.eq.${i.user_id},recipient_id.eq.${s==null?void 0:s.id})`):v=v.is("recipient_id",null);const{data:j,error:_}=await v.order("created_at",{ascending:!0}).limit(100);if(_)throw _;const I=[...new Set((j||[]).map(N=>N.sender_id))],{data:E}=await M.from("profiles").select("user_id, email, full_name").in("user_id",I),O=new Map((E||[]).map(N=>[N.user_id,N])),D=(j||[]).map(N=>{const T=O.get(N.sender_id);return{...N,sender_email:T==null?void 0:T.email,sender_name:T==null?void 0:T.full_name}});r(D)}catch(v){console.error("Error fetching messages:",v),C.error("Failed to load messages")}finally{p(!1)}},f=async v=>{if(v.preventDefault(),!(!l.trim()||!s||x)){g(!0);try{const{error:j}=await M.from("admin_messages").insert({sender_id:s.id,recipient_id:(i==null?void 0:i.user_id)||null,content:l.trim()});if(j)throw j;c("")}catch(j){console.error("Error sending message:",j),C.error("Failed to send message")}finally{g(!1)}}},b=(v,j)=>j?j.split(" ").map(_=>_[0]).join("").toUpperCase():v?v[0].toUpperCase():"A";return e.jsxs(X,{className:"flex flex-col h-[600px] border-none shadow-none md:border md:shadow-sm overflow-hidden",children:[e.jsxs(ye,{className:"border-b pb-4 flex-row items-center justify-between space-y-0",children:[e.jsxs(be,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Ra,{className:"h-5 w-5 text-primary"}),i?`Chat with ${i.full_name||i.email}`:"Global Admin Chat"]}),i&&e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>o(null),children:"Back to Global"})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-64 border-r bg-muted/30 hidden md:block overflow-y-auto",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Members"})}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsxs("button",{onClick:()=>o(null),className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${i?"hover:bg-muted":"bg-primary/10 text-primary"}`,children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary flex items-center justify-center text-primary-foreground font-bold",children:"G"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:"Global Chat"}),e.jsx("p",{className:"text-xs opacity-70 truncate",children:"All admins"})]})]}),a.map(v=>{var j;return e.jsxs("button",{onClick:()=>o(v),className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${(i==null?void 0:i.user_id)===v.user_id?"bg-primary/10 text-primary":"hover:bg-muted"}`,children:[e.jsx(no,{className:"h-8 w-8",children:e.jsx(io,{className:"bg-muted-foreground/20 text-muted-foreground text-xs",children:b(v.email,v.full_name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:v.full_name||((j=v.email)==null?void 0:j.split("@")[0])}),e.jsx("p",{className:"text-xs opacity-70 truncate capitalize",children:v.role})]})]},v.user_id)})]})]}),e.jsxs(ee,{className:"flex-1 p-0 overflow-hidden flex flex-col",children:[e.jsx(cm,{className:"flex-1 p-4",children:m?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):t.length===0?e.jsxs("div",{className:"flex flex-col h-full items-center justify-center text-muted-foreground space-y-2 py-20",children:[e.jsx(Ra,{className:"h-10 w-10 opacity-20"}),e.jsx("p",{className:"text-sm italic",children:"No messages yet. Start the conversation!"})]}):e.jsxs("div",{className:"space-y-4",children:[t.map(v=>{var _;const j=v.sender_id===(s==null?void 0:s.id);return e.jsxs("div",{className:`flex items-start gap-2 ${j?"flex-row-reverse":"flex-row"}`,children:[e.jsx(no,{className:"h-8 w-8 mt-1 flex-shrink-0",children:e.jsx(io,{className:j?"bg-primary text-primary-foreground text-xs":"bg-muted text-xs",children:b(v.sender_email,v.sender_name)})}),e.jsxs("div",{className:`flex flex-col ${j?"items-end":"items-start"} max-w-[80%]`,children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 mb-1",children:[e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase",children:j?"You":v.sender_name||((_=v.sender_email)==null?void 0:_.split("@")[0])||"Admin"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:S0(new Date(v.created_at),"HH:mm")})]}),e.jsx("div",{className:`rounded-2xl px-4 py-2 text-sm shadow-sm ${j?"bg-primary text-primary-foreground rounded-tr-none":"bg-muted text-foreground rounded-tl-none"}`,children:v.content})]})]},v.id)}),e.jsx("div",{ref:u})]})}),e.jsx("div",{className:"p-4 border-t",children:e.jsxs("form",{onSubmit:f,className:"flex w-full gap-2",children:[e.jsx(Q,{placeholder:i?`Message ${i.full_name||i.email}...`:"Message global chat...",value:l,onChange:v=>c(v.target.value),disabled:x,className:"flex-1"}),e.jsx(R,{type:"submit",size:"icon",disabled:x||!l.trim(),children:x?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsx(In,{className:"h-4 w-4"})})]})})]})]})]})}const rc={title:"",description:"",file_url:"",thumbnail_url:"",category:"Resource",is_active:!0};function C0(){const s=is(),[t,r]=d.useState(!1),[a,n]=d.useState(null),[i,o]=d.useState(rc),{data:l,isLoading:c}=os({queryKey:["digital-library"],queryFn:async()=>{const{data:h,error:f}=await M.from("digital_library").select("*").order("created_at",{ascending:!1});if(f)throw f;return h}}),m=it({mutationFn:async h=>{const{error:f}=await M.from("digital_library").insert(h);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["digital-library"]}),C.success("Library item created successfully"),g()},onError:h=>C.error("Failed to create: "+h.message)}),p=it({mutationFn:async({id:h,data:f})=>{const{error:b}=await M.from("digital_library").update(f).eq("id",h);if(b)throw b},onSuccess:()=>{s.invalidateQueries({queryKey:["digital-library"]}),C.success("Library item updated successfully"),g()},onError:h=>C.error("Failed to update: "+h.message)}),x=it({mutationFn:async h=>{const{error:f}=await M.from("digital_library").delete().eq("id",h);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["digital-library"]}),C.success("Library item deleted successfully")},onError:h=>C.error("Failed to delete: "+h.message)}),g=()=>{o(rc),n(null),r(!1)},u=h=>{n(h),o({title:h.title,description:h.description||"",file_url:h.file_url||"",thumbnail_url:h.thumbnail_url||"",category:h.category||"Resource",is_active:h.is_active}),r(!0)},y=()=>{if(!i.title){C.error("Title is required");return}a?p.mutate({id:a.id,data:i}):m.mutate(i)};return c?e.jsx(ue,{className:"h-8 w-8 animate-spin"}):e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Hc,{className:"h-5 w-5"}),"Digital Library"]}),e.jsx(Be,{children:"Manage educational resources and documentation"})]}),e.jsxs(Ms,{open:t,onOpenChange:h=>{r(h),h||g()},children:[e.jsx(Mr,{asChild:!0,children:e.jsxs(R,{className:"gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Add Resource"]})}),e.jsxs(gs,{className:"max-w-lg",children:[e.jsx(Is,{children:e.jsx(Os,{children:a?"Edit Resource":"Add New Resource"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Title *"}),e.jsx(Q,{value:i.title,onChange:h=>o({...i,title:h.target.value}),placeholder:"e.g. Sustainable Fashion Guide"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Category"}),e.jsx(Q,{value:i.category||"",onChange:h=>o({...i,category:h.target.value}),placeholder:"e.g. Guide, Whitepaper"})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-8",children:[e.jsx("input",{type:"checkbox",id:"is_active",checked:i.is_active,onChange:h=>o({...i,is_active:h.target.checked}),className:"h-4 w-4 rounded border-gray-300"}),e.jsx(B,{htmlFor:"is_active",children:"Active / Visible"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Description"}),e.jsx(qt,{value:i.description||"",onChange:h=>o({...i,description:h.target.value}),placeholder:"What is this resource about?",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"File URL"}),e.jsx(Q,{value:i.file_url||"",onChange:h=>o({...i,file_url:h.target.value}),placeholder:"Link to PDF or document"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Thumbnail URL"}),e.jsx(Q,{value:i.thumbnail_url||"",onChange:h=>o({...i,thumbnail_url:h.target.value}),placeholder:"Link to cover image"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:g,children:"Cancel"}),e.jsxs(R,{onClick:y,disabled:m.isPending||p.isPending,children:[(m.isPending||p.isPending)&&e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Update":"Create"]})]})]})]})]})]}),e.jsx(ee,{children:l&&l.length>0?e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Title"}),e.jsx(ae,{children:"Category"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{children:"File"}),e.jsx(ae,{className:"w-24",children:"Actions"})]})}),e.jsx(Rt,{children:l.map(h=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium",children:h.title}),e.jsx(se,{children:h.category||"-"}),e.jsx(se,{children:e.jsx(Le,{variant:h.is_active?"default":"secondary",children:h.is_active?"Active":"Hidden"})}),e.jsx(se,{children:h.file_url?e.jsxs("a",{href:h.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(hs,{className:"h-3 w-3"}),"Link"]}):"-"}),e.jsx(se,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>u(h),children:e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>x.mutate(h.id),children:e.jsx(xs,{className:"h-4 w-4"})})]})})]},h.id))})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No library items yet."})})]})}const ac={title:"",description:"",file_url:"",report_type:"Impact",status:"published"};function E0(){const s=is(),[t,r]=d.useState(!1),[a,n]=d.useState(null),[i,o]=d.useState(ac),{data:l,isLoading:c}=os({queryKey:["reports"],queryFn:async()=>{const{data:h,error:f}=await M.from("reports").select("*").order("created_at",{ascending:!1});if(f)throw f;return h}}),m=it({mutationFn:async h=>{const{error:f}=await M.from("reports").insert(h);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["reports"]}),C.success("Report created successfully"),g()},onError:h=>C.error("Failed to create: "+h.message)}),p=it({mutationFn:async({id:h,data:f})=>{const{error:b}=await M.from("reports").update(f).eq("id",h);if(b)throw b},onSuccess:()=>{s.invalidateQueries({queryKey:["reports"]}),C.success("Report updated successfully"),g()},onError:h=>C.error("Failed to update: "+h.message)}),x=it({mutationFn:async h=>{const{error:f}=await M.from("reports").delete().eq("id",h);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["reports"]}),C.success("Report deleted successfully")},onError:h=>C.error("Failed to delete: "+h.message)}),g=()=>{o(ac),n(null),r(!1)},u=h=>{n(h),o({title:h.title,description:h.description||"",file_url:h.file_url||"",report_type:h.report_type||"Impact",status:h.status||"published"}),r(!0)},y=()=>{if(!i.title){C.error("Title is required");return}a?p.mutate({id:a.id,data:i}):m.mutate(i)};return c?e.jsx(ue,{className:"h-8 w-8 animate-spin"}):e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(bo,{className:"h-5 w-5"}),"Reports Management"]}),e.jsx(Be,{children:"Manage and publish official reports"})]}),e.jsxs(Ms,{open:t,onOpenChange:h=>{r(h),h||g()},children:[e.jsx(Mr,{asChild:!0,children:e.jsxs(R,{className:"gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"New Report"]})}),e.jsxs(gs,{className:"max-w-lg",children:[e.jsx(Is,{children:e.jsx(Os,{children:a?"Edit Report":"Create New Report"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Title *"}),e.jsx(Q,{value:i.title,onChange:h=>o({...i,title:h.target.value}),placeholder:"e.g. Annual Impact Report 2023"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Type"}),e.jsxs(ua,{value:i.report_type||"",onValueChange:h=>o({...i,report_type:h}),children:[e.jsx(Pr,{children:e.jsx(ma,{placeholder:"Select type"})}),e.jsxs(Ar,{children:[e.jsx(nt,{value:"Impact",children:"Impact"}),e.jsx(nt,{value:"Financial",children:"Financial"}),e.jsx(nt,{value:"Annual",children:"Annual"}),e.jsx(nt,{value:"Quarterly",children:"Quarterly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Status"}),e.jsxs(ua,{value:i.status||"",onValueChange:h=>o({...i,status:h}),children:[e.jsx(Pr,{children:e.jsx(ma,{placeholder:"Select status"})}),e.jsxs(Ar,{children:[e.jsx(nt,{value:"published",children:"Published"}),e.jsx(nt,{value:"draft",children:"Draft"}),e.jsx(nt,{value:"archived",children:"Archived"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Description"}),e.jsx(qt,{value:i.description||"",onChange:h=>o({...i,description:h.target.value}),placeholder:"Brief summary of the report",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"File URL"}),e.jsx(Q,{value:i.file_url||"",onChange:h=>o({...i,file_url:h.target.value}),placeholder:"Link to PDF or document"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:g,children:"Cancel"}),e.jsxs(R,{onClick:y,disabled:m.isPending||p.isPending,children:[(m.isPending||p.isPending)&&e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Update":"Create"]})]})]})]})]})]}),e.jsx(ee,{children:l&&l.length>0?e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Title"}),e.jsx(ae,{children:"Type"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{children:"Date"}),e.jsx(ae,{className:"w-24",children:"Actions"})]})}),e.jsx(Rt,{children:l.map(h=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium",children:h.title}),e.jsx(se,{children:h.report_type||"-"}),e.jsx(se,{children:e.jsx(Le,{variant:h.status==="published"?"default":"secondary",children:h.status})}),e.jsx(se,{children:new Date(h.created_at).toLocaleDateString()}),e.jsx(se,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>u(h),children:e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>x.mutate(h.id),children:e.jsx(xs,{className:"h-4 w-4"})})]})})]},h.id))})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No reports yet."})})]})}var Kn="Switch",[T0]=pa(Kn),[P0,A0]=T0(Kn),Sm=d.forwardRef((s,t)=>{const{__scopeSwitch:r,name:a,checked:n,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:m,form:p,...x}=s,[g,u]=d.useState(null),y=rt(t,j=>u(j)),h=d.useRef(!1),f=g?p||!!g.closest("form"):!0,[b,v]=un({prop:n,defaultProp:i??!1,onChange:m,caller:Kn});return e.jsxs(P0,{scope:r,checked:b,disabled:l,children:[e.jsx(Xe.button,{type:"button",role:"switch","aria-checked":b,"aria-required":o,"data-state":Tm(b),"data-disabled":l?"":void 0,disabled:l,value:c,...x,ref:y,onClick:De(s.onClick,j=>{v(_=>!_),f&&(h.current=j.isPropagationStopped(),h.current||j.stopPropagation())})}),f&&e.jsx(Em,{control:g,bubbles:!h.current,name:a,value:c,checked:b,required:o,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});Sm.displayName=Kn;var km="SwitchThumb",Cm=d.forwardRef((s,t)=>{const{__scopeSwitch:r,...a}=s,n=A0(km,r);return e.jsx(Xe.span,{"data-state":Tm(n.checked),"data-disabled":n.disabled?"":void 0,...a,ref:t})});Cm.displayName=km;var R0="SwitchBubbleInput",Em=d.forwardRef(({__scopeSwitch:s,control:t,checked:r,bubbles:a=!0,...n},i)=>{const o=d.useRef(null),l=rt(o,i),c=Po(r),m=Dc(t);return d.useEffect(()=>{const p=o.current;if(!p)return;const x=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(x,"checked").set;if(c!==r&&u){const y=new Event("click",{bubbles:a});u.call(p,r),p.dispatchEvent(y)}},[c,r,a]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...n,tabIndex:-1,ref:l,style:{...n.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Em.displayName=R0;function Tm(s){return s?"checked":"unchecked"}var Pm=Sm,M0=Cm;const dn=d.forwardRef(({className:s,...t},r)=>e.jsx(Pm,{className:me("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",s),...t,ref:r,children:e.jsx(M0,{className:me("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));dn.displayName=Pm.displayName;function I0(){const{user:s}=Bt(),[t,r]=d.useState([]),[a,n]=d.useState(!0),[i,o]=d.useState(!1),[l,c]=d.useState(!1),[m,p]=d.useState(!1),[x,g]=d.useState("api_keys"),[u,y]=d.useState({name:"",provider:"stripe",is_test_mode:!0,stripe_publishable_key:"",stripe_secret_key:""});d.useEffect(()=>{h()},[]);const h=async()=>{n(!0);const{data:N,error:T}=await M.from("payment_configurations").select("*").order("created_at",{ascending:!1});T?(console.error("Error fetching payment configs:",T),C.error("Failed to load payment configurations")):r(N||[]),n(!1)},f=async N=>{if(N.preventDefault(),!u.name.trim()){C.error("Please enter a configuration name");return}if(x==="api_keys"&&!u.stripe_publishable_key){C.error("Please enter your Stripe publishable key");return}const T={name:u.name.trim(),provider:u.provider,is_test_mode:u.is_test_mode,is_default:t.length===0,is_active:!0,stripe_publishable_key:u.stripe_publishable_key||null,connection_type:x,metadata:u.stripe_secret_key?{stripe_secret_key:u.stripe_secret_key,has_secret_key:!0}:{},created_by:s==null?void 0:s.id},{error:P}=await M.from("payment_configurations").insert(T);P?(console.error("Error creating config:",P),C.error("Failed to create payment configuration")):(C.success("Payment configuration created"),o(!1),b(),h())},b=()=>{y({name:"",provider:"stripe",is_test_mode:!0,stripe_publishable_key:"",stripe_secret_key:""}),g("api_keys")},v=async N=>{await M.from("payment_configurations").update({is_default:!1}).neq("id",N);const{error:T}=await M.from("payment_configurations").update({is_default:!0}).eq("id",N);T?C.error("Failed to update default configuration"):(C.success("Default payment configuration updated"),h())},j=async(N,T)=>{const{error:P}=await M.from("payment_configurations").update({is_active:!T}).eq("id",N);P?C.error("Failed to update configuration"):(C.success(`Configuration ${T?"deactivated":"activated"}`),h())},_=async(N,T)=>{const{error:P}=await M.from("payment_configurations").update({is_test_mode:!T,updated_at:new Date().toISOString()}).eq("id",N);P?C.error("Failed to update test mode"):(C.success(`Switched to ${T?"Live":"Test"} mode`),h())},I=async N=>{const T=t.find(S=>S.id===N);if(T!=null&&T.is_default){C.error("Cannot delete the default configuration. Set another as default first.");return}const{error:P}=await M.from("payment_configurations").delete().eq("id",N);P?C.error("Failed to delete configuration"):(C.success("Configuration deleted"),h())},E=async N=>{var T;c(!0);try{await new Promise(P=>setTimeout(P,1500)),(T=N.stripe_publishable_key)!=null&&T.startsWith("pk_")?C.success("Connection test successful! Stripe API is reachable."):C.error("Invalid publishable key format")}catch{C.error("Connection test failed")}finally{c(!1)}},O=()=>{{C.error("Stripe Connect Client ID not configured. Add VITE_STRIPE_CONNECT_CLIENT_ID to environment variables.");return}},D=N=>{navigator.clipboard.writeText(N),C.success("Copied to clipboard")};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Payment Configurations"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage Stripe accounts and payment settings"})]}),e.jsxs(Ms,{open:i,onOpenChange:o,children:[e.jsx(Mr,{asChild:!0,children:e.jsxs(R,{className:"gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Add Configuration"]})}),e.jsxs(gs,{className:"max-w-lg",children:[e.jsxs(Is,{children:[e.jsx(Os,{children:"Add Payment Configuration"}),e.jsx(Ya,{children:"Connect a Stripe account using API keys or Stripe Connect OAuth."})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"name",children:"Configuration Name"}),e.jsx(Q,{id:"name",placeholder:"e.g., Main Store, UK Market",value:u.name,onChange:N=>y({...u,name:N.target.value}),required:!0})]}),e.jsxs(Ir,{value:x,onValueChange:N=>g(N),children:[e.jsxs(ar,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ye,{value:"api_keys",className:"gap-2",children:[e.jsx(zh,{className:"h-4 w-4"}),"API Keys"]}),e.jsxs(Ye,{value:"connect",className:"gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),"Stripe Connect"]})]}),e.jsxs($e,{value:"api_keys",className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"publishable_key",children:"Publishable Key"}),e.jsx(Q,{id:"publishable_key",placeholder:"pk_test_...",value:u.stripe_publishable_key,onChange:N=>y({...u,stripe_publishable_key:N.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Found in your Stripe Dashboard → Developers → API keys"})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"secret_key",children:"Secret Key (stored securely)"}),e.jsxs("div",{className:"relative",children:[e.jsx(Q,{id:"secret_key",type:m?"text":"password",placeholder:"sk_test_...",value:u.stripe_secret_key,onChange:N=>y({...u,stripe_secret_key:N.target.value})}),e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 h-7 w-7",onClick:()=>p(!m),children:m?e.jsx(go,{className:"h-4 w-4"}):e.jsx(Ga,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Required for processing payments. Stored encrypted."})]}),e.jsxs(Ur,{children:[e.jsx(Nr,{className:"h-4 w-4"}),e.jsx(cn,{children:"Security Note"}),e.jsx(Hr,{children:"We store keys securely. For maximum security, you can also set STRIPE_SECRET_KEY in your Supabase Edge Function secrets."})]})]}),e.jsxs($e,{value:"connect",className:"space-y-4 pt-4",children:[e.jsxs(Ur,{children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx(cn,{children:"Stripe Connect OAuth"}),e.jsx(Hr,{children:"Connect your Stripe account using OAuth for secure, managed access. This is recommended for platforms managing multiple merchants."})]}),e.jsxs(R,{type:"button",variant:"outline",className:"w-full gap-2",onClick:O,children:[e.jsx(hs,{className:"h-4 w-4"}),"Connect with Stripe"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"You'll be redirected to Stripe to authorize the connection"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{id:"test_mode",checked:u.is_test_mode,onCheckedChange:N=>y({...u,is_test_mode:N})}),e.jsx(B,{htmlFor:"test_mode",className:"cursor-pointer",children:"Test Mode"})]}),e.jsx(Le,{variant:u.is_test_mode?"secondary":"default",children:u.is_test_mode?"Test":"Live"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(R,{type:"button",variant:"outline",className:"flex-1",onClick:()=>o(!1),children:"Cancel"}),e.jsx(R,{type:"submit",className:"flex-1",children:"Save Configuration"})]})]})]})]})]}),t.length===0?e.jsx(X,{children:e.jsxs(ee,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Ka,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Payment Configurations"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 text-center max-w-md",children:"Add your first Stripe configuration to start accepting payments."}),e.jsxs(R,{onClick:()=>o(!0),className:"gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Add Configuration"]})]})}):e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{className:"text-base",children:"Active Stripe Configurations"}),e.jsx(Be,{children:"We prioritize Default Live keys. If no Live key is active, we fall back to Test keys."})]}),e.jsx(ee,{children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Name"}),e.jsx(ae,{children:"Provider"}),e.jsx(ae,{children:"Type"}),e.jsx(ae,{children:"Mode"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{className:"text-right",children:"Actions"})]})}),e.jsx(Rt,{children:t.map(N=>e.jsxs(Qe,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:N.name}),N.is_default&&e.jsx(Le,{variant:"outline",className:"text-xs",children:"Default"})]})}),e.jsx(se,{children:e.jsx(Le,{variant:"secondary",className:"capitalize",children:N.provider})}),e.jsx(se,{children:e.jsx("span",{className:"text-sm text-muted-foreground capitalize",children:N.connection_type==="api_keys"?"API Keys":"Connect"})}),e.jsx(se,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{checked:!N.is_test_mode,onCheckedChange:()=>_(N.id,N.is_test_mode)}),e.jsx(Le,{variant:N.is_test_mode?"secondary":"default",children:N.is_test_mode?e.jsxs(e.Fragment,{children:[e.jsx(ap,{className:"h-3 w-3 mr-1"}),"Test"]}):e.jsxs(e.Fragment,{children:[e.jsx(pn,{className:"h-3 w-3 mr-1"}),"Live"]})})]})}),e.jsx(se,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{checked:N.is_active,onCheckedChange:()=>j(N.id,N.is_active)}),e.jsx("span",{className:`text-sm ${N.is_active?"text-green-600":"text-muted-foreground"}`,children:N.is_active?"Active":"Inactive"})]})}),e.jsx(se,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>E(N),disabled:l,title:"Test Connection",children:l?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"})}),!N.is_default&&e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>v(N.id),title:"Set as Default",children:e.jsx(pn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>I(N.id),title:"Delete",children:e.jsx(xs,{className:"h-4 w-4 text-destructive"})})]})})]},N.id))})]})})]}),e.jsxs(X,{children:[e.jsx(ye,{children:e.jsxs(be,{className:"text-base flex items-center gap-2",children:[e.jsx(np,{className:"h-4 w-4 text-amber-500"}),"Webhook Setup"]})}),e.jsxs(ee,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure webhooks in your Stripe Dashboard to receive payment events."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Webhook Endpoint URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{readOnly:!0,value:`${window.location.origin}/api/stripe-webhook`,className:"font-mono text-sm"}),e.jsx(R,{variant:"outline",size:"icon",onClick:()=>D(`${window.location.origin}/api/stripe-webhook`),children:e.jsx(fn,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Events to Subscribe"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["checkout.session.completed","payment_intent.succeeded","payment_intent.payment_failed","customer.subscription.created","customer.subscription.updated","customer.subscription.deleted"].map(N=>e.jsx(Le,{variant:"outline",className:"font-mono text-xs",children:N},N))})]}),e.jsxs(Ur,{children:[e.jsx(Nr,{className:"h-4 w-4"}),e.jsx(cn,{children:"Webhook Secret"}),e.jsxs(Hr,{children:["After creating the webhook in Stripe, add the signing secret to your Netlify environment variables as ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"STRIPE_WEBHOOK_SECRET"})]})]})]})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{className:"text-base",children:"Future Payment Providers"}),e.jsx(Be,{children:"Pluggable architecture ready for additional providers"})]}),e.jsx(ee,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{name:"PayPal",status:"Coming Soon"},{name:"Square",status:"Coming Soon"},{name:"Wise",status:"Planned"},{name:"M-Pesa",status:"Available"}].map(N=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-4 border rounded-lg bg-muted/30",children:[e.jsx("span",{className:"font-medium",children:N.name}),e.jsx(Le,{variant:"outline",className:"mt-2 text-xs",children:N.status})]},N.name))})})]})]})}function O0(){const s=is(),[t,r]=d.useState(""),[a,n]=d.useState(!1),[i,o]=d.useState(!1),[l,c]=d.useState(!1),[m,p]=d.useState(""),[x,g]=d.useState(!1),[u,y]=d.useState(null),{data:h,isLoading:f}=os({queryKey:["resend-settings"],queryFn:async()=>{const{data:N,error:T}=await M.from("site_content").select("content").eq("section_key","resend").maybeSingle();if(T)throw T;if(!(N!=null&&N.content))return null;let P;if(typeof N.content=="string")try{P=JSON.parse(N.content)}catch{return null}else P=N.content;return{api_key:P.api_key||"",from_email:P.from_email||void 0,from_name:P.from_name||void 0,connected:P.connected||!1,last_sync:P.last_sync||null,synced_count:P.synced_count||0}}});d.useEffect(()=>{(async()=>{try{const{data:T,error:P}=await M.functions.invoke("test-resend",{body:{action:"test"}});y(!P&&(T==null?void 0:T.success))}catch{y(!1)}})()},[]);const b=it({mutationFn:async N=>{const{error:T}=await M.from("site_content").update({content:JSON.stringify({api_key:N,connected:!!N,last_sync:(h==null?void 0:h.last_sync)||null,synced_count:(h==null?void 0:h.synced_count)||0}),updated_at:new Date().toISOString()}).eq("section_key","resend");if(T)throw T},onSuccess:()=>{s.invalidateQueries({queryKey:["resend-settings"]}),r(""),C.success("Resend API key saved")},onError:()=>{C.error("Failed to save API key")}}),v=async()=>{if(!(h!=null&&h.api_key)){C.error("Please save an API key first");return}o(!0);try{const{data:N,error:T}=await M.functions.invoke("test-resend",{body:{action:"test"}});if(T)throw T;N!=null&&N.success?C.success("Connection successful! Resend is ready to use."):C.error((N==null?void 0:N.error)||"Connection failed")}catch{C.error("Failed to test connection")}finally{o(!1)}},j=async()=>{if(!(h!=null&&h.api_key)){C.error("Please connect Resend first");return}c(!0);try{const{data:N,error:T}=await M.functions.invoke("test-resend",{body:{action:"sync"}});if(T)throw T;if(N!=null&&N.success){const{error:P}=await M.from("site_content").update({content:JSON.stringify({...h,last_sync:new Date().toISOString(),synced_count:N.synced_count||0}),updated_at:new Date().toISOString()}).eq("section_key","resend");P||s.invalidateQueries({queryKey:["resend-settings"]}),C.success(`Synced ${N.synced_count} subscribers to Resend`)}else C.error((N==null?void 0:N.error)||"Sync failed")}catch{C.error("Failed to sync subscribers")}finally{c(!1)}},_=async()=>{const{error:N}=await M.from("site_content").update({content:JSON.stringify({api_key:"",connected:!1,last_sync:null,synced_count:0}),updated_at:new Date().toISOString()}).eq("section_key","resend");N?C.error("Failed to disconnect"):(s.invalidateQueries({queryKey:["resend-settings"]}),C.success("Resend disconnected"))},I=()=>{window.parent.postMessage({type:"OPEN_EXTERNAL_URL",data:{url:"https://resend.com/broadcasts"}},"*")},E=async()=>{if(!m||!(h!=null&&h.api_key)){C.error("Please enter an email address");return}g(!0);try{const{data:N,error:T}=await M.functions.invoke("test-resend",{body:{action:"send",to:m}});if(T)throw T;N.success?(C.success(`Test email sent to ${m}!`),p("")):C.error(N.error||"Failed to send test email")}catch{C.error("Failed to send test email")}finally{g(!1)}};if(f)return e.jsx(X,{children:e.jsx(ee,{className:"pt-6",children:e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(ue,{className:"h-6 w-6 animate-spin"})})})});const O=u||(h==null?void 0:h.connected)&&(h==null?void 0:h.api_key),D=h!=null&&h.api_key?`${h.api_key.slice(0,8)}${"•".repeat(24)}`:"";return e.jsxs(X,{className:"border-dashed",children:[e.jsx(ye,{className:"pb-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${O?"bg-green-500/10":"bg-muted"}`,children:e.jsx(In,{className:`h-5 w-5 ${O?"text-green-500":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-2 text-lg",children:["Resend Integration",O?e.jsxs(Le,{className:"bg-green-500/10 text-green-600 border-green-500/20",children:[e.jsx(wt,{className:"h-3 w-3 mr-1"}),u?"Cloud Connected":"Connected"]}):e.jsxs(Le,{variant:"secondary",children:[e.jsx(fo,{className:"h-3 w-3 mr-1"}),"Not Connected"]})]}),e.jsx(Be,{children:"Connect Resend to sync subscribers and send newsletters"})]})]})})}),e.jsx(ee,{className:"space-y-4",children:u?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-green-500/10 border border-green-500/20 rounded-lg",children:[e.jsxs("p",{className:"text-sm font-medium text-green-600 flex items-center gap-2",children:[e.jsx(wt,{className:"h-4 w-4"}),"Resend is connected via Cloud secrets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Your RESEND_API_KEY is configured and ready to use."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",className:"flex-1",onClick:v,disabled:i,children:[i?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(wt,{className:"h-4 w-4 mr-2"}),"Test Connection"]}),e.jsxs(R,{className:"flex-1",onClick:I,children:[e.jsx(hs,{className:"h-4 w-4 mr-2"}),"Open Resend"]})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Send Test Email"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{type:"email",placeholder:"test@example.com",value:m,onChange:N=>p(N.target.value),className:"flex-1"}),e.jsxs(R,{onClick:E,disabled:x||!m,variant:"secondary",children:[x?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(zt,{className:"h-4 w-4 mr-2"}),"Send"]})]})]})]}):O?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"API Key"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:D})]}),e.jsx(R,{variant:"outline",size:"sm",onClick:_,children:"Disconnect"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Synced"}),e.jsx("p",{className:"font-medium",children:h!=null&&h.last_sync?new Date(h.last_sync).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"})]}),e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Synced Contacts"}),e.jsx("p",{className:"font-medium",children:(h==null?void 0:h.synced_count)||0})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",className:"flex-1",onClick:v,disabled:i,children:[i?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(wt,{className:"h-4 w-4 mr-2"}),"Test Connection"]}),e.jsxs(R,{variant:"outline",className:"flex-1",onClick:j,disabled:l,children:[l?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Sync Now"]})]}),e.jsxs(R,{className:"w-full",onClick:I,children:[e.jsx(hs,{className:"h-4 w-4 mr-2"}),"Open Resend Dashboard to Send Newsletters"]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Send Test Email"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{type:"email",placeholder:"test@example.com",value:m,onChange:N=>p(N.target.value),className:"flex-1"}),e.jsxs(R,{onClick:E,disabled:x||!m,variant:"secondary",children:[x?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(zt,{className:"h-4 w-4 mr-2"}),"Send"]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Subscribers will be available in Resend as Contacts. Use Resend's Broadcast feature to send newsletters."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2 text-sm",children:[e.jsx("p",{className:"font-medium",children:"How to get your Resend API Key:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-muted-foreground",children:[e.jsxs("li",{children:["Go to ",e.jsx("span",{className:"font-medium text-foreground",children:"resend.com"})," and sign up/log in"]}),e.jsxs("li",{children:["Navigate to ",e.jsx("span",{className:"font-medium text-foreground",children:"API Keys"})," section"]}),e.jsx("li",{children:"Create a new API key with full access"}),e.jsx("li",{children:"Copy and paste it below"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Q,{type:a?"text":"password",placeholder:"re_xxxxxxxx...",value:t,onChange:N=>r(N.target.value),className:"pr-10"}),e.jsx(R,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>n(!a),children:a?e.jsx(go,{className:"h-4 w-4"}):e.jsx(Ga,{className:"h-4 w-4"})})]}),e.jsxs(R,{onClick:()=>b.mutate(t),disabled:!t||b.isPending,children:[b.isPending?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(xn,{className:"h-4 w-4 mr-2"}),"Connect"]})]})]})})]})}function D0(){const s=is(),[t,r]=d.useState(""),[a,n]=d.useState(!1),[i,o]=d.useState(!1),[l,c]=d.useState(!1),[m,p]=d.useState(null),[x,g]=d.useState(null),{data:u,isLoading:y}=os({queryKey:["mailerlite-settings"],queryFn:async()=>{const{data:E,error:O}=await M.from("site_content").select("content").eq("section_key","mailerlite").maybeSingle();if(O)throw O;if(!(E!=null&&E.content))return null;let D;if(typeof E.content=="string")try{D=JSON.parse(E.content)}catch{return null}else D=E.content;return{api_key:D.api_key||"",connected:D.connected||!1,last_sync:D.last_sync||null,synced_count:D.synced_count||0,group_id:D.group_id||null,group_name:D.group_name||null}}});d.useEffect(()=>{(async()=>{try{const{data:O,error:D}=await M.functions.invoke("sync-to-mailerlite",{body:{action:"test"}});!D&&(O!=null&&O.success)?(p(!0),g(O.group_name||null)):p(!1)}catch{p(!1)}})()},[]);const h=it({mutationFn:async E=>{const O={api_key:E,connected:!!E,last_sync:(u==null?void 0:u.last_sync)||null,synced_count:(u==null?void 0:u.synced_count)||0,group_id:(u==null?void 0:u.group_id)||null,group_name:(u==null?void 0:u.group_name)||null},{data:D}=await M.from("site_content").select("id").eq("section_key","mailerlite").maybeSingle();if(D){const{error:N}=await M.from("site_content").update({content:JSON.stringify(O),updated_at:new Date().toISOString()}).eq("section_key","mailerlite");if(N)throw N}else{const{error:N}=await M.from("site_content").insert({page_name:"integrations",section_key:"mailerlite",content:JSON.stringify(O)});if(N)throw N}},onSuccess:()=>{s.invalidateQueries({queryKey:["mailerlite-settings"]}),r(""),C.success("MailerLite API key saved")},onError:()=>{C.error("Failed to save API key")}}),f=async()=>{if(!(u!=null&&u.api_key)){C.error("Please save an API key first");return}o(!0);try{const{data:E,error:O}=await M.functions.invoke("sync-to-mailerlite",{body:{action:"test"}});if(O)throw O;E!=null&&E.success?(E.group_id&&E.group_name&&(await M.from("site_content").update({content:JSON.stringify({...u,group_id:E.group_id,group_name:E.group_name}),updated_at:new Date().toISOString()}).eq("section_key","mailerlite"),s.invalidateQueries({queryKey:["mailerlite-settings"]})),C.success(`Connected! Using group: ${E.group_name||"Default"}`)):C.error((E==null?void 0:E.error)||"Connection failed")}catch{C.error("Failed to test connection")}finally{o(!1)}},b=async()=>{if(!(u!=null&&u.api_key)){C.error("Please connect MailerLite first");return}c(!0);try{const{data:E,error:O}=await M.functions.invoke("sync-to-mailerlite",{body:{action:"sync"}});if(O)throw O;if(E!=null&&E.success){const{error:D}=await M.from("site_content").update({content:JSON.stringify({...u,last_sync:new Date().toISOString(),synced_count:E.synced_count||0,group_id:E.group_id||(u==null?void 0:u.group_id),group_name:E.group_name||(u==null?void 0:u.group_name)}),updated_at:new Date().toISOString()}).eq("section_key","mailerlite");D||s.invalidateQueries({queryKey:["mailerlite-settings"]}),C.success(`Synced ${E.synced_count} subscribers to MailerLite`)}else C.error((E==null?void 0:E.error)||"Sync failed")}catch{C.error("Failed to sync subscribers")}finally{c(!1)}},v=async()=>{const{error:E}=await M.from("site_content").update({content:JSON.stringify({api_key:"",connected:!1,last_sync:null,synced_count:0,group_id:null,group_name:null}),updated_at:new Date().toISOString()}).eq("section_key","mailerlite");E?C.error("Failed to disconnect"):(s.invalidateQueries({queryKey:["mailerlite-settings"]}),C.success("MailerLite disconnected"))},j=()=>{window.parent.postMessage({type:"OPEN_EXTERNAL_URL",data:{url:"https://dashboard.mailerlite.com/campaigns"}},"*")};if(y)return e.jsx(X,{children:e.jsx(ee,{className:"pt-6",children:e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(ue,{className:"h-6 w-6 animate-spin"})})})});const _=m||(u==null?void 0:u.connected)&&(u==null?void 0:u.api_key),I=u!=null&&u.api_key?`${u.api_key.slice(0,8)}${"•".repeat(24)}`:"";return e.jsxs(X,{className:"border-dashed",children:[e.jsx(ye,{className:"pb-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${_?"bg-emerald-500/10":"bg-muted"}`,children:e.jsx(zt,{className:`h-5 w-5 ${_?"text-emerald-500":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-2 text-lg",children:["MailerLite Integration",_?e.jsxs(Le,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:[e.jsx(wt,{className:"h-3 w-3 mr-1"}),m?"Cloud Connected":"Connected"]}):e.jsxs(Le,{variant:"secondary",children:[e.jsx(fo,{className:"h-3 w-3 mr-1"}),"Not Connected"]})]}),e.jsx(Be,{children:"Connect MailerLite to sync subscribers and send email campaigns"})]})]})})}),e.jsx(ee,{className:"space-y-4",children:m?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-lg",children:[e.jsxs("p",{className:"text-sm font-medium text-emerald-600 flex items-center gap-2",children:[e.jsx(wt,{className:"h-4 w-4"}),"MailerLite is connected via Cloud secrets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Your MAILERLITE_API_KEY is configured and ready to use."})]}),x&&e.jsxs("div",{className:"p-3 bg-emerald-500/5 border border-emerald-500/20 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Syncing to Group"}),e.jsx("p",{className:"font-medium text-emerald-600",children:x})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",className:"flex-1",onClick:f,disabled:i,children:[i?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(wt,{className:"h-4 w-4 mr-2"}),"Test Connection"]}),e.jsxs(R,{variant:"outline",className:"flex-1",onClick:b,disabled:l,children:[l?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Sync Now"]})]}),e.jsxs(R,{className:"w-full",onClick:j,children:[e.jsx(hs,{className:"h-4 w-4 mr-2"}),"Open MailerLite Dashboard"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:'Subscribers will sync to a "Moenviron Newsletter" group in MailerLite.'})]}):_?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"API Key"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:I})]}),e.jsx(R,{variant:"outline",size:"sm",onClick:v,children:"Disconnect"})]}),(u==null?void 0:u.group_name)&&e.jsxs("div",{className:"p-3 bg-emerald-500/5 border border-emerald-500/20 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Syncing to Group"}),e.jsx("p",{className:"font-medium text-emerald-600",children:u.group_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Synced"}),e.jsx("p",{className:"font-medium",children:u!=null&&u.last_sync?new Date(u.last_sync).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never"})]}),e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Synced Contacts"}),e.jsx("p",{className:"font-medium",children:(u==null?void 0:u.synced_count)||0})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",className:"flex-1",onClick:f,disabled:i,children:[i?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(wt,{className:"h-4 w-4 mr-2"}),"Test Connection"]}),e.jsxs(R,{variant:"outline",className:"flex-1",onClick:b,disabled:l,children:[l?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Sync Now"]})]}),e.jsxs(R,{className:"w-full",onClick:j,children:[e.jsx(hs,{className:"h-4 w-4 mr-2"}),"Open MailerLite Dashboard"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:'Subscribers will sync to a "Moenviron Newsletter" group in MailerLite.'})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2 text-sm",children:[e.jsx("p",{className:"font-medium",children:"How to get your MailerLite API Key:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-muted-foreground",children:[e.jsxs("li",{children:["Go to ",e.jsx("span",{className:"font-medium text-foreground",children:"dashboard.mailerlite.com"})]}),e.jsxs("li",{children:["Click ",e.jsx("span",{className:"font-medium text-foreground",children:"Integrations → MailerLite API"})]}),e.jsxs("li",{children:["Click ",e.jsx("span",{className:"font-medium text-foreground",children:"Generate new token"})]}),e.jsx("li",{children:"Copy and paste it below"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Q,{type:a?"text":"password",placeholder:"eyJ0eXAiOiJKV1QiLCJhbGc...",value:t,onChange:E=>r(E.target.value),className:"pr-10"}),e.jsx(R,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>n(!a),children:a?e.jsx(go,{className:"h-4 w-4"}):e.jsx(Ga,{className:"h-4 w-4"})})]}),e.jsxs(R,{onClick:()=>h.mutate(t),disabled:!t||h.isPending,children:[h.isPending?e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(xn,{className:"h-4 w-4 mr-2"}),"Connect"]})]})]})})]})}function L0(){const s=is(),[t,r]=d.useState(""),[a,n]=d.useState(!1),[i,o]=d.useState({email:"",name:""}),{data:l,isLoading:c}=os({queryKey:["admin-subscribers"],queryFn:async()=>{const{data:f,error:b}=await M.from("newsletter_subscribers").select("*").order("subscribed_at",{ascending:!1});if(b)throw b;return f}}),m=it({mutationFn:async({email:f,name:b})=>{const{error:v}=await M.from("newsletter_subscribers").insert({email:f,name:b||null,source:"admin"});if(v)throw v},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-subscribers"]}),n(!1),o({email:"",name:""}),C.success("Subscriber added")},onError:f=>{f.message.includes("duplicate")?C.error("This email is already subscribed"):C.error("Failed to add subscriber")}}),p=it({mutationFn:async({id:f,is_active:b})=>{const{error:v}=await M.from("newsletter_subscribers").update({is_active:b,unsubscribed_at:b?null:new Date().toISOString()}).eq("id",f);if(v)throw v},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-subscribers"]}),C.success("Subscriber updated")}}),x=it({mutationFn:async f=>{const{error:b}=await M.from("newsletter_subscribers").delete().eq("id",f);if(b)throw b},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-subscribers"]}),C.success("Subscriber deleted")}}),g=()=>{if(!l)return;const b=["Email,Name,Subscribed At,Source",...l.filter(I=>I.is_active).map(I=>`${I.email},${I.name||""},${new Date(I.subscribed_at).toLocaleDateString()},${I.source}`)].join(`
`),v=new Blob([b],{type:"text/csv"}),j=URL.createObjectURL(v),_=document.createElement("a");_.href=j,_.download=`newsletter-subscribers-${new Date().toISOString().split("T")[0]}.csv`,_.click(),URL.revokeObjectURL(j),C.success("Exported to CSV")},u=l==null?void 0:l.filter(f=>f.email.toLowerCase().includes(t.toLowerCase())||f.name&&f.name.toLowerCase().includes(t.toLowerCase())),y=(l==null?void 0:l.filter(f=>f.is_active).length)||0,h=(l==null?void 0:l.length)||0;return c?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(O0,{}),e.jsx(D0,{})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(X,{children:e.jsx(ee,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-primary/10 rounded-full",children:e.jsx(rr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:h}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Subscribers"})]})]})})}),e.jsx(X,{children:e.jsx(ee,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-green-500/10 rounded-full",children:e.jsx(wt,{className:"h-6 w-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Subscribers"})]})]})})}),e.jsx(X,{children:e.jsx(ee,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-red-500/10 rounded-full",children:e.jsx(fo,{className:"h-6 w-6 text-red-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:h-y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unsubscribed"})]})]})})})]}),e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(zt,{className:"h-5 w-5"}),"Newsletter Subscribers"]}),e.jsx(Be,{children:"Manage your email list and export for campaigns"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(R,{variant:"outline",onClick:g,className:"gap-2",children:[e.jsx(Zc,{className:"h-4 w-4"}),"Export CSV"]}),e.jsxs(Ms,{open:a,onOpenChange:n,children:[e.jsx(Mr,{asChild:!0,children:e.jsxs(R,{className:"gap-2",children:[e.jsx(ad,{className:"h-4 w-4"}),"Add Subscriber"]})}),e.jsxs(gs,{children:[e.jsxs(Is,{children:[e.jsx(Os,{children:"Add Subscriber"}),e.jsx(Ya,{children:"Manually add a subscriber to your list"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Email Address *"}),e.jsx(Q,{type:"email",placeholder:"email@example.com",value:i.email,onChange:f=>o({...i,email:f.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Name (optional)"}),e.jsx(Q,{placeholder:"John Doe",value:i.name,onChange:f=>o({...i,name:f.target.value})})]})]}),e.jsx(Eo,{children:e.jsxs(R,{onClick:()=>m.mutate(i),disabled:!i.email||m.isPending,children:[m.isPending&&e.jsx(ue,{className:"h-4 w-4 animate-spin mr-2"}),"Add Subscriber"]})})]})]})]})]}),e.jsxs(ee,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(vo,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Q,{placeholder:"Search by email or name...",className:"pl-9",value:t,onChange:f=>r(f.target.value)})]})}),e.jsxs("div",{className:"rounded-md border",children:[e.jsxs("div",{className:"grid grid-cols-12 gap-4 p-3 bg-muted/50 font-medium text-sm",children:[e.jsx("div",{className:"col-span-4",children:"Email"}),e.jsx("div",{className:"col-span-2",children:"Name"}),e.jsx("div",{className:"col-span-2",children:"Source"}),e.jsx("div",{className:"col-span-2",children:"Date"}),e.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),(u==null?void 0:u.length)===0?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"No subscribers found"}):u==null?void 0:u.map(f=>e.jsxs("div",{className:"grid grid-cols-12 gap-4 p-3 border-t items-center text-sm",children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx("span",{className:f.is_active?"":"text-muted-foreground line-through",children:f.email}),!f.is_active&&e.jsx(Le,{variant:"secondary",className:"text-xs",children:"Unsubscribed"})]}),e.jsx("div",{className:"col-span-2 text-muted-foreground",children:f.name||"-"}),e.jsx("div",{className:"col-span-2",children:e.jsx(Le,{variant:"outline",className:"text-xs capitalize",children:f.source})}),e.jsx("div",{className:"col-span-2 text-muted-foreground",children:new Date(f.subscribed_at).toLocaleDateString()}),e.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>p.mutate({id:f.id,is_active:!f.is_active}),className:f.is_active?"text-orange-500 hover:text-orange-600":"text-green-500 hover:text-green-600",children:f.is_active?"Unsubscribe":"Reactivate"}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>x.mutate(f.id),className:"text-destructive hover:text-destructive",children:e.jsx(xs,{className:"h-4 w-4"})})]})]},f.id))]})]})]})]})}const F0=()=>{const s=ns(),{user:t,isLoading:r,isAdmin:a,userRole:n}=Bt(),[i,o]=d.useState([]),[l,c]=d.useState([]),[m,p]=d.useState([]),[x,g]=d.useState(!0),[u,y]=d.useState(!1),[h,f]=d.useState(null),b=n==="admin",v=b||n==="shipping"||n==="support",j=b||n==="content",_=b||n==="content",I=b||n==="marketing",E=b||n==="marketing",O=b,D=b,N=b,T=()=>{switch(n){case"admin":return"Super Admin Dashboard";case"marketing":return"Marketing Dashboard";case"shipping":return"Shipping & Fulfillment Dashboard";case"support":return"Customer Support Dashboard";case"content":return"Content Management Dashboard";default:return"Admin Dashboard"}},P=()=>{switch(n){case"admin":return"Full access to all systems and settings";case"marketing":return"Manage subscribers, campaigns, and analytics";case"shipping":return"Track and manage order fulfillment";case"support":return"Handle customer orders and inquiries";case"content":return"Manage products and website content";default:return"Manage your assigned tasks"}},[S,W]=d.useState({name:"",description:"",price:"",category:"Clothing",image_url:"",carbon_offset_kg:"",stock_quantity:""});d.useEffect(()=>{!r&&(!t||!a)&&s("/admin-login")},[t,a,r,s]),d.useEffect(()=>{a&&K()},[a]);const K=async()=>{g(!0);const[$,Te,fe]=await Promise.all([M.from("products").select("*").order("created_at",{ascending:!1}),M.from("orders").select("*").order("created_at",{ascending:!1}),M.from("impact_metrics").select("*").order("recorded_at",{ascending:!1})]);$.data&&o($.data),Te.data&&c(Te.data),fe.data&&p(fe.data),g(!1)},F=async $=>{$.preventDefault();const Te={name:S.name,description:S.description||null,price:parseFloat(S.price),category:S.category,image_url:S.image_url||null,carbon_offset_kg:S.carbon_offset_kg?parseFloat(S.carbon_offset_kg):null,stock_quantity:parseInt(S.stock_quantity)||0};if(h){const{error:fe}=await M.from("products").update(Te).eq("id",h.id);fe?C.error("Failed to update product"):(C.success("Product updated"),K())}else{const{error:fe}=await M.from("products").insert(Te);fe?C.error("Failed to create product"):(C.success("Product created"),K())}y(!1),q()},k=async $=>{const{error:Te}=await M.from("products").delete().eq("id",$);Te?C.error("Failed to delete product"):(C.success("Product deleted"),K())},A=async($,Te)=>{const fe=l.find(ke=>ke.id===$);if(!fe)return;const{error:we}=await M.from("orders").update({status:Te}).eq("id",$);if(we){C.error("Failed to update order");return}if(C.success("Order updated"),K(),["shipped","delivered","confirmed","arrived","processing"].includes(Te.toLowerCase()))try{const ke=await M.functions.invoke("send-order-status-update",{body:{orderId:fe.id,userEmail:fe.user_email,userName:fe.user_name||"Valued Customer",newStatus:Te,totalAmount:fe.total_amount,currency:"GBP"}});ke.error?console.error("Failed to send status email:",ke.error):C.success(`Status update email sent to ${fe.user_email}`)}catch(ke){console.error("Error sending status email:",ke)}},q=()=>{W({name:"",description:"",price:"",category:"Clothing",image_url:"",carbon_offset_kg:"",stock_quantity:""}),f(null)},re=$=>{var Te;f($),W({name:$.name,description:$.description||"",price:$.price.toString(),category:$.category,image_url:$.image_url||"",carbon_offset_kg:((Te=$.carbon_offset_kg)==null?void 0:Te.toString())||"",stock_quantity:$.stock_quantity.toString()}),y(!0)};return r||x?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):a?e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-8",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-8 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Nr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:T()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:P()})]}),n&&n!=="admin"&&e.jsx(Le,{variant:"outline",className:"ml-auto capitalize",children:n})]}),e.jsxs(Ir,{defaultValue:E?"analytics":v?"orders":"chat",className:"w-full",children:[e.jsxs(ar,{className:"mb-6 flex-wrap w-full justify-start h-auto",children:[E&&e.jsxs(Ye,{value:"analytics",className:"gap-2",children:[e.jsx(_r,{className:"h-4 w-4"}),"Analytics"]}),E&&e.jsxs(Ye,{value:"performance",className:"gap-2",children:[e.jsx(ho,{className:"h-4 w-4"}),"Product Insights"]}),b&&e.jsxs(Ye,{value:"library",className:"gap-2",children:[e.jsx(Hc,{className:"h-4 w-4"}),"Digital Library"]}),b&&e.jsxs(Ye,{value:"reports",className:"gap-2",children:[e.jsx(bo,{className:"h-4 w-4"}),"Reports"]}),j&&e.jsxs(Ye,{value:"products",className:"gap-2",children:[e.jsx(Et,{className:"h-4 w-4"}),"Products"]}),v&&e.jsxs(Ye,{value:"orders",className:"gap-2",children:[e.jsx(gn,{className:"h-4 w-4"}),"Orders"]}),_&&e.jsxs(Ye,{value:"content",className:"gap-2",children:[e.jsx(td,{className:"h-4 w-4"}),"Content"]}),D&&e.jsxs(Ye,{value:"admins",className:"gap-2",children:[e.jsx(Nr,{className:"h-4 w-4"}),"Staff"]}),e.jsxs(Ye,{value:"chat",className:"gap-2",children:[e.jsx(Ra,{className:"h-4 w-4"}),"Chat"]}),O&&e.jsxs(Ye,{value:"payments",className:"gap-2",children:[e.jsx(Ka,{className:"h-4 w-4"}),"Payments"]}),I&&e.jsxs(Ye,{value:"subscribers",className:"gap-2",children:[e.jsx(zt,{className:"h-4 w-4"}),"Subscribers"]}),N&&e.jsxs(Ye,{value:"tools",className:"gap-2",children:[e.jsx(rd,{className:"h-4 w-4"}),"Tools"]})]}),e.jsx($e,{value:"analytics",children:e.jsx(Vb,{})}),e.jsx($e,{value:"performance",children:e.jsx(Wb,{})}),e.jsx($e,{value:"library",children:e.jsx(C0,{})}),e.jsx($e,{value:"reports",children:e.jsx(E0,{})}),e.jsx($e,{value:"tools",children:e.jsx(Kb,{})}),e.jsx($e,{value:"products",children:e.jsxs(X,{children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between",children:[e.jsx(be,{children:"Products"}),e.jsxs(Ms,{open:u,onOpenChange:$=>{y($),$||q()},children:[e.jsx(Mr,{asChild:!0,children:e.jsxs(R,{size:"sm",className:"gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Add Product"]})}),e.jsxs(gs,{children:[e.jsx(Is,{children:e.jsx(Os,{children:h?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:F,className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"name",children:"Name"}),e.jsx(Q,{id:"name",value:S.name,onChange:$=>W({...S,name:$.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"category",children:"Category"}),e.jsx(Q,{id:"category",value:S.category,onChange:$=>W({...S,category:$.target.value}),required:!0})]})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"description",children:"Description"}),e.jsx(qt,{id:"description",value:S.description,onChange:$=>W({...S,description:$.target.value})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"price",children:"Price (£)"}),e.jsx(Q,{id:"price",type:"number",step:"0.01",value:S.price,onChange:$=>W({...S,price:$.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"stock",children:"Stock"}),e.jsx(Q,{id:"stock",type:"number",value:S.stock_quantity,onChange:$=>W({...S,stock_quantity:$.target.value})})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"carbon",children:"Carbon (kg)"}),e.jsx(Q,{id:"carbon",type:"number",step:"0.1",value:S.carbon_offset_kg,onChange:$=>W({...S,carbon_offset_kg:$.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"image",children:"Image URL"}),e.jsx(Q,{id:"image",value:S.image_url,onChange:$=>W({...S,image_url:$.target.value})})]}),e.jsx(R,{type:"submit",className:"w-full",children:h?"Update Product":"Create Product"})]})]})]})]}),e.jsx(ee,{children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Product"}),e.jsx(ae,{children:"Category"}),e.jsx(ae,{children:"Price"}),e.jsx(ae,{children:"Stock"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{className:"text-right",children:"Actions"})]})}),e.jsx(Rt,{children:i.map($=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium",children:$.name}),e.jsx(se,{children:$.category}),e.jsxs(se,{children:["£",$.price.toFixed(2)]}),e.jsx(se,{children:$.stock_quantity}),e.jsx(se,{children:e.jsx(Le,{variant:$.is_active?"default":"secondary",children:$.is_active?"Active":"Inactive"})}),e.jsxs(se,{className:"text-right",children:[e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>re($),children:e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"icon",onClick:()=>k($.id),children:e.jsx(xs,{className:"h-4 w-4 text-destructive"})})]})]},$.id))})]})})]})}),e.jsx($e,{value:"orders",children:e.jsxs(X,{children:[e.jsx(ye,{children:e.jsx(be,{children:"Orders"})}),e.jsx(ee,{children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Order ID"}),e.jsx(ae,{children:"Customer"}),e.jsx(ae,{children:"Location"}),e.jsx(ae,{children:"Amount"}),e.jsx(ae,{children:"Payment"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{children:"Date"})]})}),e.jsx(Rt,{children:l.map($=>e.jsxs(Qe,{children:[e.jsxs(se,{className:"font-mono text-sm",children:[$.id.slice(0,8),"..."]}),e.jsx(se,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:$.user_name||"Guest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$.user_email})]})}),e.jsx(se,{children:$.customer_location?e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx(rs,{className:"h-3 w-3 text-muted-foreground"}),$.customer_location]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsxs(se,{children:["£",$.total_amount.toFixed(2)]}),e.jsx(se,{children:e.jsx(Le,{variant:"outline",children:$.payment_method})}),e.jsx(se,{children:e.jsxs("select",{value:$.status,onChange:Te=>A($.id,Te.target.value),className:"rounded border border-border bg-background px-2 py-1 text-sm",children:[e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"confirmed",children:"Confirmed"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"shipped",children:"Shipped"}),e.jsx("option",{value:"arrived",children:"Arrived at Destination"}),e.jsx("option",{value:"delivered",children:"Delivered"}),e.jsx("option",{value:"cancelled",children:"Cancelled"})]})}),e.jsx(se,{children:new Date($.created_at).toLocaleDateString()})]},$.id))})]})})]})}),e.jsx($e,{value:"metrics",children:e.jsx(Gb,{})}),e.jsx($e,{value:"content",children:e.jsx(Hb,{})}),e.jsx($e,{value:"media",children:e.jsxs(X,{children:[e.jsx(ye,{children:e.jsx(be,{children:"Media Library"})}),e.jsxs(ee,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Upload images here and copy the URL to use anywhere on the site."}),e.jsx(Ji,{label:"Upload New Image"})]})]})}),e.jsx($e,{value:"admins",children:e.jsx(Yb,{})}),e.jsx($e,{value:"chat",children:e.jsx(_m,{})}),e.jsx($e,{value:"payments",children:e.jsx(I0,{})}),e.jsx($e,{value:"subscribers",children:e.jsx(L0,{})})]})]})}),e.jsx(We,{})]}):null},q0=()=>{const{user:s,isLoading:t}=Bt(),r=ns(),[a,n]=d.useState(null),[i,o]=d.useState([]),[l,c]=d.useState(!0),[m,p]=d.useState(!1),[x,g]=d.useState(""),[u,y]=d.useState(""),[h,f]=d.useState(""),[b,v]=d.useState(""),[j,_]=d.useState(""),[I,E]=d.useState(""),[O,D]=d.useState("Kenya");d.useEffect(()=>{!t&&!s&&r("/auth")},[s,t,r]),d.useEffect(()=>{s&&N()},[s]);const N=async()=>{if(s){c(!0);try{const{data:S,error:W}=await M.from("profiles").select("*").eq("user_id",s.id).maybeSingle();W&&W.code!=="PGRST116"&&console.error("Profile fetch error:",W),S&&(n(S),g(S.full_name||""),y(S.phone||""),f(S.address_line1||""),v(S.address_line2||""),_(S.city||""),E(S.postal_code||""),D(S.country||"Kenya"));const{data:K,error:F}=await M.from("orders").select("*").eq("user_email",s.email).order("created_at",{ascending:!1});F?console.error("Orders fetch error:",F):o(K||[])}catch(S){console.error("Fetch error:",S)}finally{c(!1)}}},T=async()=>{if(s){p(!0);try{const S={user_id:s.id,full_name:x,phone:u,address_line1:h,address_line2:b,city:j,postal_code:I,country:O},{error:W}=await M.from("profiles").upsert(S,{onConflict:"user_id"});if(W)throw W;C.success("Profile saved successfully!")}catch(S){console.error("Save error:",S),C.error("Failed to save profile")}finally{p(!1)}}},P=S=>{switch(S.toLowerCase()){case"confirmed":case"completed":return"bg-green-500/10 text-green-600 border-green-500/20";case"pending":return"bg-yellow-500/10 text-yellow-600 border-yellow-500/20";case"failed":case"cancelled":return"bg-red-500/10 text-red-600 border-red-500/20";default:return"bg-muted text-muted-foreground"}};return t||l?e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}),e.jsx(We,{})]}):e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-12",children:e.jsxs("div",{className:"container max-w-4xl",children:[e.jsx("h1",{className:"mb-8 text-3xl font-bold text-foreground",children:"My Account"}),e.jsxs(Ir,{defaultValue:"profile",className:"space-y-6",children:[e.jsxs(ar,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ye,{value:"profile",className:"gap-2",children:[e.jsx(Ni,{className:"h-4 w-4"}),"Profile & Address"]}),e.jsxs(Ye,{value:"orders",className:"gap-2",children:[e.jsx(Et,{className:"h-4 w-4"}),"Order History"]})]}),e.jsx($e,{value:"profile",children:e.jsxs(X,{children:[e.jsx(ye,{children:e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"h-5 w-5 text-primary"}),"Saved Address"]})}),e.jsxs(ee,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"fullName",children:"Full Name"}),e.jsx(Q,{id:"fullName",value:x,onChange:S=>g(S.target.value),placeholder:"John Doe"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Q,{id:"phone",value:u,onChange:S=>y(S.target.value),placeholder:"+254 700 000 000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"address1",children:"Address Line 1"}),e.jsx(Q,{id:"address1",value:h,onChange:S=>f(S.target.value),placeholder:"Street address"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"address2",children:"Address Line 2"}),e.jsx(Q,{id:"address2",value:b,onChange:S=>v(S.target.value),placeholder:"Apartment, suite, etc. (optional)"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"city",children:"City"}),e.jsx(Q,{id:"city",value:j,onChange:S=>_(S.target.value),placeholder:"Nairobi"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"postalCode",children:"Postal Code"}),e.jsx(Q,{id:"postalCode",value:I,onChange:S=>E(S.target.value),placeholder:"00100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"country",children:"Country"}),e.jsx(Q,{id:"country",value:O,onChange:S=>D(S.target.value),placeholder:"Kenya"})]})]}),e.jsx(R,{onClick:T,disabled:m,className:"mt-4",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save Address"})]})]})}),e.jsx($e,{value:"orders",children:e.jsxs(X,{children:[e.jsx(ye,{children:e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Et,{className:"h-5 w-5 text-primary"}),"Order History"]})}),e.jsx(ee,{children:i.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx(Et,{className:"mx-auto h-12 w-12 text-muted-foreground/30"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"No orders yet"})]}):e.jsx("div",{className:"space-y-4",children:i.map(S=>e.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3 hover:border-primary/30 transition-colors",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Le,{variant:"outline",className:P(S.status),children:S.status}),e.jsx("span",{className:"text-sm text-muted-foreground",children:S.payment_method==="mpesa"?"M-Pesa":"Card"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wc,{className:"h-4 w-4"}),new Date(S.created_at).toLocaleDateString()]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium text-foreground",children:[e.jsx(Qc,{className:"h-4 w-4"}),S.currency==="KES"?"KSh":"£",S.total_amount.toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground flex-1",children:[e.jsxs("span",{className:"font-mono text-xs text-primary",children:["#",S.id.slice(0,8).toUpperCase()]}),e.jsx("span",{className:"mx-2",children:"•"}),Array.isArray(S.items)&&S.items.map((W,K)=>e.jsxs("span",{children:[W.name||"Item"," x",W.quantity||1,K<S.items.length-1?", ":""]},K))]}),e.jsx(Oe,{to:`/orders/${S.id}`,children:e.jsxs(R,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",children:["Track Order",e.jsx(hs,{className:"h-3 w-3"})]})})]})]},S.id))})})]})})]})]})}),e.jsx(We,{})]})},z0={gbp:{symbol:"£",code:"GBP",rate:1,minAmount:30,zeroDecimal:!1},eur:{symbol:"€",code:"EUR",rate:1.17,minAmount:50,zeroDecimal:!1},usd:{symbol:"$",code:"USD",rate:1.27,minAmount:50,zeroDecimal:!1},kes:{symbol:"KSh",code:"KES",rate:165,minAmount:100,zeroDecimal:!0},ugx:{symbol:"UGX",code:"UGX",rate:4700,minAmount:1e3,zeroDecimal:!0},tzs:{symbol:"TZS",code:"TZS",rate:3200,minAmount:1e3,zeroDecimal:!0},rwf:{symbol:"RWF",code:"RWF",rate:1350,minAmount:100,zeroDecimal:!0},ngn:{symbol:"₦",code:"NGN",rate:1950,minAmount:100,zeroDecimal:!1},zar:{symbol:"R",code:"ZAR",rate:23,minAmount:100,zeroDecimal:!1},ghs:{symbol:"GH₵",code:"GHS",rate:16,minAmount:100,zeroDecimal:!1},etb:{symbol:"ETB",code:"ETB",rate:145,minAmount:100,zeroDecimal:!1}},Am={"United Kingdom":"gbp",Kenya:"kes",Uganda:"ugx",Tanzania:"tzs",Rwanda:"rwf","United States":"usd",Nigeria:"ngn","South Africa":"zar",Ghana:"ghs",Ethiopia:"etb",Other:"gbp"},$0=Object.keys(Am);function B0(s){return Am[s]||"gbp"}const U0=[10,25,50,100],nc=[{id:"everyday",title:"Everyday Wear",description:"T-shirts, jeans, casual dresses, sweaters, and everyday clothing items",icon:wi,examples:["T-shirts","Jeans","Sweaters","Casual dresses","Shorts"]},{id:"formal",title:"Formal & Workwear",description:"Suits, blazers, formal dresses, office attire, and professional clothing",icon:rr,examples:["Suits","Blazers","Formal dresses","Dress shirts","Skirts"]},{id:"accessories",title:"Accessories & Others",description:"Shoes, bags, scarves, belts, and other textile accessories",icon:Et,examples:["Shoes","Bags","Scarves","Belts","Hats"]}],H0=()=>{const[s,t]=d.useState("money"),[r,a]=d.useState(1),[n,i]=d.useState(""),[o,l]=d.useState(""),[c,m]=d.useState(""),[p,x]=d.useState(""),[g,u]=d.useState("United Kingdom"),[y,h]=d.useState(""),[f,b]=d.useState(!1),[v,j]=d.useState([]),[_,I]=d.useState(1),[E,O]=d.useState(""),[D,N]=d.useState(""),[T,P]=d.useState(""),[S,W]=d.useState(""),[K,F]=d.useState(""),[k,A]=d.useState(!1),q=B0(g),re=z0[q],{symbol:$,rate:Te}=re;d.useEffect(()=>{a(1),i("")},[q]);const fe=U0.map(V=>Math.round(V*Te)),we=n?parseFloat(n):fe[r]||fe[1],ke=cu(o,we),Ze=async()=>{var V,je;if(!o){C.error("Please enter your email address");return}if(!g){C.error("Please select your country");return}if(we<=0){C.error("Please enter a valid donation amount");return}b(!0);try{const{data:xe,error:Ce}=await M.functions.invoke("create-checkout",{body:{items:[{id:"donation",name:`Donation to Moenviron (${re.code})`,price:we,quantity:1}],customerEmail:o,customerName:p||void 0,customerLocation:`${y?y+", ":""}${g}`,currency:q,mode:"checkout_session",isDonation:!0}});if(Ce)throw console.error("Checkout error:",Ce),new Error(Ce.message||"Failed to create checkout session");if((je=(V=xe==null?void 0:xe.sessionId)==null?void 0:V.startsWith)!=null&&je.call(V,"cs_test_")){console.warn("Blocking test session redirect in production"),Wi(o,we);return}if(xe!=null&&xe.url)window.location.href=xe.url;else throw new Error("Invalid checkout session")}catch(xe){console.error("Donation error:",xe),Wi(o,we)}finally{b(!1)}},st=V=>{j(je=>je.includes(V)?je.filter(xe=>xe!==V):[...je,V])},Z=async()=>{if(!D||!E){C.error("Please fill in your name and email");return}A(!0),await new Promise(V=>setTimeout(V,1500)),C.success("Thank you! We'll contact you shortly to arrange collection."),I(4),A(!1)},ze=()=>{switch(_){case 1:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground mb-2",children:"Select Clothing Categories"}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the types of clothes you'd like to donate"})]}),e.jsx("div",{className:"grid gap-4",children:nc.map(V=>{const je=V.icon,xe=v.includes(V.id);return e.jsxs("button",{type:"button",onClick:()=>st(V.id),className:`flex items-start gap-4 p-4 rounded-lg border-2 text-left transition-all ${xe?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:[e.jsx("div",{className:`flex h-12 w-12 shrink-0 items-center justify-center rounded-full ${xe?"bg-primary text-primary-foreground":"bg-muted"}`,children:e.jsx(je,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:V.title}),xe&&e.jsx(wt,{className:"h-5 w-5 text-primary"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:V.description}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:V.examples.map(Ce=>e.jsx("span",{className:"text-xs bg-muted px-2 py-1 rounded-full",children:Ce},Ce))})]})]},V.id)})}),e.jsxs(R,{onClick:()=>I(2),disabled:v.length===0,className:"w-full gap-2",size:"lg",children:["Continue",e.jsx(ss,{className:"h-4 w-4"})]})]});case 2:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground mb-2",children:"Your Contact Details"}),e.jsx("p",{className:"text-muted-foreground",children:"We'll use these to arrange collection"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"donor-name",children:"Full Name *"}),e.jsx(Q,{id:"donor-name",value:E,onChange:V=>O(V.target.value),placeholder:"Your full name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"donor-email",children:"Email Address *"}),e.jsx(Q,{id:"donor-email",type:"email",value:D,onChange:V=>N(V.target.value),placeholder:"your@email.com",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"donor-phone",children:"Phone Number"}),e.jsx(Q,{id:"donor-phone",type:"tel",value:T,onChange:V=>P(V.target.value),placeholder:"Your phone number"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(R,{variant:"outline",onClick:()=>I(1),className:"flex-1",children:"Back"}),e.jsxs(R,{onClick:()=>I(3),disabled:!E||!D,className:"flex-1 gap-2",children:["Continue",e.jsx(ss,{className:"h-4 w-4"})]})]})]});case 3:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground mb-2",children:"Collection Details"}),e.jsx("p",{className:"text-muted-foreground",children:"Where should we collect from?"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"donor-address",children:"Collection Address *"}),e.jsx(Q,{id:"donor-address",value:S,onChange:V=>W(V.target.value),placeholder:"Your full address",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"clothes-notes",children:"Additional Notes"}),e.jsx(Q,{id:"clothes-notes",value:K,onChange:V=>F(V.target.value),placeholder:"E.g., preferred collection times, number of bags..."})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted p-4 space-y-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:"Donation Summary"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Categories:"})," ",v.map(V=>{var je;return(je=nc.find(xe=>xe.id===V))==null?void 0:je.title}).join(", ")]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Name:"})," ",E]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Email:"})," ",D]}),T&&e.jsxs("p",{children:[e.jsx("strong",{children:"Phone:"})," ",T]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(R,{variant:"outline",onClick:()=>I(2),className:"flex-1",children:"Back"}),e.jsx(R,{onClick:Z,disabled:!S||k,className:"flex-1 gap-2",children:k?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"}),"Submitting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"h-4 w-4"}),"Submit Request"]})})]})]});case 4:return e.jsxs("div",{className:"text-center py-8 space-y-4",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:e.jsx(wt,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-xl font-semibold text-foreground",children:"Thank You!"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Your clothes donation request has been received. Our team will contact you within 48 hours to arrange collection."}),e.jsx(R,{variant:"outline",onClick:()=>{I(1),j([]),O(""),N(""),P(""),W(""),F("")},className:"mt-4",children:"Donate More Clothes"})]});default:return null}};return e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Support Our Mission",description:"Support sustainable fashion and circular economy initiatives. Donate money or clothes to help reduce textile waste and empower communities in East Africa."}),e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-12",children:e.jsxs("div",{className:"container max-w-4xl",children:[e.jsxs("div",{className:"mb-12 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:e.jsx(ra,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"mb-4 text-4xl font-bold text-foreground",children:"Support Our Mission"}),e.jsx("p",{className:"mx-auto max-w-2xl text-lg text-muted-foreground",children:"Your donation helps us create sustainable fashion opportunities, reduce textile waste, and empower communities across East Africa."})]}),e.jsxs("div",{className:"mb-12 grid gap-6 sm:grid-cols-3",children:[e.jsx(X,{className:"border-primary/20 bg-primary/5",children:e.jsxs(ee,{className:"flex flex-col items-center p-6 text-center",children:[e.jsx(ft,{className:"mb-3 h-8 w-8 text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:"Environmental Impact"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"£10 saves 5kg of textiles from landfill"})]})}),e.jsx(X,{className:"border-primary/20 bg-primary/5",children:e.jsxs(ee,{className:"flex flex-col items-center p-6 text-center",children:[e.jsx(rr,{className:"mb-3 h-8 w-8 text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:"Community Support"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"£25 provides a day's training for artisans"})]})}),e.jsx(X,{className:"border-primary/20 bg-primary/5",children:e.jsxs(ee,{className:"flex flex-col items-center p-6 text-center",children:[e.jsx(xa,{className:"mb-3 h-8 w-8 text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:"Global Reach"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"£100 funds shipping for partner donations"})]})})]}),e.jsxs(Ir,{value:s,onValueChange:V=>t(V),className:"mx-auto max-w-lg",children:[e.jsxs(ar,{className:"grid w-full grid-cols-2 mb-6",children:[e.jsxs(Ye,{value:"money",className:"gap-2",children:[e.jsx(Ka,{className:"h-4 w-4"}),"Donate Money"]}),e.jsxs(Ye,{value:"clothes",className:"gap-2",children:[e.jsx(wi,{className:"h-4 w-4"}),"Donate Clothes"]})]}),e.jsx($e,{value:"money",children:e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Make a Donation"}),e.jsx(Be,{children:"Choose an amount and payment method. Currency auto-detected based on your country."})]}),e.jsxs(ee,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{children:["Donation Amount (",re.code,")"]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:fe.map((V,je)=>e.jsxs(R,{type:"button",variant:r===je&&!n?"default":"outline",onClick:()=>{a(je),i("")},children:[$,V.toLocaleString()]},V))}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:$}),e.jsx(Q,{type:"number",placeholder:"Custom amount",value:n,onChange:V=>i(V.target.value),className:"pl-10",min:"1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{htmlFor:"country",className:"flex items-center gap-1",children:[e.jsx(rs,{className:"h-3 w-3"}),"Country * ",e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:"(determines currency)"})]}),e.jsxs(ua,{value:g,onValueChange:u,children:[e.jsx(Pr,{children:e.jsx(ma,{placeholder:"Where are you donating from?"})}),e.jsx(Ar,{children:$0.map(V=>e.jsx(nt,{value:V,children:V},V))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{children:"Payment Method"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-primary bg-primary/5 p-3",children:[e.jsx("img",{src:Ia,alt:"Stripe",className:"h-5 w-auto"}),e.jsx("span",{className:"text-sm",children:"Secure Checkout"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground p-3",children:[e.jsx("span",{children:"Also accepts:"}),e.jsx("img",{src:Da,alt:"Apple Pay",className:"h-4 w-auto opacity-60"}),e.jsx("img",{src:Oa,alt:"Google Pay",className:"h-4 w-auto opacity-60"})]})]}),e.jsx(R,{asChild:!0,variant:"outline",className:"w-full",children:e.jsx("a",{href:ke,target:"_blank",rel:"noopener noreferrer",children:"Open secure payment page (all methods)"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use this if the donation checkout keeps opening a test session."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"email",children:"Email *"}),e.jsx(Q,{id:"email",type:"email",value:o,onChange:V=>l(V.target.value),placeholder:"your@email.com",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Name (optional)"}),e.jsx(Q,{id:"name",value:p,onChange:V=>x(V.target.value),placeholder:"Your name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"city",children:"City (optional)"}),e.jsx(Q,{id:"city",value:y,onChange:V=>h(V.target.value),placeholder:"Your city"})]})]}),e.jsx(R,{onClick:Ze,disabled:f||!o,className:"w-full gap-2",size:"lg",children:f?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ra,{className:"h-4 w-4"}),"Donate ",$,(we==null?void 0:we.toLocaleString())||0]})}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"Your donation is secure and helps support sustainable fashion initiatives. Payments processed by Stripe."})]})]})}),e.jsx($e,{value:"clothes",children:e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(wi,{className:"h-5 w-5"}),"Donate Your Clothes"]}),e.jsx(Be,{children:"Give your pre-loved clothes a second life. We'll collect them from your doorstep."}),_<4&&e.jsx("div",{className:"flex items-center gap-2 mt-4",children:[1,2,3].map(V=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium ${_>=V?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:V}),V<3&&e.jsx("div",{className:`h-0.5 w-8 ${_>V?"bg-primary":"bg-muted"}`})]},V))})]}),e.jsx(ee,{children:ze()})]})})]})]})}),e.jsx(We,{})]})},V0=()=>{const{user:s}=Bt(),t=ns(),{items:r,isLoading:a,removeFromWishlist:n}=Wd(),[i,o]=d.useState([]),[l,c]=d.useState(!0);d.useEffect(()=>{if(!s){t("/auth");return}},[s,t]),d.useEffect(()=>{async function p(){if(r.length===0){o([]),c(!1);return}const x=r.map(y=>y.product_id),{data:g,error:u}=await M.from("products").select("id, name, price, currency, image_url, category, carbon_offset_kg").in("id",x);!u&&g&&o(g),c(!1)}a||p()},[r,a]);const m=p=>{const x=localStorage.getItem("moenviron-cart"),g=x?JSON.parse(x):[],u=g.findIndex(y=>y.id===p.id);u>=0?g[u].quantity+=1:g.push({id:p.id,name:p.name,price:p.price,currency:p.currency,quantity:1,image_url:p.image_url,carbon_offset_kg:p.carbon_offset_kg}),localStorage.setItem("moenviron-cart",JSON.stringify(g)),window.dispatchEvent(new CustomEvent("cart-updated")),C.success(`Added ${p.name} to cart`)};return s?e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-8",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"My Wishlist"}),e.jsxs("p",{className:"mt-2 text-muted-foreground",children:[i.length," ",i.length===1?"item":"items"," saved"]})]}),a||l?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):i.length===0?e.jsxs("div",{className:"py-16 text-center",children:[e.jsx(ra,{className:"mx-auto h-16 w-16 text-muted-foreground/30"}),e.jsx("h2",{className:"mt-4 text-xl font-semibold",children:"Your wishlist is empty"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Start adding items you love!"}),e.jsx(Oe,{to:"/shop",className:"mt-6 inline-block",children:e.jsx(R,{children:"Browse Shop"})})]}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:i.map(p=>e.jsxs(X,{className:"overflow-hidden border-border/50",children:[e.jsx(Oe,{to:`/shop/${p.id}`,children:e.jsxs("div",{className:"relative aspect-[3/4] overflow-hidden bg-muted",children:[p.image_url?e.jsx("img",{src:p.image_url,alt:p.name,className:"h-full w-full object-cover transition-transform duration-300 hover:scale-105"}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(ft,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx("div",{className:"absolute left-3 top-3 rounded-full bg-background/90 px-3 py-1 text-xs font-medium",children:p.category}),p.carbon_offset_kg&&e.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-1 rounded-full bg-primary/90 px-2 py-1 text-xs font-medium text-primary-foreground",children:[e.jsx(ft,{className:"h-3 w-3"}),"-",p.carbon_offset_kg,"kg CO₂"]})]})}),e.jsxs(ee,{className:"p-4",children:[e.jsx(Oe,{to:`/shop/${p.id}`,children:e.jsx("h3",{className:"font-medium text-foreground hover:text-primary transition-colors",children:p.name})}),e.jsxs("p",{className:"mt-1 text-lg font-semibold",children:["£",p.price.toFixed(2)]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsxs(R,{size:"sm",className:"flex-1 gap-1",onClick:()=>m(p),children:[e.jsx(As,{className:"h-4 w-4"}),"Add to Cart"]}),e.jsx(R,{size:"sm",variant:"outline",onClick:()=>n(p.id),children:e.jsx(xs,{className:"h-4 w-4"})})]})]})]},p.id))})]})}),e.jsx(We,{})]}):null},W0=()=>e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Privacy Policy",description:"Learn how Moenviron collects, uses, and protects your personal data in compliance with UK GDPR and Data Protection Act 2018."}),e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"mx-auto max-w-3xl",children:[e.jsx("h1",{className:"mb-8 text-4xl font-bold text-foreground",children:"Privacy Policy"}),e.jsxs("div",{className:"prose prose-gray max-w-none",children:[e.jsxs("p",{className:"text-muted-foreground mb-6",children:["Last updated: ",new Date().toLocaleDateString("en-GB")]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"1. Introduction"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:'Moenviron ("we", "our", "us") is committed to protecting your personal data. This privacy policy explains how we collect, use, and protect your information in compliance with the UK General Data Protection Regulation (UK GDPR) and the Data Protection Act 2018.'})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"2. Data We Collect"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mb-4",children:"We collect:"}),e.jsxs("ul",{className:"list-disc pl-6 text-muted-foreground space-y-2",children:[e.jsx("li",{children:"Contact information (name, email, phone) when you make purchases or enquiries"}),e.jsx("li",{children:"Payment information processed securely by Stripe"}),e.jsx("li",{children:"Delivery addresses for order fulfilment"}),e.jsx("li",{children:"Website usage data through cookies"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"3. How We Use Your Data"}),e.jsxs("ul",{className:"list-disc pl-6 text-muted-foreground space-y-2",children:[e.jsx("li",{children:"Process and fulfil your orders"}),e.jsx("li",{children:"Respond to your enquiries"}),e.jsx("li",{children:"Improve our products and services"}),e.jsx("li",{children:"Send marketing communications (with your consent)"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"4. Your Rights"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Under UK GDPR, you have the right to access, rectify, erase, restrict processing, data portability, and object to processing of your personal data. Contact us at privacy@moenviron.com to exercise these rights."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"5. Contact Us"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"For privacy-related enquiries, contact our Data Protection Officer at privacy@moenviron.com or write to us at our London office."})]})]})]})})}),e.jsx(We,{})]}),K0=()=>e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Terms & Conditions",description:"Read our terms and conditions governing your use of the Moenviron website and purchase of our sustainable fashion products."}),e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"mx-auto max-w-3xl",children:[e.jsx("h1",{className:"mb-8 text-4xl font-bold text-foreground",children:"Terms & Conditions"}),e.jsxs("div",{className:"prose prose-gray max-w-none",children:[e.jsxs("p",{className:"text-muted-foreground mb-6",children:["Last updated: ",new Date().toLocaleDateString("en-GB")]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"1. Introduction"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"These terms and conditions govern your use of the Moenviron website and your purchase of products from us. By using our website or making a purchase, you agree to these terms."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"2. Orders and Payment"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"All orders are subject to availability. Prices are displayed in GBP and include VAT where applicable. Payment is processed securely through Stripe."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"3. Delivery"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"We aim to dispatch orders within 2-3 business days. UK delivery typically takes 3-5 working days. International shipping times vary by destination."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"4. Intellectual Property"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"All content on this website, including text, images, and logos, is the property of Moenviron and protected by copyright law."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"5. Governing Law"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"These terms are governed by the laws of England and Wales. Any disputes will be subject to the exclusive jurisdiction of the courts of England and Wales."})]})]})]})})}),e.jsx(We,{})]}),G0=()=>e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ut,{title:"Returns Policy",description:"Learn about our returns policy under UK Consumer Rights Act 2015. Return items within 14 days for a full refund."}),e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-16",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"mx-auto max-w-3xl",children:[e.jsx("h1",{className:"mb-8 text-4xl font-bold text-foreground",children:"Returns Policy"}),e.jsxs("div",{className:"prose prose-gray max-w-none",children:[e.jsxs("p",{className:"text-muted-foreground mb-6",children:["Last updated: ",new Date().toLocaleDateString("en-GB")]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"Your Rights"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Under the Consumer Rights Act 2015 and the Consumer Contracts Regulations 2013, you have the right to cancel your order within 14 days of receiving your goods for a full refund."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"How to Return"}),e.jsxs("ol",{className:"list-decimal pl-6 text-muted-foreground space-y-2",children:[e.jsx("li",{children:"Contact us at returns@moenviron.com within 14 days of receiving your order"}),e.jsx("li",{children:"We'll send you a returns authorisation and shipping label"}),e.jsx("li",{children:"Pack the item securely in its original packaging if possible"}),e.jsx("li",{children:"Drop off at your nearest post office or arrange collection"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"Refunds"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Once we receive your return and verify its condition, we'll process your refund within 14 days. Refunds will be issued to the original payment method."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"Exceptions"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Items must be unworn, unwashed, and in their original condition with all tags attached. We cannot accept returns on items that show signs of wear or damage."})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"Faulty Items"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"If you receive a faulty or damaged item, please contact us immediately. We'll arrange a free return and send a replacement or full refund."})]})]})]})})}),e.jsx(We,{})]}),Y0=()=>{const s=An();return d.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",s.pathname)},[s.pathname]),e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsxs(Vd,{children:[e.jsx("title",{children:"Page Not Found | Moenviron Loop"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("meta",{name:"description",content:"The page you're looking for doesn't exist or has been moved."})]}),e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 flex items-center justify-center bg-muted",children:e.jsxs("div",{className:"container max-w-lg text-center py-16",children:[e.jsx("h1",{className:"text-8xl font-bold text-primary/20 mb-4",children:"404"}),e.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-4",children:"Page Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"The page you're looking for doesn't exist or has been moved."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsx(Oe,{to:"/",children:e.jsxs(R,{className:"gap-2",children:[e.jsx(Fh,{className:"h-4 w-4"}),"Return to Home"]})}),e.jsxs(R,{variant:"outline",onClick:()=>window.history.back(),className:"gap-2",children:[e.jsx(Rn,{className:"h-4 w-4"}),"Go Back"]})]})]})}),e.jsx(We,{})]})};var Q0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z0=Q0.reduce((s,t)=>{const r=qn(`Primitive.${t}`),a=d.forwardRef((n,i)=>{const{asChild:o,...l}=n,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...l,ref:i})});return a.displayName=`Primitive.${t}`,{...s,[t]:a}},{}),J0="Separator",ic="horizontal",X0=["horizontal","vertical"],Rm=d.forwardRef((s,t)=>{const{decorative:r,orientation:a=ic,...n}=s,i=ej(a)?a:ic,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return e.jsx(Z0.div,{"data-orientation":i,...l,...n,ref:t})});Rm.displayName=J0;function ej(s){return X0.includes(s)}var Mm=Rm;const Im=d.forwardRef(({className:s,orientation:t="horizontal",decorative:r=!0,...a},n)=>e.jsx(Mm,{ref:n,decorative:r,orientation:t,className:me("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...a}));Im.displayName=Mm.displayName;const oc=[{key:"pending",label:"Order Placed",icon:xo,description:"We've received your order"},{key:"confirmed",label:"Confirmed",icon:Kh,description:"Payment verified, preparing your order"},{key:"processing",label:"Processing",icon:Eh,description:"Your items are being prepared"},{key:"shipped",label:"Shipped",icon:On,description:"Your order is on the way"},{key:"delivered",label:"Delivered",icon:wt,description:"Order delivered successfully"}],tj=()=>{const{id:s}=zc(),[t,r]=d.useState(null),[a,n]=d.useState(!0),[i,o]=d.useState(null);d.useEffect(()=>{s&&l(s)},[s]);const l=async h=>{n(!0),o(null);try{const{data:f,error:b}=await M.from("orders").select("*").eq("id",h).single();if(b){if(b.code==="PGRST116")o("Order not found. Please check your order ID.");else throw b;return}const v=Array.isArray(f.items)?f.items:[],j=f.shipping_address;r({...f,items:v,shipping_address:j})}catch(f){console.error("Error fetching order:",f),o("Failed to load order details. Please try again.")}finally{n(!1)}},c=()=>{t&&(navigator.clipboard.writeText(t.id.slice(0,8).toUpperCase()),C.success("Order ID copied to clipboard"))},m=h=>{const f=h.toLowerCase();return f==="completed"?4:f==="cancelled"||f==="failed"?-1:oc.findIndex(b=>b.key===f)},p=h=>{switch(h){case"KES":return"KSh";case"GBP":return"£";case"USD":return"$";default:return h}},x=h=>new Date(h).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}),g=h=>new Date(h).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});if(a)return e.jsxs("div",{className:"flex min-h-screen flex-col bg-gradient-to-b from-stone-50 to-white",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ue,{className:"mx-auto h-12 w-12 animate-spin text-emerald-600"}),e.jsx("p",{className:"mt-4 text-stone-600",children:"Loading order details..."})]})}),e.jsx(We,{})]});if(i||!t)return e.jsxs("div",{className:"flex min-h-screen flex-col bg-gradient-to-b from-stone-50 to-white",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center px-4",children:e.jsx(X,{className:"max-w-md w-full border-red-200 bg-red-50/50",children:e.jsxs(ee,{className:"pt-8 text-center",children:[e.jsx(po,{className:"mx-auto h-16 w-16 text-red-400"}),e.jsx("h2",{className:"mt-4 text-xl font-semibold text-stone-800",children:"Order Not Found"}),e.jsx("p",{className:"mt-2 text-stone-600",children:i||"We couldn't find this order."}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3",children:[e.jsx(Oe,{to:"/profile",children:e.jsx(R,{className:"w-full bg-emerald-600 hover:bg-emerald-700",children:"View My Orders"})}),e.jsx(Oe,{to:"/shop",children:e.jsx(R,{variant:"outline",className:"w-full",children:"Continue Shopping"})})]})]})})}),e.jsx(We,{})]});const u=m(t.status),y=t.status.toLowerCase()==="cancelled"||t.status.toLowerCase()==="failed";return e.jsxs("div",{className:"flex min-h-screen flex-col bg-gradient-to-b from-stone-50 to-white",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-8 md:py-12",children:e.jsxs("div",{className:"container max-w-4xl px-4",children:[e.jsxs(Oe,{to:"/profile",className:"mb-6 inline-flex items-center gap-2 text-sm text-stone-600 hover:text-emerald-600 transition-colors",children:[e.jsx(Rn,{className:"h-4 w-4"}),"Back to My Orders"]}),e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-stone-800 tracking-tight",children:"Order Tracking"}),e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsxs("span",{className:"font-mono text-lg font-semibold text-emerald-700",children:["#",t.id.slice(0,8).toUpperCase()]}),e.jsx("button",{onClick:c,className:"p-1.5 rounded-md hover:bg-stone-100 transition-colors",title:"Copy Order ID",children:e.jsx(fn,{className:"h-4 w-4 text-stone-400"})})]})]}),e.jsx(Le,{className:`text-sm px-4 py-1.5 ${y?"bg-red-100 text-red-700 border-red-200":u===4?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-amber-100 text-amber-700 border-amber-200"}`,children:t.status.charAt(0).toUpperCase()+t.status.slice(1)})]})}),!y&&e.jsxs(X,{className:"mb-8 border-stone-200 overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-emerald-600 to-teal-600 px-6 py-4",children:e.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[e.jsx(Et,{className:"h-5 w-5"}),"Order Progress"]})}),e.jsxs(ee,{className:"p-6 md:p-8",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-[22px] top-8 bottom-8 w-0.5 bg-stone-200 md:hidden"}),e.jsx("div",{className:"hidden md:block absolute top-6 left-0 right-0 h-0.5 bg-stone-200",style:{left:"10%",right:"10%"}}),e.jsx("div",{className:"hidden md:block absolute top-6 left-0 h-0.5 bg-emerald-500 transition-all duration-500",style:{left:"10%",width:`${Math.max(0,Math.min(80,u/4*80))}%`}}),e.jsx("div",{className:"space-y-6 md:space-y-0 md:flex md:justify-between",children:oc.map((h,f)=>{const b=f<=u,v=f===u,j=h.icon;return e.jsxs("div",{className:`relative flex md:flex-col md:items-center md:text-center gap-4 md:gap-2 ${f<=u?"opacity-100":"opacity-40"}`,children:[e.jsx("div",{className:`relative z-10 flex h-11 w-11 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-300 ${b?"border-emerald-500 bg-emerald-500 text-white":"border-stone-300 bg-white text-stone-400"} ${v?"ring-4 ring-emerald-100":""}`,children:e.jsx(j,{className:"h-5 w-5"})}),e.jsxs("div",{className:"md:mt-3",children:[e.jsx("p",{className:`font-medium text-sm ${b?"text-stone-800":"text-stone-500"}`,children:h.label}),e.jsx("p",{className:"text-xs text-stone-500 mt-0.5 hidden md:block max-w-[100px]",children:h.description})]})]},h.key)})})]}),t.estimated_delivery_date&&e.jsx("div",{className:"mt-8 p-4 bg-emerald-50 rounded-lg border border-emerald-100",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Wc,{className:"h-5 w-5 text-emerald-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-stone-600",children:"Estimated Delivery"}),e.jsx("p",{className:"font-semibold text-emerald-700",children:x(t.estimated_delivery_date)})]})]})})]})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(X,{className:"border-stone-200",children:e.jsxs(ee,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold text-stone-800 mb-4 flex items-center gap-2",children:[e.jsx(Et,{className:"h-5 w-5 text-emerald-600"}),"Order Items"]}),e.jsx("div",{className:"space-y-4",children:t.items.map((h,f)=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-16 w-16 rounded-lg bg-stone-100 flex items-center justify-center overflow-hidden",children:h.image?e.jsx("img",{src:h.image,alt:h.name,className:"h-full w-full object-cover"}):e.jsx(Et,{className:"h-6 w-6 text-stone-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-stone-800 truncate",children:h.name}),e.jsxs("p",{className:"text-sm text-stone-500",children:["Qty: ",h.quantity]})]}),e.jsxs("p",{className:"font-semibold text-stone-800",children:[p(t.currency),h.price.toFixed(2)]})]},f))}),e.jsx(Im,{className:"my-4"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-medium text-stone-600",children:"Total"}),e.jsxs("span",{className:"text-xl font-bold text-emerald-700",children:[p(t.currency),t.total_amount.toFixed(2)]})]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(X,{className:"border-stone-200",children:e.jsxs(ee,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold text-stone-800 mb-4 flex items-center gap-2",children:[e.jsx(rs,{className:"h-5 w-5 text-emerald-600"}),"Shipping Address"]}),t.shipping_address?e.jsxs("div",{className:"text-stone-600 space-y-1",children:[t.shipping_address.name&&e.jsx("p",{className:"font-medium text-stone-800",children:t.shipping_address.name}),t.shipping_address.line1&&e.jsx("p",{children:t.shipping_address.line1}),t.shipping_address.line2&&e.jsx("p",{children:t.shipping_address.line2}),e.jsx("p",{children:[t.shipping_address.city,t.shipping_address.postal_code].filter(Boolean).join(", ")}),t.shipping_address.country&&e.jsx("p",{children:t.shipping_address.country}),t.shipping_address.phone&&e.jsxs("p",{className:"mt-2 text-sm",children:["Phone: ",t.shipping_address.phone]})]}):e.jsx("p",{className:"text-stone-500 text-sm",children:"Shipping address will be confirmed via email."})]})}),(t.tracking_number||t.tracking_carrier)&&e.jsx(X,{className:"border-emerald-200 bg-emerald-50/30",children:e.jsxs(ee,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold text-stone-800 mb-4 flex items-center gap-2",children:[e.jsx(On,{className:"h-5 w-5 text-emerald-600"}),"Tracking Information"]}),e.jsxs("div",{className:"space-y-3 text-sm",children:[t.tracking_carrier&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-stone-500",children:"Carrier"}),e.jsx("span",{className:"font-medium text-stone-800",children:t.tracking_carrier})]}),t.tracking_number&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-stone-500",children:"Tracking Number"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-stone-800",children:t.tracking_number}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t.tracking_number||""),C.success("Tracking number copied")},className:"p-1 rounded hover:bg-stone-100",children:e.jsx(fn,{className:"h-3 w-3 text-stone-400"})})]})]}),t.shipped_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-stone-500",children:"Shipped On"}),e.jsx("span",{className:"font-medium text-stone-800",children:g(t.shipped_at)})]}),t.delivered_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-stone-500",children:"Delivered On"}),e.jsx("span",{className:"font-medium text-emerald-700",children:g(t.delivered_at)})]})]})]})}),e.jsx(X,{className:"border-stone-200",children:e.jsxs(ee,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold text-stone-800 mb-4 flex items-center gap-2",children:[e.jsx(Ka,{className:"h-5 w-5 text-emerald-600"}),"Payment Details"]}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-stone-500",children:"Method"}),e.jsx("span",{className:"font-medium text-stone-800",children:t.payment_method==="mpesa"?"M-Pesa":t.payment_method==="paystack"?"Paystack":"Card Payment"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-stone-500",children:"Date"}),e.jsx("span",{className:"font-medium text-stone-800",children:g(t.created_at)})]}),t.mpesa_transaction_id&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-stone-500",children:"M-Pesa Ref"}),e.jsx("span",{className:"font-mono text-stone-800",children:t.mpesa_transaction_id})]})]})]})})]})]}),e.jsx(X,{className:"mt-8 border-emerald-200 bg-emerald-50/50",children:e.jsx(ee,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-stone-800",children:"Need Help?"}),e.jsxs("p",{className:"text-sm text-stone-600 mt-1",children:["Contact us at ",e.jsx("a",{href:"mailto:info@moenviron.com",className:"text-emerald-600 hover:underline",children:"info@moenviron.com"})," or via WhatsApp"]})]}),e.jsx(Oe,{to:"/contact",children:e.jsx(R,{variant:"outline",className:"border-emerald-300 text-emerald-700 hover:bg-emerald-100",children:"Contact Support"})})]})})})]})}),e.jsx(We,{})]})},sj=Io({email:da().email("Please enter a valid email address"),password:da().min(6,"Password must be at least 6 characters")}),rj=()=>{const s=ns(),{user:t,isLoading:r,isAdmin:a,userRole:n}=Bt(),[i,o]=d.useState(""),[l,c]=d.useState(""),[m,p]=d.useState(!1),[x,g]=d.useState({}),[u,y]=d.useState(null);d.useEffect(()=>{t&&!r&&a&&n&&n!=="user"&&s("/staff")},[t,r,a,n,s]);const h=()=>{const b=sj.safeParse({email:i,password:l});if(!b.success){const v={};return b.error.errors.forEach(j=>{j.path[0]==="email"&&(v.email=j.message),j.path[0]==="password"&&(v.password=j.message)}),g(v),!1}return g({}),!0},f=async b=>{if(b.preventDefault(),!h())return;p(!0),y(null);const{error:v}=await M.auth.signInWithPassword({email:i,password:l});if(v){p(!1),v.message.includes("Invalid login credentials")?y("Invalid email or password"):y(v.message);return}const{data:j}=await M.auth.getUser();if(j.user){const{data:_}=await M.from("user_roles").select("role").eq("user_id",j.user.id).maybeSingle();_&&_.role!=="user"?(C.success(`Welcome, ${_.role.charAt(0).toUpperCase()+_.role.slice(1)}!`),s("/staff")):(await M.auth.signOut(),y("Access denied. This account does not have staff privileges."))}p(!1)};return r?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex flex-1 items-center justify-center py-12",children:e.jsx("div",{className:"container max-w-md",children:e.jsxs(X,{className:"border-border/50",children:[e.jsxs(ye,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-forest",children:e.jsx(rr,{className:"h-6 w-6 text-white"})}),e.jsx(be,{className:"text-2xl",children:"Staff Portal"}),e.jsx(Be,{children:"Sign in with your staff credentials"})]}),e.jsxs(ee,{children:[u&&e.jsxs(Ur,{variant:"destructive",className:"mb-4",children:[e.jsx(po,{className:"h-4 w-4"}),e.jsx(Hr,{children:u})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(B,{htmlFor:"staff-email",children:"Email"}),e.jsx(Q,{id:"staff-email",type:"email",value:i,onChange:b=>o(b.target.value),placeholder:"staff@example.com",disabled:m}),x.email&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:x.email})]}),e.jsxs("div",{children:[e.jsx(B,{htmlFor:"staff-password",children:"Password"}),e.jsx(Q,{id:"staff-password",type:"password",value:l,onChange:b=>c(b.target.value),placeholder:"••••••••",disabled:m}),x.password&&e.jsx("p",{className:"mt-1 text-sm text-destructive",children:x.password})]}),e.jsx(R,{type:"submit",className:"w-full bg-forest hover:bg-forest/90",disabled:m,children:m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In as Staff"})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Admin access?"," ",e.jsx(R,{variant:"link",className:"p-0 h-auto",onClick:()=>s("/admin-login"),children:"Go to Admin Portal"})]})})]})]})})}),e.jsx(We,{})]})},lc=["#1A3C34","#2D5A4E","#4A7C6F","#6B9D8F","#8CBFAF"],aj=()=>{const s=ns(),{user:t,isLoading:r,isAdmin:a,userRole:n}=Bt(),[i,o]=d.useState([]),[l,c]=d.useState([]),[m,p]=d.useState([]),[x,g]=d.useState(!0),[u,y]=d.useState({totalOrders:0,pendingOrders:0,completedOrders:0,totalRevenue:0,totalProducts:0,lowStockProducts:0,totalSubscribers:0,newSubscribersThisWeek:0}),h=a&&n&&n!=="user",f=n==="admin"||n==="shipping"||n==="support",b=n==="admin"||n==="content",v=n==="admin"||n==="marketing",j=n==="admin"||n==="marketing",_=()=>{switch(n){case"admin":return"Super Admin";case"marketing":return"Marketing Team";case"shipping":return"Shipping & Fulfillment";case"support":return"Customer Support";case"content":return"Content Manager";default:return"Staff Member"}},I=()=>{switch(n){case"admin":return"Full access to all systems";case"marketing":return"Manage subscribers and campaigns";case"shipping":return"Track and manage shipments";case"support":return"Handle customer inquiries";case"content":return"Manage products and content";default:return"Assigned tasks"}},E=()=>{switch(n){case"marketing":return e.jsx(zt,{className:"h-5 w-5"});case"shipping":return e.jsx(On,{className:"h-5 w-5"});case"support":return e.jsx(Ra,{className:"h-5 w-5"});case"content":return e.jsx(td,{className:"h-5 w-5"});default:return e.jsx(rr,{className:"h-5 w-5"})}};d.useEffect(()=>{!r&&(!t||!h)&&s("/staff-login")},[t,h,r,s]),d.useEffect(()=>{h&&O()},[h]);const O=async()=>{g(!0);const[P,S,W]=await Promise.all([M.from("orders").select("*").order("created_at",{ascending:!1}),M.from("products").select("*").order("created_at",{ascending:!1}),M.from("newsletter_subscribers").select("*").order("subscribed_at",{ascending:!1})]);if(P.data){o(P.data);const K=P.data.filter(A=>A.status==="delivered"||A.status==="completed"),F=P.data.filter(A=>A.status==="pending"||A.status==="processing"),k=K.reduce((A,q)=>A+Number(q.total_amount),0);y(A=>({...A,totalOrders:P.data.length,pendingOrders:F.length,completedOrders:K.length,totalRevenue:k}))}if(S.data){c(S.data);const K=S.data.filter(F=>F.stock_quantity<10);y(F=>({...F,totalProducts:S.data.length,lowStockProducts:K.length}))}if(W.data){p(W.data);const K=new Date;K.setDate(K.getDate()-7);const F=W.data.filter(k=>new Date(k.subscribed_at)>K);y(k=>({...k,totalSubscribers:W.data.length,newSubscribersThisWeek:F.length}))}g(!1)},D=async(P,S)=>{const W=i.find(k=>k.id===P);if(!W)return;const K={status:S};S==="shipped"?K.shipped_at=new Date().toISOString():S==="delivered"&&(K.delivered_at=new Date().toISOString());const{error:F}=await M.from("orders").update(K).eq("id",P);if(F){C.error("Failed to update order");return}if(C.success("Order status updated"),O(),["shipped","delivered","confirmed","arrived","processing"].includes(S.toLowerCase()))try{await M.functions.invoke("send-order-status-update",{body:{orderId:W.id,userEmail:W.user_email,userName:W.user_name||"Valued Customer",newStatus:S,totalAmount:W.total_amount,currency:"GBP"}}),C.success("Email notification sent")}catch(k){console.error("Error sending status email:",k)}},N=()=>{const P={},S=new Date;for(let W=6;W>=0;W--){const K=new Date(S);K.setDate(K.getDate()-W);const F=K.toLocaleDateString("en-GB",{weekday:"short"});P[F]=0}return i.forEach(W=>{const K=new Date(W.created_at),F=S.getTime()-K.getTime();if(Math.floor(F/(1e3*60*60*24))<7){const A=K.toLocaleDateString("en-GB",{weekday:"short"});P[A]!==void 0&&P[A]++}}),Object.entries(P).map(([W,K])=>({day:W,orders:K}))},T=()=>{const P={};return i.forEach(S=>{P[S.status]=(P[S.status]||0)+1}),Object.entries(P).map(([S,W])=>({name:S,value:W}))};return r||x?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-forest"})}):h?e.jsxs("div",{className:"flex min-h-screen flex-col bg-gray-50",children:[e.jsx(Ve,{}),e.jsx("main",{className:"flex-1 py-8",children:e.jsxs("div",{className:"container",children:[e.jsxs("div",{className:"mb-8 flex items-center gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-forest text-white",children:E()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:[_()," Dashboard"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:I()})]}),e.jsx(Le,{variant:"outline",className:"capitalize text-forest border-forest",children:n})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4 mb-8",children:[f&&e.jsxs(e.Fragment,{children:[e.jsxs(X,{className:"border-l-4 border-l-forest",children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Total Orders"}),e.jsx(gn,{className:"h-4 w-4 text-forest"})]}),e.jsxs(ee,{children:[e.jsx("div",{className:"text-2xl font-bold",children:u.totalOrders}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.pendingOrders," pending"]})]})]}),e.jsxs(X,{className:"border-l-4 border-l-amber-500",children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Revenue"}),e.jsx(Qc,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(ee,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["£",u.totalRevenue.toFixed(2)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["From ",u.completedOrders," completed orders"]})]})]})]}),b&&e.jsxs(X,{className:"border-l-4 border-l-blue-500",children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Products"}),e.jsx(Et,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(ee,{children:[e.jsx("div",{className:"text-2xl font-bold",children:u.totalProducts}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.lowStockProducts," low stock"]})]})]}),v&&e.jsxs(X,{className:"border-l-4 border-l-purple-500",children:[e.jsxs(ye,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Subscribers"}),e.jsx(zt,{className:"h-4 w-4 text-purple-500"})]}),e.jsxs(ee,{children:[e.jsx("div",{className:"text-2xl font-bold",children:u.totalSubscribers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+",u.newSubscribersThisWeek," this week"]})]})]})]}),e.jsxs(Ir,{defaultValue:f?"orders":j?"analytics":"chat",className:"w-full",children:[e.jsxs(ar,{className:"mb-6 flex-wrap",children:[j&&e.jsxs(Ye,{value:"analytics",className:"gap-2",children:[e.jsx(ho,{className:"h-4 w-4"}),"Analytics"]}),f&&e.jsxs(Ye,{value:"orders",className:"gap-2",children:[e.jsx(gn,{className:"h-4 w-4"}),"Orders"]}),b&&e.jsxs(Ye,{value:"products",className:"gap-2",children:[e.jsx(Et,{className:"h-4 w-4"}),"Products"]}),v&&e.jsxs(Ye,{value:"subscribers",className:"gap-2",children:[e.jsx(zt,{className:"h-4 w-4"}),"Subscribers"]}),e.jsxs(Ye,{value:"chat",className:"gap-2",children:[e.jsx(Ra,{className:"h-4 w-4"}),"Team Chat"]})]}),e.jsx($e,{value:"analytics",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{className:"text-lg",children:"Orders This Week"}),e.jsx(Be,{children:"Daily order volume for the past 7 days"})]}),e.jsx(ee,{children:e.jsx("div",{className:"h-[300px]",children:e.jsx(mn,{width:"100%",height:"100%",children:e.jsxs(gi,{data:N(),children:[e.jsx(yi,{strokeDasharray:"3 3",stroke:"#e5e5e5"}),e.jsx(bi,{dataKey:"day",stroke:"#888",fontSize:12}),e.jsx(vi,{stroke:"#888",fontSize:12}),e.jsx(hn,{contentStyle:{backgroundColor:"white",border:"1px solid #e5e5e5",borderRadius:"8px"}}),e.jsx(ji,{type:"monotone",dataKey:"orders",stroke:"#1A3C34",fill:"#1A3C34",fillOpacity:.2})]})})})})]}),e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{className:"text-lg",children:"Order Status Distribution"}),e.jsx(Be,{children:"Current order status breakdown"})]}),e.jsx(ee,{children:e.jsx("div",{className:"h-[300px]",children:e.jsx(mn,{width:"100%",height:"100%",children:e.jsxs(oh,{children:[e.jsx(lh,{data:T(),cx:"50%",cy:"50%",labelLine:!1,label:({name:P,percent:S})=>`${P} (${(S*100).toFixed(0)}%)`,outerRadius:100,fill:"#8884d8",dataKey:"value",children:T().map((P,S)=>e.jsx(ch,{fill:lc[S%lc.length]},`cell-${S}`))}),e.jsx(hn,{})]})})})})]}),e.jsxs(X,{className:"lg:col-span-2",children:[e.jsx(ye,{children:e.jsx(be,{className:"text-lg",children:"Quick Stats"})}),e.jsx(ee,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-green-50 rounded-lg",children:[e.jsx(wt,{className:"h-8 w-8 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),e.jsx("p",{className:"text-xl font-bold text-green-600",children:u.completedOrders})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-50 rounded-lg",children:[e.jsx(xo,{className:"h-8 w-8 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pending"}),e.jsx("p",{className:"text-xl font-bold text-amber-600",children:u.pendingOrders})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-50 rounded-lg",children:[e.jsx(Et,{className:"h-8 w-8 text-blue-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Products"}),e.jsx("p",{className:"text-xl font-bold text-blue-600",children:u.totalProducts})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-purple-50 rounded-lg",children:[e.jsx(_r,{className:"h-8 w-8 text-purple-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"New Subs"}),e.jsxs("p",{className:"text-xl font-bold text-purple-600",children:["+",u.newSubscribersThisWeek]})]})]})]})})]})]})}),e.jsx($e,{value:"orders",children:e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Orders Management"}),e.jsx(Be,{children:"View and manage customer orders"})]}),e.jsx(ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Order ID"}),e.jsx(ae,{children:"Customer"}),e.jsx(ae,{children:"Amount"}),e.jsx(ae,{children:"Payment"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{children:"Date"}),e.jsx(ae,{children:"Actions"})]})}),e.jsx(Rt,{children:i.slice(0,20).map(P=>e.jsxs(Qe,{children:[e.jsxs(se,{className:"font-mono text-sm",children:[P.id.slice(0,8),"..."]}),e.jsx(se,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.user_name||"Guest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:P.user_email})]})}),e.jsxs(se,{className:"font-medium",children:["£",Number(P.total_amount).toFixed(2)]}),e.jsx(se,{children:e.jsx(Le,{variant:"outline",children:P.payment_method})}),e.jsx(se,{children:e.jsx(Le,{variant:P.status==="delivered"||P.status==="completed"?"default":P.status==="pending"?"secondary":"outline",className:P.status==="delivered"||P.status==="completed"?"bg-green-500":P.status==="shipped"?"bg-blue-500 text-white":"",children:P.status})}),e.jsx(se,{children:new Date(P.created_at).toLocaleDateString()}),e.jsx(se,{children:e.jsxs("select",{value:P.status,onChange:S=>D(P.id,S.target.value),className:"rounded border border-border bg-background px-2 py-1 text-sm",children:[e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"confirmed",children:"Confirmed"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"shipped",children:"Shipped"}),e.jsx("option",{value:"arrived",children:"Arrived"}),e.jsx("option",{value:"delivered",children:"Delivered"}),e.jsx("option",{value:"cancelled",children:"Cancelled"})]})})]},P.id))})]})})})]})}),e.jsx($e,{value:"products",children:e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Products Overview"}),e.jsx(Be,{children:"View product inventory and status"})]}),e.jsx(ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Product"}),e.jsx(ae,{children:"Category"}),e.jsx(ae,{children:"Price"}),e.jsx(ae,{children:"Stock"}),e.jsx(ae,{children:"Status"})]})}),e.jsx(Rt,{children:l.map(P=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium",children:P.name}),e.jsx(se,{children:P.category}),e.jsxs(se,{children:["£",P.price.toFixed(2)]}),e.jsx(se,{children:e.jsx("span",{className:P.stock_quantity<10?"text-red-500 font-medium":"",children:P.stock_quantity})}),e.jsx(se,{children:e.jsx(Le,{variant:P.is_active?"default":"secondary",children:P.is_active?"Active":"Inactive"})})]},P.id))})]})})})]})}),e.jsx($e,{value:"subscribers",children:e.jsxs(X,{children:[e.jsxs(ye,{children:[e.jsx(be,{children:"Newsletter Subscribers"}),e.jsx(Be,{children:"Manage your subscriber list"})]}),e.jsx(ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pt,{children:[e.jsx(At,{children:e.jsxs(Qe,{children:[e.jsx(ae,{children:"Email"}),e.jsx(ae,{children:"Subscribed Date"}),e.jsx(ae,{children:"Status"})]})}),e.jsx(Rt,{children:m.map(P=>e.jsxs(Qe,{children:[e.jsx(se,{className:"font-medium",children:P.email}),e.jsx(se,{children:new Date(P.subscribed_at).toLocaleDateString()}),e.jsx(se,{children:e.jsx(Le,{variant:P.is_active?"default":"secondary",children:P.is_active?"Active":"Unsubscribed"})})]},P.id))})]})})})]})}),e.jsx($e,{value:"chat",children:e.jsx(_m,{})})]})]})}),e.jsx(We,{})]}):null},nj=()=>{const[s]=d.useState(()=>new Dx);return e.jsx(Hd,{children:e.jsx(Lx,{client:s,children:e.jsx(ux,{children:e.jsxs(Uf,{children:[e.jsx(Hp,{}),e.jsx(Nf,{}),e.jsx(qg,{}),e.jsxs(nh,{children:[e.jsx(ex,{}),e.jsx(tx,{}),e.jsx(Xf,{}),e.jsxs(ih,{children:[e.jsx(tt,{path:"/",element:e.jsx(Fg,{})}),e.jsx(tt,{path:"/shop",element:e.jsx(Ug,{})}),e.jsx(tt,{path:"/shop/:id",element:e.jsx(Vg,{})}),e.jsx(tt,{path:"/about",element:e.jsx(Wg,{})}),e.jsx(tt,{path:"/impact",element:e.jsx(Jg,{})}),e.jsx(tt,{path:"/projects",element:e.jsx(sy,{})}),e.jsx(tt,{path:"/partners",element:e.jsx(ny,{})}),e.jsx(tt,{path:"/contact",element:e.jsx(dy,{})}),e.jsx(tt,{path:"/cart",element:e.jsx(_y,{})}),e.jsx(tt,{path:"/checkout",element:e.jsx(Cy,{})}),e.jsx(tt,{path:"/checkout/success",element:e.jsx(Ey,{})}),e.jsx(tt,{path:"/auth",element:e.jsx(sb,{})}),e.jsx(tt,{path:"/admin-login",element:e.jsx(nb,{})}),e.jsx(tt,{path:"/admin",element:e.jsx(F0,{})}),e.jsx(tt,{path:"/profile",element:e.jsx(q0,{})}),e.jsx(tt,{path:"/donate",element:e.jsx(H0,{})}),e.jsx(tt,{path:"/wishlist",element:e.jsx(V0,{})}),e.jsx(tt,{path:"/privacy",element:e.jsx(W0,{})}),e.jsx(tt,{path:"/terms",element:e.jsx(K0,{})}),e.jsx(tt,{path:"/returns",element:e.jsx(G0,{})}),e.jsx(tt,{path:"/orders/:id",element:e.jsx(tj,{})}),e.jsx(tt,{path:"/staff-login",element:e.jsx(rj,{})}),e.jsx(tt,{path:"/staff",element:e.jsx(aj,{})}),e.jsx(tt,{path:"*",element:e.jsx(Y0,{})})]})]})]})})})})};if(typeof window<"u"){const s=t=>{try{window.parent&&window.parent!==window&&window.parent.postMessage(t,"*")}catch{}};window.addEventListener("error",t=>{var r;s({type:"ERROR_CAPTURED",error:{message:t.message,stack:(r=t.error)==null?void 0:r.stack,filename:t.filename,lineno:t.lineno,colno:t.colno,source:"window.onerror"},timestamp:Date.now()})}),window.addEventListener("unhandledrejection",t=>{const r=t.reason,a=typeof r=="object"&&(r!=null&&r.message)?String(r.message):String(r),n=typeof r=="object"?r==null?void 0:r.stack:void 0;s({type:"ERROR_CAPTURED",error:{message:a,stack:n,filename:void 0,lineno:void 0,colno:void 0,source:"unhandledrejection"},timestamp:Date.now()})})}console.log("Mounting React app...");yh.createRoot(document.getElementById("root")).render(e.jsx(nj,{}));