@nymbalhq/admin 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,313 @@
1
+ var Ka=e=>{throw TypeError(e)};var Hs=(e,t,n)=>t.has(e)||Ka("Cannot "+n);var b=(e,t,n)=>(Hs(e,t,"read from private field"),n?n.call(e):t.get(e)),F=(e,t,n)=>t.has(e)?Ka("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,s)=>(Hs(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),J=(e,t,n)=>(Hs(e,t,"access private method"),n);var zr=(e,t,n,s)=>({set _(o){M(e,t,o,n)},get _(){return b(e,t,s)}});import{r as l,a as Sr,u as yt,N as Ff,b as $f,L as an,R as Qo,c as Uf,d as qe,O as Vf,e as Yo,f as Bf,g as Kf,h as Hf}from"./vendor-dpy99fWE.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();var tc={exports:{}},xs={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var qf=l,Wf=Symbol.for("react.element"),Gf=Symbol.for("react.fragment"),Qf=Object.prototype.hasOwnProperty,Yf=qf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Xf={key:!0,ref:!0,__self:!0,__source:!0};function nc(e,t,n){var s,o={},a=null,i=null;n!==void 0&&(a=""+n),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(i=t.ref);for(s in t)Qf.call(t,s)&&!Xf.hasOwnProperty(s)&&(o[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)o[s]===void 0&&(o[s]=t[s]);return{$$typeof:Wf,type:e,key:a,ref:i,props:o,_owner:Yf.current}}xs.Fragment=Gf;xs.jsx=nc;xs.jsxs=nc;tc.exports=xs;var r=tc.exports,rc,Ha=Sr;rc=Ha.createRoot,Ha.hydrateRoot;var Qn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Xt,Pt,Tn,Ki,Zf=(Ki=class extends Qn{constructor(){super();F(this,Xt);F(this,Pt);F(this,Tn);M(this,Tn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){b(this,Pt)||this.setEventListener(b(this,Tn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,Pt))==null||t.call(this),M(this,Pt,void 0))}setEventListener(t){var n;M(this,Tn,t),(n=b(this,Pt))==null||n.call(this),M(this,Pt,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){b(this,Xt)!==t&&(M(this,Xt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof b(this,Xt)=="boolean"?b(this,Xt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Xt=new WeakMap,Pt=new WeakMap,Tn=new WeakMap,Ki),Xo=new Zf,Jf={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},kt,Go,Hi,eh=(Hi=class{constructor(){F(this,kt,Jf);F(this,Go,!1)}setTimeoutProvider(e){M(this,kt,e)}setTimeout(e,t){return b(this,kt).setTimeout(e,t)}clearTimeout(e){b(this,kt).clearTimeout(e)}setInterval(e,t){return b(this,kt).setInterval(e,t)}clearInterval(e){b(this,kt).clearInterval(e)}},kt=new WeakMap,Go=new WeakMap,Hi),Gt=new eh;function th(e){setTimeout(e,0)}var nh=typeof window>"u"||"Deno"in globalThis;function Re(){}function rh(e,t){return typeof e=="function"?e(t):e}function ho(e){return typeof e=="number"&&e>=0&&e!==1/0}function sc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function zt(e,t){return typeof e=="function"?e(t):e}function Oe(e,t){return typeof e=="function"?e(t):e}function qa(e,t){const{type:n="all",exact:s,fetchStatus:o,predicate:a,queryKey:i,stale:c}=e;if(i){if(s){if(t.queryHash!==Zo(i,t.options))return!1}else if(!fr(t.queryKey,i))return!1}if(n!=="all"){const u=t.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||o&&o!==t.state.fetchStatus||a&&!a(t))}function Wa(e,t){const{exact:n,status:s,predicate:o,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ln(t.options.mutationKey)!==ln(a))return!1}else if(!fr(t.options.mutationKey,a))return!1}return!(s&&t.state.status!==s||o&&!o(t))}function Zo(e,t){return((t==null?void 0:t.queryKeyHashFn)||ln)(e)}function ln(e){return JSON.stringify(e,(t,n)=>mo(n)?Object.keys(n).sort().reduce((s,o)=>(s[o]=n[o],s),{}):n)}function fr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>fr(e[n],t[n])):!1}var sh=Object.prototype.hasOwnProperty;function oc(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=Ga(e)&&Ga(t);if(!s&&!(mo(e)&&mo(t)))return t;const a=(s?e:Object.keys(e)).length,i=s?t:Object.keys(t),c=i.length,u=s?new Array(c):{};let d=0;for(let h=0;h<c;h++){const f=s?h:i[h],m=e[f],g=t[f];if(m===g){u[f]=m,(s?h<a:sh.call(e,f))&&d++;continue}if(m===null||g===null||typeof m!="object"||typeof g!="object"){u[f]=g;continue}const v=oc(m,g,n+1);u[f]=v,v===m&&d++}return a===c&&d===a?e:u}function es(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Ga(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function mo(e){if(!Qa(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Qa(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Qa(e){return Object.prototype.toString.call(e)==="[object Object]"}function oh(e){return new Promise(t=>{Gt.setTimeout(t,e)})}function po(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?oc(e,t):t}function ah(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function ih(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var Jo=Symbol();function ac(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Jo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ea(e,t){return typeof e=="function"?e(...t):!!e}function ch(e,t,n){let s=!1,o;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??(o=t()),s||(s=!0,o.aborted?n():o.addEventListener("abort",n,{once:!0})),o)}),e}var hr=(()=>{let e=()=>nh;return{isServer(){return e()},setIsServer(t){e=t}}})();function xo(){let e,t;const n=new Promise((o,a)=>{e=o,t=a});n.status="pending",n.catch(()=>{});function s(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{s({status:"fulfilled",value:o}),e(o)},n.reject=o=>{s({status:"rejected",reason:o}),t(o)},n}var lh=th;function dh(){let e=[],t=0,n=c=>{c()},s=c=>{c()},o=lh;const a=c=>{t?e.push(c):o(()=>{n(c)})},i=()=>{const c=e;e=[],c.length&&o(()=>{s(()=>{c.forEach(u=>{n(u)})})})};return{batch:c=>{let u;t++;try{u=c()}finally{t--,t||i()}return u},batchCalls:c=>(...u)=>{a(()=>{c(...u)})},schedule:a,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{s=c},setScheduler:c=>{o=c}}}var ye=dh(),An,Tt,Mn,qi,uh=(qi=class extends Qn{constructor(){super();F(this,An,!0);F(this,Tt);F(this,Mn);M(this,Mn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}}})}onSubscribe(){b(this,Tt)||this.setEventListener(b(this,Mn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,Tt))==null||t.call(this),M(this,Tt,void 0))}setEventListener(t){var n;M(this,Mn,t),(n=b(this,Tt))==null||n.call(this),M(this,Tt,t(this.setOnline.bind(this)))}setOnline(t){b(this,An)!==t&&(M(this,An,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return b(this,An)}},An=new WeakMap,Tt=new WeakMap,Mn=new WeakMap,qi),ts=new uh;function fh(e){return Math.min(1e3*2**e,3e4)}function ic(e){return(e??"online")==="online"?ts.isOnline():!0}var go=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function cc(e){let t=!1,n=0,s;const o=xo(),a=()=>o.status!=="pending",i=p=>{var x;if(!a()){const y=new go(p);m(y),(x=e.onCancel)==null||x.call(e,y)}},c=()=>{t=!0},u=()=>{t=!1},d=()=>Xo.isFocused()&&(e.networkMode==="always"||ts.isOnline())&&e.canRun(),h=()=>ic(e.networkMode)&&e.canRun(),f=p=>{a()||(s==null||s(),o.resolve(p))},m=p=>{a()||(s==null||s(),o.reject(p))},g=()=>new Promise(p=>{var x;s=y=>{(a()||d())&&p(y)},(x=e.onPause)==null||x.call(e)}).then(()=>{var p;s=void 0,a()||(p=e.onContinue)==null||p.call(e)}),v=()=>{if(a())return;let p;const x=n===0?e.initialPromise:void 0;try{p=x??e.fn()}catch(y){p=Promise.reject(y)}Promise.resolve(p).then(f).catch(y=>{var E;if(a())return;const w=e.retry??(hr.isServer()?0:3),N=e.retryDelay??fh,j=typeof N=="function"?N(n,y):N,C=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!C){m(y);return}n++,(E=e.onFail)==null||E.call(e,n,y),oh(j).then(()=>d()?void 0:g()).then(()=>{t?m(y):v()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(s==null||s(),o),cancelRetry:c,continueRetry:u,canStart:h,start:()=>(h()?v():g().then(v),o)}}var Zt,Wi,lc=(Wi=class{constructor(){F(this,Zt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ho(this.gcTime)&&M(this,Zt,Gt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(hr.isServer()?1/0:5*60*1e3))}clearGcTimeout(){b(this,Zt)!==void 0&&(Gt.clearTimeout(b(this,Zt)),M(this,Zt,void 0))}},Zt=new WeakMap,Wi),Jt,_n,$e,en,we,br,tn,Ie,dc,lt,Gi,hh=(Gi=class extends lc{constructor(t){super();F(this,Ie);F(this,Jt);F(this,_n);F(this,$e);F(this,en);F(this,we);F(this,br);F(this,tn);M(this,tn,!1),M(this,br,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,en,t.client),M(this,$e,b(this,en).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,Jt,Xa(this.options)),this.state=t.state??b(this,Jt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=b(this,we))==null?void 0:t.promise}setOptions(t){if(this.options={...b(this,br),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Xa(this.options);n.data!==void 0&&(this.setState(Ya(n.data,n.dataUpdatedAt)),M(this,Jt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&b(this,$e).remove(this)}setData(t,n){const s=po(this.state.data,t,this.options);return J(this,Ie,lt).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(t,n){J(this,Ie,lt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var s,o;const n=(s=b(this,we))==null?void 0:s.promise;return(o=b(this,we))==null||o.cancel(t),n?n.then(Re).catch(Re):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return b(this,Jt)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Oe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>zt(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:!sc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,we))==null||n.continue()}onOnline(){var n;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,we))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),b(this,$e).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(b(this,we)&&(b(this,tn)||J(this,Ie,dc).call(this)?b(this,we).cancel({revert:!0}):b(this,we).cancelRetry()),this.scheduleGc()),b(this,$e).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||J(this,Ie,lt).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,h,f,m,g,v,p,x,y,w,N;if(this.state.fetchStatus!=="idle"&&((u=b(this,we))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(b(this,we))return b(this,we).continueRetry(),b(this,we).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const s=new AbortController,o=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(M(this,tn,!0),s.signal)})},a=()=>{const j=ac(this.options,n),E=(()=>{const S={client:b(this,en),queryKey:this.queryKey,meta:this.meta};return o(S),S})();return M(this,tn,!1),this.options.persister?this.options.persister(j,E,this):j(E)},c=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:b(this,en),state:this.state,fetchFn:a};return o(j),j})();(d=this.options.behavior)==null||d.onFetch(c,this),M(this,_n,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=c.fetchOptions)==null?void 0:h.meta))&&J(this,Ie,lt).call(this,{type:"fetch",meta:(f=c.fetchOptions)==null?void 0:f.meta}),M(this,we,cc({initialPromise:n==null?void 0:n.initialPromise,fn:c.fetchFn,onCancel:j=>{j instanceof go&&j.revert&&this.setState({...b(this,_n),fetchStatus:"idle"}),s.abort()},onFail:(j,C)=>{J(this,Ie,lt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{J(this,Ie,lt).call(this,{type:"pause"})},onContinue:()=>{J(this,Ie,lt).call(this,{type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode,canRun:()=>!0}));try{const j=await b(this,we).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(g=(m=b(this,$e).config).onSuccess)==null||g.call(m,j,this),(p=(v=b(this,$e).config).onSettled)==null||p.call(v,j,this.state.error,this),j}catch(j){if(j instanceof go){if(j.silent)return b(this,we).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw J(this,Ie,lt).call(this,{type:"error",error:j}),(y=(x=b(this,$e).config).onError)==null||y.call(x,j,this),(N=(w=b(this,$e).config).onSettled)==null||N.call(w,this.state.data,j,this),j}finally{this.scheduleGc()}}},Jt=new WeakMap,_n=new WeakMap,$e=new WeakMap,en=new WeakMap,we=new WeakMap,br=new WeakMap,tn=new WeakMap,Ie=new WeakSet,dc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},lt=function(t){const n=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...uc(s.data,this.options),fetchMeta:t.meta??null};case"success":const o={...s,...Ya(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,_n,t.manual?o:void 0),o;case"error":const a=t.error;return{...s,error:a,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=n(this.state),ye.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),b(this,$e).notify({query:this,type:"updated",action:t})})},Gi);function uc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ic(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ya(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Xa(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,s=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var ke,se,wr,Ee,nn,In,dt,At,jr,On,Dn,rn,sn,Mt,zn,de,lr,vo,yo,bo,wo,jo,No,Co,hc,Qi,fc=(Qi=class extends Qn{constructor(t,n){super();F(this,de);F(this,ke);F(this,se);F(this,wr);F(this,Ee);F(this,nn);F(this,In);F(this,dt);F(this,At);F(this,jr);F(this,On);F(this,Dn);F(this,rn);F(this,sn);F(this,Mt);F(this,zn,new Set);this.options=n,M(this,ke,t),M(this,At,null),M(this,dt,xo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(b(this,se).addObserver(this),Za(b(this,se),this.options)?J(this,de,lr).call(this):this.updateResult(),J(this,de,wo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return So(b(this,se),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return So(b(this,se),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,J(this,de,jo).call(this),J(this,de,No).call(this),b(this,se).removeObserver(this)}setOptions(t){const n=this.options,s=b(this,se);if(this.options=b(this,ke).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Oe(this.options.enabled,b(this,se))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");J(this,de,Co).call(this),b(this,se).setOptions(this.options),n._defaulted&&!es(this.options,n)&&b(this,ke).getQueryCache().notify({type:"observerOptionsUpdated",query:b(this,se),observer:this});const o=this.hasListeners();o&&Ja(b(this,se),s,this.options,n)&&J(this,de,lr).call(this),this.updateResult(),o&&(b(this,se)!==s||Oe(this.options.enabled,b(this,se))!==Oe(n.enabled,b(this,se))||zt(this.options.staleTime,b(this,se))!==zt(n.staleTime,b(this,se)))&&J(this,de,vo).call(this);const a=J(this,de,yo).call(this);o&&(b(this,se)!==s||Oe(this.options.enabled,b(this,se))!==Oe(n.enabled,b(this,se))||a!==b(this,Mt))&&J(this,de,bo).call(this,a)}getOptimisticResult(t){const n=b(this,ke).getQueryCache().build(b(this,ke),t),s=this.createResult(n,t);return ph(this,s)&&(M(this,Ee,s),M(this,In,this.options),M(this,nn,b(this,se).state)),s}getCurrentResult(){return b(this,Ee)}trackResult(t,n){return new Proxy(t,{get:(s,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&b(this,dt).status==="pending"&&b(this,dt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,o))})}trackProp(t){b(this,zn).add(t)}getCurrentQuery(){return b(this,se)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=b(this,ke).defaultQueryOptions(t),s=b(this,ke).getQueryCache().build(b(this,ke),n);return s.fetch().then(()=>this.createResult(s,n))}fetch(t){return J(this,de,lr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),b(this,Ee)))}createResult(t,n){var D;const s=b(this,se),o=this.options,a=b(this,Ee),i=b(this,nn),c=b(this,In),d=t!==s?t.state:b(this,wr),{state:h}=t;let f={...h},m=!1,g;if(n._optimisticResults){const O=this.hasListeners(),$=!O&&Za(t,n),_=O&&Ja(t,s,n,o);($||_)&&(f={...f,...uc(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:v,errorUpdatedAt:p,status:x}=f;g=f.data;let y=!1;if(n.placeholderData!==void 0&&g===void 0&&x==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(c==null?void 0:c.placeholderData)?(O=a.data,y=!0):O=typeof n.placeholderData=="function"?n.placeholderData((D=b(this,Dn))==null?void 0:D.state.data,b(this,Dn)):n.placeholderData,O!==void 0&&(x="success",g=po(a==null?void 0:a.data,O,n),m=!0)}if(n.select&&g!==void 0&&!y)if(a&&g===(i==null?void 0:i.data)&&n.select===b(this,jr))g=b(this,On);else try{M(this,jr,n.select),g=n.select(g),g=po(a==null?void 0:a.data,g,n),M(this,On,g),M(this,At,null)}catch(O){M(this,At,O)}b(this,At)&&(v=b(this,At),g=b(this,On),p=Date.now(),x="error");const w=f.fetchStatus==="fetching",N=x==="pending",j=x==="error",C=N&&w,E=g!==void 0,P={status:x,fetchStatus:f.fetchStatus,isPending:N,isSuccess:x==="success",isError:j,isInitialLoading:C,isLoading:C,data:g,dataUpdatedAt:f.dataUpdatedAt,error:v,errorUpdatedAt:p,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:w,isRefetching:w&&!N,isLoadingError:j&&!E,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&E,isStale:ta(t,n),refetch:this.refetch,promise:b(this,dt),isEnabled:Oe(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=P.data!==void 0,$=P.status==="error"&&!O,_=X=>{$?X.reject(P.error):O&&X.resolve(P.data)},G=()=>{const X=M(this,dt,P.promise=xo());_(X)},U=b(this,dt);switch(U.status){case"pending":t.queryHash===s.queryHash&&_(U);break;case"fulfilled":($||P.data!==U.value)&&G();break;case"rejected":(!$||P.error!==U.reason)&&G();break}}return P}updateResult(){const t=b(this,Ee),n=this.createResult(b(this,se),this.options);if(M(this,nn,b(this,se).state),M(this,In,this.options),b(this,nn).data!==void 0&&M(this,Dn,b(this,se)),es(n,t))return;M(this,Ee,n);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!b(this,zn).size)return!0;const i=new Set(a??b(this,zn));return this.options.throwOnError&&i.add("error"),Object.keys(b(this,Ee)).some(c=>{const u=c;return b(this,Ee)[u]!==t[u]&&i.has(u)})};J(this,de,hc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&J(this,de,wo).call(this)}},ke=new WeakMap,se=new WeakMap,wr=new WeakMap,Ee=new WeakMap,nn=new WeakMap,In=new WeakMap,dt=new WeakMap,At=new WeakMap,jr=new WeakMap,On=new WeakMap,Dn=new WeakMap,rn=new WeakMap,sn=new WeakMap,Mt=new WeakMap,zn=new WeakMap,de=new WeakSet,lr=function(t){J(this,de,Co).call(this);let n=b(this,se).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Re)),n},vo=function(){J(this,de,jo).call(this);const t=zt(this.options.staleTime,b(this,se));if(hr.isServer()||b(this,Ee).isStale||!ho(t))return;const s=sc(b(this,Ee).dataUpdatedAt,t)+1;M(this,rn,Gt.setTimeout(()=>{b(this,Ee).isStale||this.updateResult()},s))},yo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(b(this,se)):this.options.refetchInterval)??!1},bo=function(t){J(this,de,No).call(this),M(this,Mt,t),!(hr.isServer()||Oe(this.options.enabled,b(this,se))===!1||!ho(b(this,Mt))||b(this,Mt)===0)&&M(this,sn,Gt.setInterval(()=>{(this.options.refetchIntervalInBackground||Xo.isFocused())&&J(this,de,lr).call(this)},b(this,Mt)))},wo=function(){J(this,de,vo).call(this),J(this,de,bo).call(this,J(this,de,yo).call(this))},jo=function(){b(this,rn)!==void 0&&(Gt.clearTimeout(b(this,rn)),M(this,rn,void 0))},No=function(){b(this,sn)!==void 0&&(Gt.clearInterval(b(this,sn)),M(this,sn,void 0))},Co=function(){const t=b(this,ke).getQueryCache().build(b(this,ke),this.options);if(t===b(this,se))return;const n=b(this,se);M(this,se,t),M(this,wr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},hc=function(t){ye.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(b(this,Ee))}),b(this,ke).getQueryCache().notify({query:b(this,se),type:"observerResultsUpdated"})})},Qi);function mh(e,t){return Oe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Oe(t.retryOnMount,e)===!1)}function Za(e,t){return mh(e,t)||e.state.data!==void 0&&So(e,t,t.refetchOnMount)}function So(e,t,n){if(Oe(t.enabled,e)!==!1&&zt(t.staleTime,e)!=="static"){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&ta(e,t)}return!1}function Ja(e,t,n,s){return(e!==t||Oe(s.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ta(e,n)}function ta(e,t){return Oe(t.enabled,e)!==!1&&e.isStaleByTime(zt(t.staleTime,e))}function ph(e,t){return!es(e.getCurrentResult(),t)}function ns(e){return{onFetch:(t,n)=>{var h,f,m,g,v;const s=t.options,o=(m=(f=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,a=((g=t.state.data)==null?void 0:g.pages)||[],i=((v=t.state.data)==null?void 0:v.pageParams)||[];let c={pages:[],pageParams:[]},u=0;const d=async()=>{let p=!1;const x=N=>{ch(N,()=>t.signal,()=>p=!0)},y=ac(t.options,t.fetchOptions),w=async(N,j,C)=>{if(p)return Promise.reject();if(j==null&&N.pages.length)return Promise.resolve(N);const S=(()=>{const $={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return x($),$})(),P=await y(S),{maxPages:D}=t.options,O=C?ih:ah;return{pages:O(N.pages,P,D),pageParams:O(N.pageParams,j,D)}};if(o&&a.length){const N=o==="backward",j=N?mc:Eo,C={pages:a,pageParams:i},E=j(s,C);c=await w(C,E,N)}else{const N=e??a.length;do{const j=u===0?i[0]??s.initialPageParam:Eo(s,c);if(u>0&&j==null)break;c=await w(c,j),u++}while(u<N)}return c};t.options.persister?t.fetchFn=()=>{var p,x;return(x=(p=t.options).persister)==null?void 0:x.call(p,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function Eo(e,{pages:t,pageParams:n}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,n[s],n):void 0}function mc(e,{pages:t,pageParams:n}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,n[0],n):void 0}function xh(e,t){return t?Eo(e,t)!=null:!1}function gh(e,t){return!t||!e.getPreviousPageParam?!1:mc(e,t)!=null}var vh=class extends fc{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ns()})}getOptimisticResult(e){return e.behavior=ns(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var v,p;const{state:n}=e,s=super.createResult(e,t),{isFetching:o,isRefetching:a,isError:i,isRefetchError:c}=s,u=(p=(v=n.fetchMeta)==null?void 0:v.fetchMore)==null?void 0:p.direction,d=i&&u==="forward",h=o&&u==="forward",f=i&&u==="backward",m=o&&u==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xh(t,n.data),hasPreviousPage:gh(t,n.data),isFetchNextPageError:d,isFetchingNextPage:h,isFetchPreviousPageError:f,isFetchingPreviousPage:m,isRefetchError:c&&!d&&!f,isRefetching:a&&!h&&!m}}},Nr,Xe,Ne,on,Ze,St,Yi,yh=(Yi=class extends lc{constructor(t){super();F(this,Ze);F(this,Nr);F(this,Xe);F(this,Ne);F(this,on);M(this,Nr,t.client),this.mutationId=t.mutationId,M(this,Ne,t.mutationCache),M(this,Xe,[]),this.state=t.state||pc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){b(this,Xe).includes(t)||(b(this,Xe).push(t),this.clearGcTimeout(),b(this,Ne).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,Xe,b(this,Xe).filter(n=>n!==t)),this.scheduleGc(),b(this,Ne).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){b(this,Xe).length||(this.state.status==="pending"?this.scheduleGc():b(this,Ne).remove(this))}continue(){var t;return((t=b(this,on))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,c,u,d,h,f,m,g,v,p,x,y,w,N,j,C,E,S;const n=()=>{J(this,Ze,St).call(this,{type:"continue"})},s={client:b(this,Nr),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,on,cc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(P,D)=>{J(this,Ze,St).call(this,{type:"failed",failureCount:P,error:D})},onPause:()=>{J(this,Ze,St).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>b(this,Ne).canRun(this)}));const o=this.state.status==="pending",a=!b(this,on).canStart();try{if(o)n();else{J(this,Ze,St).call(this,{type:"pending",variables:t,isPaused:a}),b(this,Ne).config.onMutate&&await b(this,Ne).config.onMutate(t,this,s);const D=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,t,s));D!==this.state.context&&J(this,Ze,St).call(this,{type:"pending",context:D,variables:t,isPaused:a})}const P=await b(this,on).start();return await((d=(u=b(this,Ne).config).onSuccess)==null?void 0:d.call(u,P,t,this.state.context,this,s)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,P,t,this.state.context,s)),await((g=(m=b(this,Ne).config).onSettled)==null?void 0:g.call(m,P,null,this.state.variables,this.state.context,this,s)),await((p=(v=this.options).onSettled)==null?void 0:p.call(v,P,null,t,this.state.context,s)),J(this,Ze,St).call(this,{type:"success",data:P}),P}catch(P){try{await((y=(x=b(this,Ne).config).onError)==null?void 0:y.call(x,P,t,this.state.context,this,s))}catch(D){Promise.reject(D)}try{await((N=(w=this.options).onError)==null?void 0:N.call(w,P,t,this.state.context,s))}catch(D){Promise.reject(D)}try{await((C=(j=b(this,Ne).config).onSettled)==null?void 0:C.call(j,void 0,P,this.state.variables,this.state.context,this,s))}catch(D){Promise.reject(D)}try{await((S=(E=this.options).onSettled)==null?void 0:S.call(E,void 0,P,t,this.state.context,s))}catch(D){Promise.reject(D)}throw J(this,Ze,St).call(this,{type:"error",error:P}),P}finally{b(this,Ne).runNext(this)}}},Nr=new WeakMap,Xe=new WeakMap,Ne=new WeakMap,on=new WeakMap,Ze=new WeakSet,St=function(t){const n=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ye.batch(()=>{b(this,Xe).forEach(s=>{s.onMutationUpdate(t)}),b(this,Ne).notify({mutation:this,type:"updated",action:t})})},Yi);function pc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ut,He,Cr,Xi,bh=(Xi=class extends Qn{constructor(t={}){super();F(this,ut);F(this,He);F(this,Cr);this.config=t,M(this,ut,new Set),M(this,He,new Map),M(this,Cr,0)}build(t,n,s){const o=new yh({client:t,mutationCache:this,mutationId:++zr(this,Cr)._,options:t.defaultMutationOptions(n),state:s});return this.add(o),o}add(t){b(this,ut).add(t);const n=Lr(t);if(typeof n=="string"){const s=b(this,He).get(n);s?s.push(t):b(this,He).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(b(this,ut).delete(t)){const n=Lr(t);if(typeof n=="string"){const s=b(this,He).get(n);if(s)if(s.length>1){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}else s[0]===t&&b(this,He).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Lr(t);if(typeof n=="string"){const s=b(this,He).get(n),o=s==null?void 0:s.find(a=>a.state.status==="pending");return!o||o===t}else return!0}runNext(t){var s;const n=Lr(t);if(typeof n=="string"){const o=(s=b(this,He).get(n))==null?void 0:s.find(a=>a!==t&&a.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ye.batch(()=>{b(this,ut).forEach(t=>{this.notify({type:"removed",mutation:t})}),b(this,ut).clear(),b(this,He).clear()})}getAll(){return Array.from(b(this,ut))}find(t){const n={exact:!0,...t};return this.getAll().find(s=>Wa(n,s))}findAll(t={}){return this.getAll().filter(n=>Wa(t,n))}notify(t){ye.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ye.batch(()=>Promise.all(t.map(n=>n.continue().catch(Re))))}},ut=new WeakMap,He=new WeakMap,Cr=new WeakMap,Xi);function Lr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var ft,_t,Te,ht,pt,Wr,Ro,Zi,wh=(Zi=class extends Qn{constructor(n,s){super();F(this,pt);F(this,ft);F(this,_t);F(this,Te);F(this,ht);M(this,ft,n),this.setOptions(s),this.bindMethods(),J(this,pt,Wr).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const s=this.options;this.options=b(this,ft).defaultMutationOptions(n),es(this.options,s)||b(this,ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:b(this,Te),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&ln(s.mutationKey)!==ln(this.options.mutationKey)?this.reset():((o=b(this,Te))==null?void 0:o.state.status)==="pending"&&b(this,Te).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=b(this,Te))==null||n.removeObserver(this)}onMutationUpdate(n){J(this,pt,Wr).call(this),J(this,pt,Ro).call(this,n)}getCurrentResult(){return b(this,_t)}reset(){var n;(n=b(this,Te))==null||n.removeObserver(this),M(this,Te,void 0),J(this,pt,Wr).call(this),J(this,pt,Ro).call(this)}mutate(n,s){var o;return M(this,ht,s),(o=b(this,Te))==null||o.removeObserver(this),M(this,Te,b(this,ft).getMutationCache().build(b(this,ft),this.options)),b(this,Te).addObserver(this),b(this,Te).execute(n)}},ft=new WeakMap,_t=new WeakMap,Te=new WeakMap,ht=new WeakMap,pt=new WeakSet,Wr=function(){var s;const n=((s=b(this,Te))==null?void 0:s.state)??pc();M(this,_t,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ro=function(n){ye.batch(()=>{var s,o,a,i,c,u,d,h;if(b(this,ht)&&this.hasListeners()){const f=b(this,_t).variables,m=b(this,_t).context,g={client:b(this,ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(o=(s=b(this,ht)).onSuccess)==null||o.call(s,n.data,f,m,g)}catch(v){Promise.reject(v)}try{(i=(a=b(this,ht)).onSettled)==null||i.call(a,n.data,null,f,m,g)}catch(v){Promise.reject(v)}}else if((n==null?void 0:n.type)==="error"){try{(u=(c=b(this,ht)).onError)==null||u.call(c,n.error,f,m,g)}catch(v){Promise.reject(v)}try{(h=(d=b(this,ht)).onSettled)==null||h.call(d,void 0,n.error,f,m,g)}catch(v){Promise.reject(v)}}}this.listeners.forEach(f=>{f(b(this,_t))})})},Zi),Je,Ji,jh=(Ji=class extends Qn{constructor(t={}){super();F(this,Je);this.config=t,M(this,Je,new Map)}build(t,n,s){const o=n.queryKey,a=n.queryHash??Zo(o,n);let i=this.get(a);return i||(i=new hh({client:t,queryKey:o,queryHash:a,options:t.defaultQueryOptions(n),state:s,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){b(this,Je).has(t.queryHash)||(b(this,Je).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=b(this,Je).get(t.queryHash);n&&(t.destroy(),n===t&&b(this,Je).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ye.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return b(this,Je).get(t)}getAll(){return[...b(this,Je).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(s=>qa(n,s))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(s=>qa(t,s)):n}notify(t){ye.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ye.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ye.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Je=new WeakMap,Ji),ge,It,Ot,Ln,Fn,Dt,$n,Un,ec,Nh=(ec=class{constructor(e={}){F(this,ge);F(this,It);F(this,Ot);F(this,Ln);F(this,Fn);F(this,Dt);F(this,$n);F(this,Un);M(this,ge,e.queryCache||new jh),M(this,It,e.mutationCache||new bh),M(this,Ot,e.defaultOptions||{}),M(this,Ln,new Map),M(this,Fn,new Map),M(this,Dt,0)}mount(){zr(this,Dt)._++,b(this,Dt)===1&&(M(this,$n,Xo.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ge).onFocus())})),M(this,Un,ts.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ge).onOnline())})))}unmount(){var e,t;zr(this,Dt)._--,b(this,Dt)===0&&((e=b(this,$n))==null||e.call(this),M(this,$n,void 0),(t=b(this,Un))==null||t.call(this),M(this,Un,void 0))}isFetching(e){return b(this,ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return b(this,It).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ge).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=b(this,ge).build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(zt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return b(this,ge).findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),o=b(this,ge).get(s.queryHash),a=o==null?void 0:o.state.data,i=rh(t,a);if(i!==void 0)return b(this,ge).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return ye.batch(()=>b(this,ge).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ge).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=b(this,ge);ye.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=b(this,ge);return ye.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=ye.batch(()=>b(this,ge).findAll(e).map(o=>o.cancel(n)));return Promise.all(s).then(Re).catch(Re)}invalidateQueries(e,t={}){return ye.batch(()=>(b(this,ge).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},s=ye.batch(()=>b(this,ge).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let a=o.fetch(void 0,n);return n.throwOnError||(a=a.catch(Re)),o.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(s).then(Re)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=b(this,ge).build(this,t);return n.isStaleByTime(zt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Re).catch(Re)}fetchInfiniteQuery(e){return e.behavior=ns(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Re).catch(Re)}ensureInfiniteQueryData(e){return e.behavior=ns(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ts.isOnline()?b(this,It).resumePausedMutations():Promise.resolve()}getQueryCache(){return b(this,ge)}getMutationCache(){return b(this,It)}getDefaultOptions(){return b(this,Ot)}setDefaultOptions(e){M(this,Ot,e)}setQueryDefaults(e,t){b(this,Ln).set(ln(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...b(this,Ln).values()],n={};return t.forEach(s=>{fr(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){b(this,Fn).set(ln(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...b(this,Fn).values()],n={};return t.forEach(s=>{fr(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...b(this,Ot).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Zo(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===Jo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...b(this,Ot).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){b(this,ge).clear(),b(this,It).clear()}},ge=new WeakMap,It=new WeakMap,Ot=new WeakMap,Ln=new WeakMap,Fn=new WeakMap,Dt=new WeakMap,$n=new WeakMap,Un=new WeakMap,ec),xc=l.createContext(void 0),be=e=>{const t=l.useContext(xc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Ch=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(xc.Provider,{value:e,children:t})),gc=l.createContext(!1),Sh=()=>l.useContext(gc);gc.Provider;function Eh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Rh=l.createContext(Eh()),Ph=()=>l.useContext(Rh),kh=(e,t,n)=>{const s=n!=null&&n.state.error&&typeof e.throwOnError=="function"?ea(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},Th=e=>{l.useEffect(()=>{e.clearReset()},[e])},Ah=({result:e,errorResetBoundary:t,throwOnError:n,query:s,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(o&&e.data===void 0||ea(n,[e.error,s])),Mh=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...o)=>n(s(...o)):n(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},_h=(e,t)=>e.isLoading&&e.isFetching&&!t,Ih=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,ei=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function vc(e,t,n){var m,g,v,p;const s=Sh(),o=Ph(),a=be(),i=a.defaultQueryOptions(e);(g=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||g.call(m,i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=s?"isRestoring":"optimistic",Mh(i),kh(i,o,c),Th(o);const u=!a.getQueryCache().get(i.queryHash),[d]=l.useState(()=>new t(a,i)),h=d.getOptimisticResult(i),f=!s&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(x=>{const y=f?d.subscribe(ye.batchCalls(x)):Re;return d.updateResult(),y},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),Ih(i,h))throw ei(i,d,o);if(Ah({result:h,errorResetBoundary:o,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw h.error;if((p=(v=a.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||p.call(v,i,h),i.experimental_prefetchInRender&&!hr.isServer()&&_h(h,s)){const x=u?ei(i,d,o):c==null?void 0:c.promise;x==null||x.catch(Re).finally(()=>{d.updateResult()})}return i.notifyOnChangeProps?h:d.trackResult(h)}function Ae(e,t){return vc(e,fc)}function Se(e,t){const n=be(),[s]=l.useState(()=>new wh(n,e));l.useEffect(()=>{s.setOptions(e)},[s,e]);const o=l.useSyncExternalStore(l.useCallback(i=>s.subscribe(ye.batchCalls(i)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),a=l.useCallback((i,c)=>{s.mutate(i,c).catch(Re)},[s]);if(o.error&&ea(s.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}function Oh(e,t){return vc(e,vh)}const rs=new Nh({defaultOptions:{queries:{staleTime:3e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!1}}});var Dh={pending:["confirmed","cancelled"],confirmed:["processing","cancelled","refunded","partially_refunded"],processing:["shipped","cancelled","refunded","partially_refunded"],shipped:["delivered","refunded","partially_refunded"],delivered:["refunded","partially_refunded"],cancelled:[],refunded:[],partially_refunded:["refunded"]};function zh(e){return e.capturedMinor<=0?"unpaid":e.refundedMinor<=0?"paid":e.refundedMinor<e.capturedMinor?"partially_refunded":"refunded"}var Lh="product.created.v1",Fh="product.updated.v1",$h="product.deleted.v1",Uh="product.published.v1",Vh="product.unpublished.v1",Bh="category.created.v1",Kh="category.updated.v1",Hh="category.deleted.v1",qh="order.placed.v1",Wh="order.paid.v1",Gh="order.fulfilled.v1",Qh="order.shipped.v1",Yh="order.delivered.v1",Xh="order.cancelled.v1",Zh="order.refunded.v1",Jh="order.partially_refunded.v1",em="order.status_changed.v1",tm="inventory.changed.v1",nm="inventory.reserved.v1",rm="inventory.released.v1",sm="inventory.low_stock.v1",om="inventory.out_of_stock.v1",am="customer.created.v1",im="customer.updated.v1",cm="customer.deleted.v1",lm="cart.created.v1",dm="cart.item_added.v1",um="cart.item_removed.v1",fm="cart.updated.v1",hm="cart.abandoned.v1",mm="cart.converted.v1",pm="payment.intent_created.v1",xm="payment.captured.v1",gm="payment.failed.v1",vm="payment.refunded.v1",ym="adapter.error.v1",bm="settings.changed.v1",wm=[Lh,Fh,$h,Uh,Vh,Bh,Kh,Hh,qh,Wh,Gh,Qh,Yh,Xh,Zh,Jh,em,tm,nm,rm,sm,om,am,im,cm,lm,dm,um,fm,hm,mm,pm,xm,gm,vm,ym,bm],jm="idempotency-key";class Vn extends Error{constructor(t,n,s,o){super(n),this.code=t,this.status=s,this.context=o,this.name="ApiError"}}const Nm="x-csrf-token",Cm=new Set(["POST","PUT","PATCH","DELETE"]);let Gr=null;function Sm(){return Gr??(Gr=fetch("/api/csrf").then(async e=>{var n;const t=await e.json();if(!e.ok||!((n=t.data)!=null&&n.token))throw new Vn("csrf.unavailable",`GET /api/csrf answered ${e.status}`,e.status);return t.data.token}).catch(e=>{throw Gr=null,e})),Gr}async function Em(e){var n;return e.status!==403?!1:((n=(await e.clone().json().catch(()=>({}))).error)==null?void 0:n.code)==="csrf.invalid"}async function na(e,t={}){const n=(t.method??"GET").toUpperCase();if(!Cm.has(n))return fetch(e,t);const s=async()=>{const a=new Headers(t.headers);return a.set(Nm,await Sm()),fetch(e,{...t,headers:a})},o=await s();return await Em(o)?(Gr=null,s()):o}function Rm(e,t){if(!t)return e;const n=new URLSearchParams;for(const[o,a]of Object.entries(t))a!=null&&a!==""&&n.set(o,String(a));const s=n.toString();return s?`${e}?${s}`:e}async function Pm(e){const t=bc();return t!==e?t!==null:Mm()}function Po(){return crypto.randomUUID()}async function Et(e,t,n,s={}){const{query:o,retried:a=!1}=s,i=bc(),c={};i&&(c.Authorization=`Bearer ${i}`),s.idempotencyKey!==void 0&&(c[jm]=s.idempotencyKey);const u=Rm(t,o),d={method:e,headers:c};n!==void 0&&(c["Content-Type"]="application/json",d.body=JSON.stringify(n));const h=await na(u,d);if(h.status===401){if(!a&&i!==null&&!t.startsWith("/api/auth/")&&await Pm(i))return Et(e,t,n,{...s,retried:!0});const g=(await h.json().catch(()=>({}))).error;throw new Vn((g==null?void 0:g.code)??"UNAUTHORIZED",(g==null?void 0:g.message)??"Unauthorized",401)}if(s.text&&h.ok)return await h.text();const f=await h.json();if(!h.ok){const m=f.error;throw new Vn((m==null?void 0:m.code)??"UNKNOWN_ERROR",(m==null?void 0:m.message)??`HTTP ${h.status}`,h.status,m==null?void 0:m.context)}return s.envelope?f:"data"in f?f.data:f}function Fr(e,t){const n=(e==null?void 0:e.idempotencyKey)??(t.startsWith("/api/admin/")?Po():void 0);return n===void 0?{}:{idempotencyKey:n}}const ae={get(e,t){return Et("GET",e,void 0,t===void 0?{}:{query:t})},getPage(e,t){return Et("GET",e,void 0,{envelope:!0,...t&&{query:t}})},getText(e,t){return Et("GET",e,void 0,{text:!0,...t&&{query:t}})},post(e,t,n){return Et("POST",e,t,Fr(n,e))},patch(e,t,n){return Et("PATCH",e,t,Fr(n,e))},put(e,t,n){return Et("PUT",e,t,Fr(n,e))},delete(e,t){return Et("DELETE",e,void 0,Fr(t,e))}};let gs=null,qs=null;const ko=new Set;function yc(e){gs=e}function bc(){return gs}function wc(){gs=null}function ss(){return gs!==null}function km(e){return ko.add(e),()=>{ko.delete(e)}}async function Tm(e){var t,n;try{const s=await fetch("/api/admin/me",{headers:{Authorization:`Bearer ${e}`}});return s.ok?((n=(t=(await s.json()).data)==null?void 0:t.roles)==null?void 0:n.includes("admin"))??!1:!1}catch{return!1}}async function Am(){var t;let e;try{const n=await na("/api/auth/refresh",{method:"POST"});if(!n.ok)return!1;e=(t=(await n.json()).data)==null?void 0:t.accessToken}catch{return!1}return!e||!await Tm(e)?!1:(yc(e),!0)}function jc(e){return qs??(qs=Am().then(t=>{if(qs=null,!t&&(wc(),e))for(const n of[...ko])n();return t})),qs}function Mm(){return jc(!0)}function _m(){return jc(!1)}/**
10
+ * @license lucide-react v0.462.0 - ISC
11
+ *
12
+ * This source code is licensed under the ISC license.
13
+ * See the LICENSE file in the root directory of this source tree.
14
+ */const Im=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Nc=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();/**
15
+ * @license lucide-react v0.462.0 - ISC
16
+ *
17
+ * This source code is licensed under the ISC license.
18
+ * See the LICENSE file in the root directory of this source tree.
19
+ */var Om={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"};/**
20
+ * @license lucide-react v0.462.0 - ISC
21
+ *
22
+ * This source code is licensed under the ISC license.
23
+ * See the LICENSE file in the root directory of this source tree.
24
+ */const Dm=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:o="",children:a,iconNode:i,...c},u)=>l.createElement("svg",{ref:u,...Om,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Nc("lucide",o),...c},[...i.map(([d,h])=>l.createElement(d,h)),...Array.isArray(a)?a:[a]]));/**
25
+ * @license lucide-react v0.462.0 - ISC
26
+ *
27
+ * This source code is licensed under the ISC license.
28
+ * See the LICENSE file in the root directory of this source tree.
29
+ */const K=(e,t)=>{const n=l.forwardRef(({className:s,...o},a)=>l.createElement(Dm,{ref:a,iconNode:t,className:Nc(`lucide-${Im(e)}`,s),...o}));return n.displayName=`${e}`,n};/**
30
+ * @license lucide-react v0.462.0 - ISC
31
+ *
32
+ * This source code is licensed under the ISC license.
33
+ * See the LICENSE file in the root directory of this source tree.
34
+ */const zm=K("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
35
+ * @license lucide-react v0.462.0 - ISC
36
+ *
37
+ * This source code is licensed under the ISC license.
38
+ * See the LICENSE file in the root directory of this source tree.
39
+ */const ra=K("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
40
+ * @license lucide-react v0.462.0 - ISC
41
+ *
42
+ * This source code is licensed under the ISC license.
43
+ * See the LICENSE file in the root directory of this source tree.
44
+ */const Lm=K("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
45
+ * @license lucide-react v0.462.0 - ISC
46
+ *
47
+ * This source code is licensed under the ISC license.
48
+ * See the LICENSE file in the root directory of this source tree.
49
+ */const Cc=K("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/**
50
+ * @license lucide-react v0.462.0 - ISC
51
+ *
52
+ * This source code is licensed under the ISC license.
53
+ * See the LICENSE file in the root directory of this source tree.
54
+ */const Fm=K("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"}]]);/**
55
+ * @license lucide-react v0.462.0 - ISC
56
+ *
57
+ * This source code is licensed under the ISC license.
58
+ * See the LICENSE file in the root directory of this source tree.
59
+ */const $m=K("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/**
60
+ * @license lucide-react v0.462.0 - ISC
61
+ *
62
+ * This source code is licensed under the ISC license.
63
+ * See the LICENSE file in the root directory of this source tree.
64
+ */const Yn=K("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
65
+ * @license lucide-react v0.462.0 - ISC
66
+ *
67
+ * This source code is licensed under the ISC license.
68
+ * See the LICENSE file in the root directory of this source tree.
69
+ */const Sc=K("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
70
+ * @license lucide-react v0.462.0 - ISC
71
+ *
72
+ * This source code is licensed under the ISC license.
73
+ * See the LICENSE file in the root directory of this source tree.
74
+ */const Ec=K("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
75
+ * @license lucide-react v0.462.0 - ISC
76
+ *
77
+ * This source code is licensed under the ISC license.
78
+ * See the LICENSE file in the root directory of this source tree.
79
+ */const Um=K("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
80
+ * @license lucide-react v0.462.0 - ISC
81
+ *
82
+ * This source code is licensed under the ISC license.
83
+ * See the LICENSE file in the root directory of this source tree.
84
+ */const Vm=K("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"}]]);/**
85
+ * @license lucide-react v0.462.0 - ISC
86
+ *
87
+ * This source code is licensed under the ISC license.
88
+ * See the LICENSE file in the root directory of this source tree.
89
+ */const ti=K("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
90
+ * @license lucide-react v0.462.0 - ISC
91
+ *
92
+ * This source code is licensed under the ISC license.
93
+ * See the LICENSE file in the root directory of this source tree.
94
+ */const Bm=K("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"}]]);/**
95
+ * @license lucide-react v0.462.0 - ISC
96
+ *
97
+ * This source code is licensed under the ISC license.
98
+ * See the LICENSE file in the root directory of this source tree.
99
+ */const Km=K("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
100
+ * @license lucide-react v0.462.0 - ISC
101
+ *
102
+ * This source code is licensed under the ISC license.
103
+ * See the LICENSE file in the root directory of this source tree.
104
+ */const ni=K("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
105
+ * @license lucide-react v0.462.0 - ISC
106
+ *
107
+ * This source code is licensed under the ISC license.
108
+ * See the LICENSE file in the root directory of this source tree.
109
+ */const Hm=K("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"}]]);/**
110
+ * @license lucide-react v0.462.0 - ISC
111
+ *
112
+ * This source code is licensed under the ISC license.
113
+ * See the LICENSE file in the root directory of this source tree.
114
+ */const qm=K("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"}]]);/**
115
+ * @license lucide-react v0.462.0 - ISC
116
+ *
117
+ * This source code is licensed under the ISC license.
118
+ * See the LICENSE file in the root directory of this source tree.
119
+ */const Wm=K("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"}]]);/**
120
+ * @license lucide-react v0.462.0 - ISC
121
+ *
122
+ * This source code is licensed under the ISC license.
123
+ * See the LICENSE file in the root directory of this source tree.
124
+ */const Gm=K("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"}]]);/**
125
+ * @license lucide-react v0.462.0 - ISC
126
+ *
127
+ * This source code is licensed under the ISC license.
128
+ * See the LICENSE file in the root directory of this source tree.
129
+ */const Rc=K("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
130
+ * @license lucide-react v0.462.0 - ISC
131
+ *
132
+ * This source code is licensed under the ISC license.
133
+ * See the LICENSE file in the root directory of this source tree.
134
+ */const Qm=K("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
135
+ * @license lucide-react v0.462.0 - ISC
136
+ *
137
+ * This source code is licensed under the ISC license.
138
+ * See the LICENSE file in the root directory of this source tree.
139
+ */const os=K("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
140
+ * @license lucide-react v0.462.0 - ISC
141
+ *
142
+ * This source code is licensed under the ISC license.
143
+ * See the LICENSE file in the root directory of this source tree.
144
+ */const Ym=K("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
145
+ * @license lucide-react v0.462.0 - ISC
146
+ *
147
+ * This source code is licensed under the ISC license.
148
+ * See the LICENSE file in the root directory of this source tree.
149
+ */const Xm=K("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
150
+ * @license lucide-react v0.462.0 - ISC
151
+ *
152
+ * This source code is licensed under the ISC license.
153
+ * See the LICENSE file in the root directory of this source tree.
154
+ */const Zm=K("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
155
+ * @license lucide-react v0.462.0 - ISC
156
+ *
157
+ * This source code is licensed under the ISC license.
158
+ * See the LICENSE file in the root directory of this source tree.
159
+ */const Jm=K("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
160
+ * @license lucide-react v0.462.0 - ISC
161
+ *
162
+ * This source code is licensed under the ISC license.
163
+ * See the LICENSE file in the root directory of this source tree.
164
+ */const sa=K("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
165
+ * @license lucide-react v0.462.0 - ISC
166
+ *
167
+ * This source code is licensed under the ISC license.
168
+ * See the LICENSE file in the root directory of this source tree.
169
+ */const ep=K("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"}]]);/**
170
+ * @license lucide-react v0.462.0 - ISC
171
+ *
172
+ * This source code is licensed under the ISC license.
173
+ * See the LICENSE file in the root directory of this source tree.
174
+ */const Pc=K("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"}]]);/**
175
+ * @license lucide-react v0.462.0 - ISC
176
+ *
177
+ * This source code is licensed under the ISC license.
178
+ * See the LICENSE file in the root directory of this source tree.
179
+ */const tp=K("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"}]]);/**
180
+ * @license lucide-react v0.462.0 - ISC
181
+ *
182
+ * This source code is licensed under the ISC license.
183
+ * See the LICENSE file in the root directory of this source tree.
184
+ */const np=K("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"}]]);/**
185
+ * @license lucide-react v0.462.0 - ISC
186
+ *
187
+ * This source code is licensed under the ISC license.
188
+ * See the LICENSE file in the root directory of this source tree.
189
+ */const rp=K("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
190
+ * @license lucide-react v0.462.0 - ISC
191
+ *
192
+ * This source code is licensed under the ISC license.
193
+ * See the LICENSE file in the root directory of this source tree.
194
+ */const dn=K("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"}]]);/**
195
+ * @license lucide-react v0.462.0 - ISC
196
+ *
197
+ * This source code is licensed under the ISC license.
198
+ * See the LICENSE file in the root directory of this source tree.
199
+ */const sp=K("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"}]]);/**
200
+ * @license lucide-react v0.462.0 - ISC
201
+ *
202
+ * This source code is licensed under the ISC license.
203
+ * See the LICENSE file in the root directory of this source tree.
204
+ */const mr=K("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
205
+ * @license lucide-react v0.462.0 - ISC
206
+ *
207
+ * This source code is licensed under the ISC license.
208
+ * See the LICENSE file in the root directory of this source tree.
209
+ */const op=K("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"}]]);/**
210
+ * @license lucide-react v0.462.0 - ISC
211
+ *
212
+ * This source code is licensed under the ISC license.
213
+ * See the LICENSE file in the root directory of this source tree.
214
+ */const Xn=K("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
215
+ * @license lucide-react v0.462.0 - ISC
216
+ *
217
+ * This source code is licensed under the ISC license.
218
+ * See the LICENSE file in the root directory of this source tree.
219
+ */const kc=K("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"}]]);/**
220
+ * @license lucide-react v0.462.0 - ISC
221
+ *
222
+ * This source code is licensed under the ISC license.
223
+ * See the LICENSE file in the root directory of this source tree.
224
+ */const ap=K("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"}]]);/**
225
+ * @license lucide-react v0.462.0 - ISC
226
+ *
227
+ * This source code is licensed under the ISC license.
228
+ * See the LICENSE file in the root directory of this source tree.
229
+ */const Bn=K("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"}]]);/**
230
+ * @license lucide-react v0.462.0 - ISC
231
+ *
232
+ * This source code is licensed under the ISC license.
233
+ * See the LICENSE file in the root directory of this source tree.
234
+ */const ip=K("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"}]]);/**
235
+ * @license lucide-react v0.462.0 - ISC
236
+ *
237
+ * This source code is licensed under the ISC license.
238
+ * See the LICENSE file in the root directory of this source tree.
239
+ */const cp=K("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
240
+ * @license lucide-react v0.462.0 - ISC
241
+ *
242
+ * This source code is licensed under the ISC license.
243
+ * See the LICENSE file in the root directory of this source tree.
244
+ */const Tc=K("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"}]]);/**
245
+ * @license lucide-react v0.462.0 - ISC
246
+ *
247
+ * This source code is licensed under the ISC license.
248
+ * See the LICENSE file in the root directory of this source tree.
249
+ */const To=K("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"}]]);/**
250
+ * @license lucide-react v0.462.0 - ISC
251
+ *
252
+ * This source code is licensed under the ISC license.
253
+ * See the LICENSE file in the root directory of this source tree.
254
+ */const as=K("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"}]]);/**
255
+ * @license lucide-react v0.462.0 - ISC
256
+ *
257
+ * This source code is licensed under the ISC license.
258
+ * See the LICENSE file in the root directory of this source tree.
259
+ */const Ac=K("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"}]]);/**
260
+ * @license lucide-react v0.462.0 - ISC
261
+ *
262
+ * This source code is licensed under the ISC license.
263
+ * See the LICENSE file in the root directory of this source tree.
264
+ */const oa=K("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"}]]);/**
265
+ * @license lucide-react v0.462.0 - ISC
266
+ *
267
+ * This source code is licensed under the ISC license.
268
+ * See the LICENSE file in the root directory of this source tree.
269
+ */const vs=K("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Mc(){return Ae({queryKey:["me"],queryFn:()=>ae.get("/api/admin/me"),staleTime:5*6e4})}function _c(){const e=yt(),t=l.useCallback(async(s,o)=>{var d;const a=await na("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s,password:o})}),i=await a.json();if(!a.ok||!i.data)throw new Error(((d=i.error)==null?void 0:d.message)??"Login failed");const{accessToken:c,customer:u}=i.data;if(!u.roles.includes("admin"))throw new Error("Not authorized: admin role required");yc(c),await rs.invalidateQueries({queryKey:["me"]}),e("/")},[e]),n=l.useCallback(async()=>{await ae.post("/api/auth/logout").catch(()=>{}),wc(),rs.clear(),e("/login")},[e]);return{isAuthenticated:ss(),login:t,logout:n}}function Ic(e={}){return Ae({queryKey:["orders","list",e],queryFn:()=>ae.get("/api/admin/orders",e)})}function lp(e){return Ae({queryKey:["orders","detail",e],queryFn:()=>ae.get(`/api/admin/orders/${e}`),enabled:!!e})}function dp(e){return Ae({queryKey:["orders","notes",e],queryFn:()=>ae.get(`/api/admin/orders/${e}/notes`),enabled:!!e})}function up(){const e=be();return Se({mutationFn:async({orderId:t,action:n,body:s})=>ae.post(`/api/admin/orders/${t}/${n}`,s),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","detail",t.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})}})}function fp(){const e=be();return Se({mutationFn:({orderId:t,reason:n})=>ae.post(`/api/admin/orders/${t}/cancel`,{reason:n}),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","list"]})}})}function Oc(){const e=be();return Se({mutationFn:({orderId:t,note:n})=>ae.post(`/api/admin/orders/${t}/mark-paid`,n?{note:n}:{}),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","detail",t.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})}})}function hp(){const e=be();return Se({mutationFn:t=>ae.post(`/api/admin/orders/${t}/mark-delivered`),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","list"]})}})}function mp(){const e=be();return Se({mutationFn:({orderId:t,trackingNumber:n,carrier:s})=>ae.post(`/api/admin/orders/${t}/ship`,{trackingNumber:n,carrier:s}),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","list"]})}})}function pp(){const e=be();return Se({mutationFn:({orderId:t,amountMinor:n,reason:s,requestId:o})=>ae.post(`/api/admin/orders/${t}/refund`,s?{amountMinor:n,reason:s,requestId:o}:{amountMinor:n,requestId:o}),onSuccess:async t=>{await Promise.all([e.invalidateQueries({queryKey:["orders","detail",t.order.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})])}})}function xp(){const e=be();return Se({mutationFn:({orderId:t,body:n})=>ae.post(`/api/admin/orders/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["orders","notes",n.orderId]})}})}function q(...e){return["admin",...e].join("-")}function Dc(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Dc(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function zc(){for(var e,t,n=0,s="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Dc(e))&&(s&&(s+=" "),s+=t);return s}const aa="-",gp=e=>{const t=yp(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:i=>{const c=i.split(aa);return c[0]===""&&c.length!==1&&c.shift(),Lc(c,t)||vp(i)},getConflictingClassGroupIds:(i,c)=>{const u=n[i]||[];return c&&s[i]?[...u,...s[i]]:u}}},Lc=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],s=t.nextPart.get(n),o=s?Lc(e.slice(1),s):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(aa);return(i=t.validators.find(({validator:c})=>c(a)))==null?void 0:i.classGroupId},ri=/^\[(.+)\]$/,vp=e=>{if(ri.test(e)){const t=ri.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},yp=e=>{const{theme:t,prefix:n}=e,s={nextPart:new Map,validators:[]};return wp(Object.entries(e.classGroups),n).forEach(([a,i])=>{Ao(i,s,a,t)}),s},Ao=(e,t,n,s)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:si(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(bp(o)){Ao(o(s),t,n,s);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Ao(i,si(t,a),n,s)})})},si=(e,t)=>{let n=e;return t.split(aa).forEach(s=>{n.nextPart.has(s)||n.nextPart.set(s,{nextPart:new Map,validators:[]}),n=n.nextPart.get(s)}),n},bp=e=>e.isThemeGetter,wp=(e,t)=>t?e.map(([n,s])=>{const o=s.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,c])=>[t+i,c])):a);return[n,o]}):e,jp=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const o=(a,i)=>{n.set(a,i),t++,t>e&&(t=0,s=n,n=new Map)};return{get(a){let i=n.get(a);if(i!==void 0)return i;if((i=s.get(a))!==void 0)return o(a,i),i},set(a,i){n.has(a)?n.set(a,i):o(a,i)}}},Fc="!",Np=e=>{const{separator:t,experimentalParseClassName:n}=e,s=t.length===1,o=t[0],a=t.length,i=c=>{const u=[];let d=0,h=0,f;for(let x=0;x<c.length;x++){let y=c[x];if(d===0){if(y===o&&(s||c.slice(x,x+a)===t)){u.push(c.slice(h,x)),h=x+a;continue}if(y==="/"){f=x;continue}}y==="["?d++:y==="]"&&d--}const m=u.length===0?c:c.substring(h),g=m.startsWith(Fc),v=g?m.substring(1):m,p=f&&f>h?f-h:void 0;return{modifiers:u,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:p}};return n?c=>n({className:c,parseClassName:i}):i},Cp=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(s=>{s[0]==="["?(t.push(...n.sort(),s),n=[]):n.push(s)}),t.push(...n.sort()),t},Sp=e=>({cache:jp(e.cacheSize),parseClassName:Np(e),...gp(e)}),Ep=/\s+/,Rp=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o}=t,a=[],i=e.trim().split(Ep);let c="";for(let u=i.length-1;u>=0;u-=1){const d=i[u],{modifiers:h,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:g}=n(d);let v=!!g,p=s(v?m.substring(0,g):m);if(!p){if(!v){c=d+(c.length>0?" "+c:c);continue}if(p=s(m),!p){c=d+(c.length>0?" "+c:c);continue}v=!1}const x=Cp(h).join(":"),y=f?x+Fc:x,w=y+p;if(a.includes(w))continue;a.push(w);const N=o(p,v);for(let j=0;j<N.length;++j){const C=N[j];a.push(y+C)}c=d+(c.length>0?" "+c:c)}return c};function Pp(){let e=0,t,n,s="";for(;e<arguments.length;)(t=arguments[e++])&&(n=$c(t))&&(s&&(s+=" "),s+=n);return s}const $c=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=$c(e[s]))&&(n&&(n+=" "),n+=t);return n};function kp(e,...t){let n,s,o,a=i;function i(u){const d=t.reduce((h,f)=>f(h),e());return n=Sp(d),s=n.cache.get,o=n.cache.set,a=c,c(u)}function c(u){const d=s(u);if(d)return d;const h=Rp(u,n);return o(u,h),h}return function(){return a(Pp.apply(null,arguments))}}const me=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Uc=/^\[(?:([a-z-]+):)?(.+)\]$/i,Tp=/^\d+\/\d+$/,Ap=new Set(["px","full","screen"]),Mp=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_p=/\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$/,Ip=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Op=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Dp=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ct=e=>Rn(e)||Ap.has(e)||Tp.test(e),Nt=e=>Zn(e,"length",Kp),Rn=e=>!!e&&!Number.isNaN(Number(e)),Ws=e=>Zn(e,"number",Rn),ar=e=>!!e&&Number.isInteger(Number(e)),zp=e=>e.endsWith("%")&&Rn(e.slice(0,-1)),ee=e=>Uc.test(e),Ct=e=>Mp.test(e),Lp=new Set(["length","size","percentage"]),Fp=e=>Zn(e,Lp,Vc),$p=e=>Zn(e,"position",Vc),Up=new Set(["image","url"]),Vp=e=>Zn(e,Up,qp),Bp=e=>Zn(e,"",Hp),ir=()=>!0,Zn=(e,t,n)=>{const s=Uc.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):n(s[2]):!1},Kp=e=>_p.test(e)&&!Ip.test(e),Vc=()=>!1,Hp=e=>Op.test(e),qp=e=>Dp.test(e),Wp=()=>{const e=me("colors"),t=me("spacing"),n=me("blur"),s=me("brightness"),o=me("borderColor"),a=me("borderRadius"),i=me("borderSpacing"),c=me("borderWidth"),u=me("contrast"),d=me("grayscale"),h=me("hueRotate"),f=me("invert"),m=me("gap"),g=me("gradientColorStops"),v=me("gradientColorStopPositions"),p=me("inset"),x=me("margin"),y=me("opacity"),w=me("padding"),N=me("saturate"),j=me("scale"),C=me("sepia"),E=me("skew"),S=me("space"),P=me("translate"),D=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto",ee,t],_=()=>[ee,t],G=()=>["",ct,Nt],U=()=>["auto",Rn,ee],X=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],V=()=>["solid","dashed","dotted","double","none"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],L=()=>["start","end","center","between","around","evenly","stretch"],T=()=>["","0",ee],ie=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ce=()=>[Rn,ee];return{cacheSize:500,separator:":",theme:{colors:[ir],spacing:[ct,Nt],blur:["none","",Ct,ee],brightness:ce(),borderColor:[e],borderRadius:["none","","full",Ct,ee],borderSpacing:_(),borderWidth:G(),contrast:ce(),grayscale:T(),hueRotate:ce(),invert:T(),gap:_(),gradientColorStops:[e],gradientColorStopPositions:[zp,Nt],inset:$(),margin:$(),opacity:ce(),padding:_(),saturate:ce(),scale:ce(),sepia:T(),skew:ce(),space:_(),translate:_()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],container:["container"],columns:[{columns:[Ct]}],"break-after":[{"break-after":ie()}],"break-before":[{"break-before":ie()}],"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:[...X(),ee]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ar,ee]}],basis:[{basis:$()}],"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:T()}],shrink:[{shrink:T()}],order:[{order:["first","last","none",ar,ee]}],"grid-cols":[{"grid-cols":[ir]}],"col-start-end":[{col:["auto",{span:["full",ar,ee]},ee]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[ir]}],"row-start-end":[{row:["auto",{span:[ar,ee]},ee]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"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:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...L()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...L(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...L(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"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:[Ct]},Ct]}],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",Ct,Nt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ws]}],"font-family":[{font:[ir]}],"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",Rn,Ws]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ct,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ct,Nt]}],"underline-offset":[{"underline-offset":["auto",ct,ee]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"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":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...X(),$p]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Fp]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Vp]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[c]}],"border-w-x":[{"border-x":[c]}],"border-w-y":[{"border-y":[c]}],"border-w-s":[{"border-s":[c]}],"border-w-e":[{"border-e":[c]}],"border-w-t":[{"border-t":[c]}],"border-w-r":[{"border-r":[c]}],"border-w-b":[{"border-b":[c]}],"border-w-l":[{"border-l":[c]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...V(),"hidden"]}],"divide-x":[{"divide-x":[c]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[c]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:V()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...V()]}],"outline-offset":[{"outline-offset":[ct,ee]}],"outline-w":[{outline:[ct,Nt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[ct,Nt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ct,Bp]}],"shadow-color":[{shadow:[ir]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[s]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Ct,ee]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[f]}],saturate:[{saturate:[N]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ee]}],duration:[{duration:ce()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:ce()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[j]}],"scale-x":[{"scale-x":[j]}],"scale-y":[{"scale-y":[j]}],rotate:[{rotate:[ar,ee]}],"translate-x":[{"translate-x":[P]}],"translate-y":[{"translate-y":[P]}],"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",e]}],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:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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:[e,"none"]}],"stroke-w":[{stroke:[ct,Nt,Ws]}],stroke:[{stroke:[e,"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"]}}},Gp=kp(Wp);function k(...e){return Gp(zc(e))}const Qp=[{to:"/",label:"Dashboard",icon:Jm,end:!0},{to:"/orders",label:"Orders",icon:Bn,end:!1},{to:"/products",label:"Products",icon:dn,end:!1},{to:"/inventory",label:"Inventory",icon:Cc,end:!1},{to:"/customers",label:"Customers",icon:oa,end:!1},{to:"/activity",label:"Activity",icon:os,end:!1},{to:"/settings",label:"Settings",icon:ap,end:!1}];function Yp(){const{data:e}=Ic({status:"pending",limit:1});return!e||e.length===0?null:r.jsx("span",{className:"ml-auto flex h-4 min-w-4 items-center justify-center rounded-full bg-blue-500/20 px-1 text-[10px] font-semibold text-blue-400",children:e.length})}function Xp({open:e,onClose:t}){const{data:n}=Mc(),{logout:s}=_c(),o=()=>{s()};return r.jsxs("aside",{id:"admin-sidebar","data-testid":q("sidebar"),"data-state":e?"open":"closed",className:k("fixed inset-y-0 left-0 z-50 flex w-60 flex-col bg-zinc-950 transition-transform duration-150 md:visible md:translate-x-0",e?"visible translate-x-0":"invisible -translate-x-full"),children:[r.jsxs("div",{className:"flex h-14 items-center border-b border-zinc-800/60 px-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-blue-600",children:r.jsx("span",{className:"text-xs font-bold text-white",children:"N"})}),r.jsx("span",{className:"text-sm font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"})]}),(n==null?void 0:n.storeName)&&r.jsx("span",{className:"ml-2 truncate text-[10px] font-medium text-zinc-500 border-l border-zinc-700 pl-2",children:n.storeName})]}),r.jsx("nav",{className:"flex-1 overflow-y-auto py-3 px-2",children:r.jsx("ul",{className:"space-y-0.5",children:Qp.map(a=>r.jsx("li",{children:r.jsx(Ff,{to:a.to,end:a.end,"data-testid":q("nav",a.label.toLowerCase()),onClick:t,className:({isActive:i})=>k("flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium transition-all duration-100",i?"border-l-2 border-blue-500 bg-blue-600/10 pl-[10px] text-blue-400":"text-zinc-400 hover:bg-zinc-800/50 hover:text-zinc-200"),children:({isActive:i})=>r.jsxs(r.Fragment,{children:[r.jsx(a.icon,{className:k("h-4 w-4 shrink-0",i?"text-blue-400":"text-zinc-500")}),r.jsx("span",{children:a.label}),a.label==="Orders"&&r.jsx(Yp,{})]})})},a.to))})}),r.jsx("div",{className:"border-t border-zinc-800/60"}),r.jsx("div",{className:"p-3",children:r.jsxs("div",{className:"flex items-center gap-3 rounded-md px-3 py-2.5",children:[r.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-zinc-700 text-xs font-semibold text-zinc-300",children:n?n.userId.slice(0,2).toUpperCase():r.jsx(sa,{className:"h-3.5 w-3.5 animate-spin"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-xs font-medium text-zinc-300",children:(n==null?void 0:n.storeName)??"Loading..."}),r.jsx("p",{className:"truncate text-[10px] text-zinc-500 capitalize",children:(n==null?void 0:n.environment)??""})]}),r.jsx("button",{onClick:o,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300 transition-colors",title:"Sign out",children:r.jsx(ep,{className:"h-3.5 w-3.5"})})]})})]})}function Zp(){const t=$f().filter(n=>{const s=n.handle;return(s==null?void 0:s.breadcrumb)!=null}).map(n=>{var a;const s=n.handle;return{label:(a=s.breadcrumb)==null?void 0:a.call(s,n.params),pathname:n.pathname}}).filter(n=>n.label!=null);return t.length===0?null:r.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:t.map((n,s)=>{const o=s===t.length-1;return r.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&r.jsx(Ec,{className:"h-3.5 w-3.5 text-zinc-400"}),o?r.jsx("span",{className:"font-medium text-zinc-900",children:n.label}):r.jsx(an,{to:n.pathname,className:k("text-zinc-500 hover:text-zinc-700 transition-colors","font-normal"),children:n.label})]},n.pathname)})})}const oi=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ai=zc,ys=(e,t)=>n=>{var s;if((t==null?void 0:t.variants)==null)return ai(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(d=>{const h=n==null?void 0:n[d],f=a==null?void 0:a[d];if(h===null)return null;const m=oi(h)||oi(f);return o[d][m]}),c=n&&Object.entries(n).reduce((d,h)=>{let[f,m]=h;return m===void 0||(d[f]=m),d},{}),u=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((d,h)=>{let{class:f,className:m,...g}=h;return Object.entries(g).every(v=>{let[p,x]=v;return Array.isArray(x)?x.includes({...a,...c}[p]):{...a,...c}[p]===x})?[...d,f,m]:d},[]);return ai(e,i,u,n==null?void 0:n.class,n==null?void 0:n.className)},Jp=ys("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 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-blue-600 text-white hover:bg-blue-700 active:bg-blue-800",secondary:"bg-zinc-100 text-zinc-900 hover:bg-zinc-200 active:bg-zinc-300 border border-zinc-200",destructive:"bg-red-600 text-white hover:bg-red-700 active:bg-red-800",outline:"border border-zinc-200 bg-white text-zinc-900 hover:bg-zinc-50 active:bg-zinc-100",ghost:"text-zinc-700 hover:bg-zinc-100 hover:text-zinc-900 active:bg-zinc-200",link:"text-blue-600 underline-offset-4 hover:underline p-0 h-auto"},size:{default:"h-9 px-4 py-2",sm:"h-7 rounded px-3 text-xs",lg:"h-11 rounded-md px-8 text-base",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ue=l.forwardRef(({className:e,variant:t,size:n,...s},o)=>r.jsx("button",{className:k(Jp({variant:t,size:n,className:e})),ref:o,...s}));ue.displayName="Button";function I(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function ii(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rt(...e){return t=>{let n=!1;const s=e.map(o=>{const a=ii(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<s.length;o++){const a=s[o];typeof a=="function"?a():ii(e[o],null)}}}}function le(...e){return l.useCallback(rt(...e),e)}function ex(e,t){const n=l.createContext(t),s=a=>{const{children:i,...c}=a,u=l.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,children:i})};s.displayName=e+"Provider";function o(a){const i=l.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,o]}function ot(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),u=n.length;n=[...n,i];const d=f=>{var y;const{scope:m,children:g,...v}=f,p=((y=m==null?void 0:m[e])==null?void 0:y[u])||c,x=l.useMemo(()=>v,Object.values(v));return r.jsx(p.Provider,{value:x,children:g})};d.displayName=a+"Provider";function h(f,m){var p;const g=((p=m==null?void 0:m[e])==null?void 0:p[u])||c,v=l.useContext(g);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[d,h]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const u=(c==null?void 0:c[e])||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return o.scopeName=e,[s,tx(o,...t)]}function tx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:u,scopeName:d})=>{const f=u(a)[`__scope${d}`];return{...c,...f}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function un(e){const t=nx(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),u=c.find(sx);if(u){const d=u.props.children,h=c.map(f=>f===u?l.Children.count(d)>1?l.Children.only(null):l.isValidElement(d)?d.props.children:null:f);return r.jsx(t,{...i,ref:o,children:l.isValidElement(d)?l.cloneElement(d,void 0,h):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function nx(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=ax(o),c=ox(a,o.props);return o.type!==l.Fragment&&(c.ref=s?rt(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rx=Symbol("radix.slottable");function sx(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rx}function ox(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const u=a(...c);return o(...c),u}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ax(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ix=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],W=ix.reduce((e,t)=>{const n=un(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Bc(e,t){e&&Sr.flushSync(()=>e.dispatchEvent(t))}function st(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function cx(e,t=globalThis==null?void 0:globalThis.document){const n=st(e);l.useEffect(()=>{const s=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var lx="DismissableLayer",Mo="dismissableLayer.update",dx="dismissableLayer.pointerDownOutside",ux="dismissableLayer.focusOutside",ci,Kc=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...u}=e,d=l.useContext(Kc),[h,f]=l.useState(null),m=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=l.useState({}),v=le(t,S=>f(S)),p=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=p.indexOf(x),w=h?p.indexOf(h):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,j=w>=y,C=mx(S=>{const P=S.target,D=[...d.branches].some(O=>O.contains(P));!j||D||(o==null||o(S),i==null||i(S),S.defaultPrevented||c==null||c())},m),E=px(S=>{const P=S.target;[...d.branches].some(O=>O.contains(P))||(a==null||a(S),i==null||i(S),S.defaultPrevented||c==null||c())},m);return cx(S=>{w===d.layers.size-1&&(s==null||s(S),!S.defaultPrevented&&c&&(S.preventDefault(),c()))},m),l.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(ci=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),li(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=ci)}},[h,m,n,d]),l.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),li())},[h,d]),l.useEffect(()=>{const S=()=>g({});return document.addEventListener(Mo,S),()=>document.removeEventListener(Mo,S)},[]),r.jsx(W.div,{...u,ref:v,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:I(e.onFocusCapture,E.onFocusCapture),onBlurCapture:I(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:I(e.onPointerDownCapture,C.onPointerDownCapture)})});Er.displayName=lx;var fx="DismissableLayerBranch",hx=l.forwardRef((e,t)=>{const n=l.useContext(Kc),s=l.useRef(null),o=le(t,s);return l.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(W.div,{...e,ref:o})});hx.displayName=fx;function mx(e,t=globalThis==null?void 0:globalThis.document){const n=st(e),s=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let u=function(){Hc(dx,n,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);s.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function px(e,t=globalThis==null?void 0:globalThis.document){const n=st(e),s=l.useRef(!1);return l.useEffect(()=>{const o=a=>{a.target&&!s.current&&Hc(ux,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function li(){const e=new CustomEvent(Mo);document.dispatchEvent(e)}function Hc(e,t,n,{discrete:s}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?Bc(o,a):o.dispatchEvent(a)}var Gs=0;function bs(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??di()),document.body.insertAdjacentElement("beforeend",e[1]??di()),Gs++,()=>{Gs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Gs--}},[])}function di(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Qs="focusScope.autoFocusOnMount",Ys="focusScope.autoFocusOnUnmount",ui={bubbles:!1,cancelable:!0},xx="FocusScope",Rr=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,u]=l.useState(null),d=st(o),h=st(a),f=l.useRef(null),m=le(t,p=>u(p)),g=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(s){let p=function(N){if(g.paused||!c)return;const j=N.target;c.contains(j)?f.current=j:Rt(f.current,{select:!0})},x=function(N){if(g.paused||!c)return;const j=N.relatedTarget;j!==null&&(c.contains(j)||Rt(f.current,{select:!0}))},y=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&Rt(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",x);const w=new MutationObserver(y);return c&&w.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",x),w.disconnect()}}},[s,c,g.paused]),l.useEffect(()=>{if(c){hi.add(g);const p=document.activeElement;if(!c.contains(p)){const y=new CustomEvent(Qs,ui);c.addEventListener(Qs,d),c.dispatchEvent(y),y.defaultPrevented||(gx(jx(qc(c)),{select:!0}),document.activeElement===p&&Rt(c))}return()=>{c.removeEventListener(Qs,d),setTimeout(()=>{const y=new CustomEvent(Ys,ui);c.addEventListener(Ys,h),c.dispatchEvent(y),y.defaultPrevented||Rt(p??document.body,{select:!0}),c.removeEventListener(Ys,h),hi.remove(g)},0)}}},[c,d,h,g]);const v=l.useCallback(p=>{if(!n&&!s||g.paused)return;const x=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,y=document.activeElement;if(x&&y){const w=p.currentTarget,[N,j]=vx(w);N&&j?!p.shiftKey&&y===j?(p.preventDefault(),n&&Rt(N,{select:!0})):p.shiftKey&&y===N&&(p.preventDefault(),n&&Rt(j,{select:!0})):y===w&&p.preventDefault()}},[n,s,g.paused]);return r.jsx(W.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Rr.displayName=xx;function gx(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Rt(s,{select:t}),document.activeElement!==n)return}function vx(e){const t=qc(e),n=fi(t,e),s=fi(t.reverse(),e);return[n,s]}function qc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function fi(e,t){for(const n of e)if(!yx(n,{upTo:t}))return n}function yx(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function bx(e){return e instanceof HTMLInputElement&&"select"in e}function Rt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bx(e)&&t&&e.select()}}var hi=wx();function wx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=mi(e,t),e.unshift(t)},remove(t){var n;e=mi(e,t),(n=e[0])==null||n.resume()}}}function mi(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function jx(e){return e.filter(t=>t.tagName!=="A")}var Ce=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},Nx=Qo[" useId ".trim().toString()]||(()=>{}),Cx=0;function je(e){const[t,n]=l.useState(Nx());return Ce(()=>{n(s=>s??String(Cx++))},[e]),t?`radix-${t}`:""}const Sx=["top","right","bottom","left"],Ft=Math.min,De=Math.max,is=Math.round,$r=Math.floor,nt=e=>({x:e,y:e}),Ex={left:"right",right:"left",bottom:"top",top:"bottom"};function _o(e,t,n){return De(e,Ft(t,n))}function xt(e,t){return typeof e=="function"?e(t):e}function gt(e){return e.split("-")[0]}function Jn(e){return e.split("-")[1]}function ia(e){return e==="x"?"y":"x"}function ca(e){return e==="y"?"height":"width"}function tt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function la(e){return ia(tt(e))}function Rx(e,t,n){n===void 0&&(n=!1);const s=Jn(e),o=la(e),a=ca(o);let i=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=cs(i)),[i,cs(i)]}function Px(e){const t=cs(e);return[Io(e),t,Io(t)]}function Io(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const pi=["left","right"],xi=["right","left"],kx=["top","bottom"],Tx=["bottom","top"];function Ax(e,t,n){switch(e){case"top":case"bottom":return n?t?xi:pi:t?pi:xi;case"left":case"right":return t?kx:Tx;default:return[]}}function Mx(e,t,n,s){const o=Jn(e);let a=Ax(gt(e),n==="start",s);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Io)))),a}function cs(e){const t=gt(e);return Ex[t]+e.slice(t.length)}function _x(e){return{top:0,right:0,bottom:0,left:0,...e}}function Wc(e){return typeof e!="number"?_x(e):{top:e,right:e,bottom:e,left:e}}function ls(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function gi(e,t,n){let{reference:s,floating:o}=e;const a=tt(t),i=la(t),c=ca(i),u=gt(t),d=a==="y",h=s.x+s.width/2-o.width/2,f=s.y+s.height/2-o.height/2,m=s[c]/2-o[c]/2;let g;switch(u){case"top":g={x:h,y:s.y-o.height};break;case"bottom":g={x:h,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:f};break;case"left":g={x:s.x-o.width,y:f};break;default:g={x:s.x,y:s.y}}switch(Jn(t)){case"start":g[i]-=m*(n&&d?-1:1);break;case"end":g[i]+=m*(n&&d?-1:1);break}return g}async function Ix(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:m=!1,padding:g=0}=xt(t,e),v=Wc(g),x=c[m?f==="floating"?"reference":"floating":f],y=ls(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:h,strategy:u})),w=f==="floating"?{x:s,y:o,width:i.floating.width,height:i.floating.height}:i.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),j=await(a.isElement==null?void 0:a.isElement(N))?await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1}:{x:1,y:1},C=ls(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:N,strategy:u}):w);return{top:(y.top-C.top+v.top)/j.y,bottom:(C.bottom-y.bottom+v.bottom)/j.y,left:(y.left-C.left+v.left)/j.x,right:(C.right-y.right+v.right)/j.x}}const Ox=50,Dx=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Ix},u=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:h,y:f}=gi(d,s,u),m=s,g=0;const v={};for(let p=0;p<a.length;p++){const x=a[p];if(!x)continue;const{name:y,fn:w}=x,{x:N,y:j,data:C,reset:E}=await w({x:h,y:f,initialPlacement:s,placement:m,strategy:o,middlewareData:v,rects:d,platform:c,elements:{reference:e,floating:t}});h=N??h,f=j??f,v[y]={...v[y],...C},E&&g<Ox&&(g++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(d=E.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:h,y:f}=gi(d,m,u)),p=-1)}return{x:h,y:f,placement:m,strategy:o,middlewareData:v}},zx=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:i,elements:c,middlewareData:u}=t,{element:d,padding:h=0}=xt(e,t)||{};if(d==null)return{};const f=Wc(h),m={x:n,y:s},g=la(o),v=ca(g),p=await i.getDimensions(d),x=g==="y",y=x?"top":"left",w=x?"bottom":"right",N=x?"clientHeight":"clientWidth",j=a.reference[v]+a.reference[g]-m[g]-a.floating[v],C=m[g]-a.reference[g],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let S=E?E[N]:0;(!S||!await(i.isElement==null?void 0:i.isElement(E)))&&(S=c.floating[N]||a.floating[v]);const P=j/2-C/2,D=S/2-p[v]/2-1,O=Ft(f[y],D),$=Ft(f[w],D),_=O,G=S-p[v]-$,U=S/2-p[v]/2+P,X=_o(_,U,G),V=!u.arrow&&Jn(o)!=null&&U!==X&&a.reference[v]/2-(U<_?O:$)-p[v]/2<0,re=V?U<_?U-_:U-G:0;return{[g]:m[g]+re,data:{[g]:X,centerOffset:U-X-re,...V&&{alignmentOffset:re}},reset:V}}}),Lx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:p=!0,...x}=xt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=gt(o),w=tt(c),N=gt(c)===c,j=await(u.isRTL==null?void 0:u.isRTL(d.floating)),C=m||(N||!p?[cs(c)]:Px(c)),E=v!=="none";!m&&E&&C.push(...Mx(c,p,v,j));const S=[c,...C],P=await u.detectOverflow(t,x),D=[];let O=((s=a.flip)==null?void 0:s.overflows)||[];if(h&&D.push(P[y]),f){const U=Rx(o,i,j);D.push(P[U[0]],P[U[1]])}if(O=[...O,{placement:o,overflows:D}],!D.every(U=>U<=0)){var $,_;const U=((($=a.flip)==null?void 0:$.index)||0)+1,X=S[U];if(X&&(!(f==="alignment"?w!==tt(X):!1)||O.every(L=>tt(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:U,overflows:O},reset:{placement:X}};let V=(_=O.filter(re=>re.overflows[0]<=0).sort((re,L)=>re.overflows[1]-L.overflows[1])[0])==null?void 0:_.placement;if(!V)switch(g){case"bestFit":{var G;const re=(G=O.filter(L=>{if(E){const T=tt(L.placement);return T===w||T==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(T=>T>0).reduce((T,ie)=>T+ie,0)]).sort((L,T)=>L[1]-T[1])[0])==null?void 0:G[0];re&&(V=re);break}case"initialPlacement":V=c;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function vi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yi(e){return Sx.some(t=>e[t]>=0)}const Fx=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...a}=xt(e,t);switch(o){case"referenceHidden":{const i=await s.detectOverflow(t,{...a,elementContext:"reference"}),c=vi(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:yi(c)}}}case"escaped":{const i=await s.detectOverflow(t,{...a,altBoundary:!0}),c=vi(i,n.floating);return{data:{escapedOffsets:c,escaped:yi(c)}}}default:return{}}}}},Gc=new Set(["left","top"]);async function $x(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),i=gt(n),c=Jn(n),u=tt(n)==="y",d=Gc.has(i)?-1:1,h=a&&u?-1:1,f=xt(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof v=="number"&&(g=c==="end"?v*-1:v),u?{x:g*h,y:m*d}:{x:m*d,y:g*h}}const Ux=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:i,middlewareData:c}=t,u=await $x(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:i}}}}},Vx=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:a}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:u={fn:y=>{let{x:w,y:N}=y;return{x:w,y:N}}},...d}=xt(e,t),h={x:n,y:s},f=await a.detectOverflow(t,d),m=tt(gt(o)),g=ia(m);let v=h[g],p=h[m];if(i){const y=g==="y"?"top":"left",w=g==="y"?"bottom":"right",N=v+f[y],j=v-f[w];v=_o(N,v,j)}if(c){const y=m==="y"?"top":"left",w=m==="y"?"bottom":"right",N=p+f[y],j=p-f[w];p=_o(N,p,j)}const x=u.fn({...t,[g]:v,[m]:p});return{...x,data:{x:x.x-n,y:x.y-s,enabled:{[g]:i,[m]:c}}}}}},Bx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:u=!0,crossAxis:d=!0}=xt(e,t),h={x:n,y:s},f=tt(o),m=ia(f);let g=h[m],v=h[f];const p=xt(c,t),x=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(u){const N=m==="y"?"height":"width",j=a.reference[m]-a.floating[N]+x.mainAxis,C=a.reference[m]+a.reference[N]-x.mainAxis;g<j?g=j:g>C&&(g=C)}if(d){var y,w;const N=m==="y"?"width":"height",j=Gc.has(gt(o)),C=a.reference[f]-a.floating[N]+(j&&((y=i.offset)==null?void 0:y[f])||0)+(j?0:x.crossAxis),E=a.reference[f]+a.reference[N]+(j?0:((w=i.offset)==null?void 0:w[f])||0)-(j?x.crossAxis:0);v<C?v=C:v>E&&(v=E)}return{[m]:g,[f]:v}}}},Kx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:a,platform:i,elements:c}=t,{apply:u=()=>{},...d}=xt(e,t),h=await i.detectOverflow(t,d),f=gt(o),m=Jn(o),g=tt(o)==="y",{width:v,height:p}=a.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const w=p-h.top-h.bottom,N=v-h.left-h.right,j=Ft(p-h[x],w),C=Ft(v-h[y],N),E=!t.middlewareData.shift;let S=j,P=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(S=w),E&&!m){const O=De(h.left,0),$=De(h.right,0),_=De(h.top,0),G=De(h.bottom,0);g?P=v-2*(O!==0||$!==0?O+$:De(h.left,h.right)):S=p-2*(_!==0||G!==0?_+G:De(h.top,h.bottom))}await u({...t,availableWidth:P,availableHeight:S});const D=await i.getDimensions(c.floating);return v!==D.width||p!==D.height?{reset:{rects:!0}}:{}}}};function ws(){return typeof window<"u"}function er(e){return Qc(e)?(e.nodeName||"").toLowerCase():"#document"}function Le(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function at(e){var t;return(t=(Qc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Qc(e){return ws()?e instanceof Node||e instanceof Le(e).Node:!1}function We(e){return ws()?e instanceof Element||e instanceof Le(e).Element:!1}function bt(e){return ws()?e instanceof HTMLElement||e instanceof Le(e).HTMLElement:!1}function bi(e){return!ws()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Le(e).ShadowRoot}function Pr(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Ge(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function Hx(e){return/^(table|td|th)$/.test(er(e))}function js(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const qx=/transform|translate|scale|rotate|perspective|filter/,Wx=/paint|layout|strict|content/,qt=e=>!!e&&e!=="none";let Xs;function da(e){const t=We(e)?Ge(e):e;return qt(t.transform)||qt(t.translate)||qt(t.scale)||qt(t.rotate)||qt(t.perspective)||!ua()&&(qt(t.backdropFilter)||qt(t.filter))||qx.test(t.willChange||"")||Wx.test(t.contain||"")}function Gx(e){let t=$t(e);for(;bt(t)&&!Kn(t);){if(da(t))return t;if(js(t))return null;t=$t(t)}return null}function ua(){return Xs==null&&(Xs=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xs}function Kn(e){return/^(html|body|#document)$/.test(er(e))}function Ge(e){return Le(e).getComputedStyle(e)}function Ns(e){return We(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $t(e){if(er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bi(e)&&e.host||at(e);return bi(t)?t.host:t}function Yc(e){const t=$t(e);return Kn(t)?e.ownerDocument?e.ownerDocument.body:e.body:bt(t)&&Pr(t)?t:Yc(t)}function pr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Yc(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),i=Le(o);if(a){const c=Oo(i);return t.concat(i,i.visualViewport||[],Pr(o)?o:[],c&&n?pr(c):[])}else return t.concat(o,pr(o,[],n))}function Oo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Xc(e){const t=Ge(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=bt(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:s,c=is(n)!==a||is(s)!==i;return c&&(n=a,s=i),{width:n,height:s,$:c}}function fa(e){return We(e)?e:e.contextElement}function Pn(e){const t=fa(e);if(!bt(t))return nt(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=Xc(t);let i=(a?is(n.width):n.width)/s,c=(a?is(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Qx=nt(0);function Zc(e){const t=Le(e);return!ua()||!t.visualViewport?Qx:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Yx(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Le(e)?!1:t}function fn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=fa(e);let i=nt(1);t&&(s?We(s)&&(i=Pn(s)):i=Pn(e));const c=Yx(a,n,s)?Zc(a):nt(0);let u=(o.left+c.x)/i.x,d=(o.top+c.y)/i.y,h=o.width/i.x,f=o.height/i.y;if(a){const m=Le(a),g=s&&We(s)?Le(s):s;let v=m,p=Oo(v);for(;p&&s&&g!==v;){const x=Pn(p),y=p.getBoundingClientRect(),w=Ge(p),N=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*x.x,j=y.top+(p.clientTop+parseFloat(w.paddingTop))*x.y;u*=x.x,d*=x.y,h*=x.x,f*=x.y,u+=N,d+=j,v=Le(p),p=Oo(v)}}return ls({width:h,height:f,x:u,y:d})}function Cs(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:fn(at(e)).left+n}function Jc(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Cs(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function Xx(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",i=at(s),c=t?js(t.floating):!1;if(s===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},d=nt(1);const h=nt(0),f=bt(s);if((f||!f&&!a)&&((er(s)!=="body"||Pr(i))&&(u=Ns(s)),f)){const g=fn(s);d=Pn(s),h.x=g.x+s.clientLeft,h.y=g.y+s.clientTop}const m=i&&!f&&!a?Jc(i,u):nt(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+m.x,y:n.y*d.y-u.scrollTop*d.y+h.y+m.y}}function Zx(e){return Array.from(e.getClientRects())}function Jx(e){const t=at(e),n=Ns(e),s=e.ownerDocument.body,o=De(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=De(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Cs(e);const c=-n.scrollTop;return Ge(s).direction==="rtl"&&(i+=De(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:i,y:c}}const wi=25;function eg(e,t){const n=Le(e),s=at(e),o=n.visualViewport;let a=s.clientWidth,i=s.clientHeight,c=0,u=0;if(o){a=o.width,i=o.height;const h=ua();(!h||h&&t==="fixed")&&(c=o.offsetLeft,u=o.offsetTop)}const d=Cs(s);if(d<=0){const h=s.ownerDocument,f=h.body,m=getComputedStyle(f),g=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(s.clientWidth-f.clientWidth-g);v<=wi&&(a-=v)}else d<=wi&&(a+=d);return{width:a,height:i,x:c,y:u}}function tg(e,t){const n=fn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=bt(e)?Pn(e):nt(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=o*a.x,d=s*a.y;return{width:i,height:c,x:u,y:d}}function ji(e,t,n){let s;if(t==="viewport")s=eg(e,n);else if(t==="document")s=Jx(at(e));else if(We(t))s=tg(t,n);else{const o=Zc(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ls(s)}function el(e,t){const n=$t(e);return n===t||!We(n)||Kn(n)?!1:Ge(n).position==="fixed"||el(n,t)}function ng(e,t){const n=t.get(e);if(n)return n;let s=pr(e,[],!1).filter(c=>We(c)&&er(c)!=="body"),o=null;const a=Ge(e).position==="fixed";let i=a?$t(e):e;for(;We(i)&&!Kn(i);){const c=Ge(i),u=da(i);!u&&c.position==="fixed"&&(o=null),(a?!u&&!o:!u&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Pr(i)&&!u&&el(e,i))?s=s.filter(h=>h!==i):o=c,i=$t(i)}return t.set(e,s),s}function rg(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const i=[...n==="clippingAncestors"?js(t)?[]:ng(t,this._c):[].concat(n),s],c=ji(t,i[0],o);let u=c.top,d=c.right,h=c.bottom,f=c.left;for(let m=1;m<i.length;m++){const g=ji(t,i[m],o);u=De(g.top,u),d=Ft(g.right,d),h=Ft(g.bottom,h),f=De(g.left,f)}return{width:d-f,height:h-u,x:f,y:u}}function sg(e){const{width:t,height:n}=Xc(e);return{width:t,height:n}}function og(e,t,n){const s=bt(t),o=at(t),a=n==="fixed",i=fn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=nt(0);function d(){u.x=Cs(o)}if(s||!s&&!a)if((er(t)!=="body"||Pr(o))&&(c=Ns(t)),s){const g=fn(t,!0,a,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else o&&d();a&&!s&&o&&d();const h=o&&!s&&!a?Jc(o,c):nt(0),f=i.left+c.scrollLeft-u.x-h.x,m=i.top+c.scrollTop-u.y-h.y;return{x:f,y:m,width:i.width,height:i.height}}function Zs(e){return Ge(e).position==="static"}function Ni(e,t){if(!bt(e)||Ge(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return at(e)===n&&(n=n.ownerDocument.body),n}function tl(e,t){const n=Le(e);if(js(e))return n;if(!bt(e)){let o=$t(e);for(;o&&!Kn(o);){if(We(o)&&!Zs(o))return o;o=$t(o)}return n}let s=Ni(e,t);for(;s&&Hx(s)&&Zs(s);)s=Ni(s,t);return s&&Kn(s)&&Zs(s)&&!da(s)?n:s||Gx(e)||n}const ag=async function(e){const t=this.getOffsetParent||tl,n=this.getDimensions,s=await n(e.floating);return{reference:og(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function ig(e){return Ge(e).direction==="rtl"}const cg={convertOffsetParentRelativeRectToViewportRelativeRect:Xx,getDocumentElement:at,getClippingRect:rg,getOffsetParent:tl,getElementRects:ag,getClientRects:Zx,getDimensions:sg,getScale:Pn,isElement:We,isRTL:ig};function nl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lg(e,t){let n=null,s;const o=at(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const d=e.getBoundingClientRect(),{left:h,top:f,width:m,height:g}=d;if(c||t(),!m||!g)return;const v=$r(f),p=$r(o.clientWidth-(h+m)),x=$r(o.clientHeight-(f+g)),y=$r(h),N={rootMargin:-v+"px "+-p+"px "+-x+"px "+-y+"px",threshold:De(0,Ft(1,u))||1};let j=!0;function C(E){const S=E[0].intersectionRatio;if(S!==u){if(!j)return i();S?i(!1,S):s=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!nl(d,e.getBoundingClientRect())&&i(),j=!1}try{n=new IntersectionObserver(C,{...N,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,N)}n.observe(e)}return i(!0),a}function dg(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,d=fa(e),h=o||a?[...d?pr(d):[],...t?pr(t):[]]:[];h.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const f=d&&c?lg(d,n):null;let m=-1,g=null;i&&(g=new ResizeObserver(y=>{let[w]=y;w&&w.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=g)==null||N.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let v,p=u?fn(e):null;u&&x();function x(){const y=fn(e);p&&!nl(p,y)&&n(),p=y,v=requestAnimationFrame(x)}return n(),()=>{var y;h.forEach(w=>{o&&w.removeEventListener("scroll",n),a&&w.removeEventListener("resize",n)}),f==null||f(),(y=g)==null||y.disconnect(),g=null,u&&cancelAnimationFrame(v)}}const ug=Ux,fg=Vx,hg=Lx,mg=Kx,pg=Fx,Ci=zx,xg=Bx,gg=(e,t,n)=>{const s=new Map,o={platform:cg,...n},a={...o.platform,_c:s};return Dx(e,t,{...o,platform:a})};var vg=typeof document<"u",yg=function(){},Qr=vg?l.useLayoutEffect:yg;function ds(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!ds(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const a=o[s];if(!(a==="_owner"&&e.$$typeof)&&!ds(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function rl(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Si(e,t){const n=rl(e);return Math.round(t*n)/n}function Js(e){const t=l.useRef(e);return Qr(()=>{t.current=e}),t}function bg(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:u,open:d}=e,[h,f]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=l.useState(s);ds(m,s)||g(s);const[v,p]=l.useState(null),[x,y]=l.useState(null),w=l.useCallback(L=>{L!==E.current&&(E.current=L,p(L))},[]),N=l.useCallback(L=>{L!==S.current&&(S.current=L,y(L))},[]),j=a||v,C=i||x,E=l.useRef(null),S=l.useRef(null),P=l.useRef(h),D=u!=null,O=Js(u),$=Js(o),_=Js(d),G=l.useCallback(()=>{if(!E.current||!S.current)return;const L={placement:t,strategy:n,middleware:m};$.current&&(L.platform=$.current),gg(E.current,S.current,L).then(T=>{const ie={...T,isPositioned:_.current!==!1};U.current&&!ds(P.current,ie)&&(P.current=ie,Sr.flushSync(()=>{f(ie)}))})},[m,t,n,$,_]);Qr(()=>{d===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[d]);const U=l.useRef(!1);Qr(()=>(U.current=!0,()=>{U.current=!1}),[]),Qr(()=>{if(j&&(E.current=j),C&&(S.current=C),j&&C){if(O.current)return O.current(j,C,G);G()}},[j,C,G,O,D]);const X=l.useMemo(()=>({reference:E,floating:S,setReference:w,setFloating:N}),[w,N]),V=l.useMemo(()=>({reference:j,floating:C}),[j,C]),re=l.useMemo(()=>{const L={position:n,left:0,top:0};if(!V.floating)return L;const T=Si(V.floating,h.x),ie=Si(V.floating,h.y);return c?{...L,transform:"translate("+T+"px, "+ie+"px)",...rl(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:ie}},[n,c,V.floating,h.x,h.y]);return l.useMemo(()=>({...h,update:G,refs:X,elements:V,floatingStyles:re}),[h,G,X,V,re])}const wg=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Ci({element:s.current,padding:o}).fn(n):{}:s?Ci({element:s,padding:o}).fn(n):{}}}},jg=(e,t)=>{const n=ug(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ng=(e,t)=>{const n=fg(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cg=(e,t)=>({fn:xg(e).fn,options:[e,t]}),Sg=(e,t)=>{const n=hg(e);return{name:n.name,fn:n.fn,options:[e,t]}},Eg=(e,t)=>{const n=mg(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rg=(e,t)=>{const n=pg(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pg=(e,t)=>{const n=wg(e);return{name:n.name,fn:n.fn,options:[e,t]}};var kg="Arrow",sl=l.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(W.svg,{...a,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});sl.displayName=kg;var Tg=sl;function ol(e){const[t,n]=l.useState(void 0);return Ce(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,c;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;i=d.inlineSize,c=d.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var ha="Popper",[al,tr]=ot(ha),[Ag,il]=al(ha),cl=e=>{const{__scopePopper:t,children:n}=e,[s,o]=l.useState(null);return r.jsx(Ag,{scope:t,anchor:s,onAnchorChange:o,children:n})};cl.displayName=ha;var ll="PopperAnchor",dl=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=il(ll,n),i=l.useRef(null),c=le(t,i),u=l.useRef(null);return l.useEffect(()=>{const d=u.current;u.current=(s==null?void 0:s.current)||i.current,d!==u.current&&a.onAnchorChange(u.current)}),s?null:r.jsx(W.div,{...o,ref:c})});dl.displayName=ll;var ma="PopperContent",[Mg,_g]=al(ma),ul=l.forwardRef((e,t)=>{var A,Q,Y,oe,fe,he;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:v,...p}=e,x=il(ma,n),[y,w]=l.useState(null),N=le(t,_e=>w(_e)),[j,C]=l.useState(null),E=ol(j),S=(E==null?void 0:E.width)??0,P=(E==null?void 0:E.height)??0,D=s+(a!=="center"?"-"+a:""),O=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},$=Array.isArray(d)?d:[d],_=$.length>0,G={padding:O,boundary:$.filter(Og),altBoundary:_},{refs:U,floatingStyles:X,placement:V,isPositioned:re,middlewareData:L}=bg({strategy:"fixed",placement:D,whileElementsMounted:(..._e)=>dg(..._e,{animationFrame:g==="always"}),elements:{reference:x.anchor},middleware:[jg({mainAxis:o+P,alignmentAxis:i}),u&&Ng({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Cg():void 0,...G}),u&&Sg({...G}),Eg({...G,apply:({elements:_e,rects:Ye,availableWidth:rr,availableHeight:sr})=>{const{width:or,height:Lf}=Ye.reference,Dr=_e.floating.style;Dr.setProperty("--radix-popper-available-width",`${rr}px`),Dr.setProperty("--radix-popper-available-height",`${sr}px`),Dr.setProperty("--radix-popper-anchor-width",`${or}px`),Dr.setProperty("--radix-popper-anchor-height",`${Lf}px`)}}),j&&Pg({element:j,padding:c}),Dg({arrowWidth:S,arrowHeight:P}),m&&Rg({strategy:"referenceHidden",...G})]}),[T,ie]=ml(V),ce=st(v);Ce(()=>{re&&(ce==null||ce())},[re,ce]);const R=(A=L.arrow)==null?void 0:A.x,B=(Q=L.arrow)==null?void 0:Q.y,H=((Y=L.arrow)==null?void 0:Y.centerOffset)!==0,[z,Z]=l.useState();return Ce(()=>{y&&Z(window.getComputedStyle(y).zIndex)},[y]),r.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:re?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:z,"--radix-popper-transform-origin":[(oe=L.transformOrigin)==null?void 0:oe.x,(fe=L.transformOrigin)==null?void 0:fe.y].join(" "),...((he=L.hide)==null?void 0:he.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(Mg,{scope:n,placedSide:T,onArrowChange:C,arrowX:R,arrowY:B,shouldHideArrow:H,children:r.jsx(W.div,{"data-side":T,"data-align":ie,...p,ref:N,style:{...p.style,animation:re?void 0:"none"}})})})});ul.displayName=ma;var fl="PopperArrow",Ig={top:"bottom",right:"left",bottom:"top",left:"right"},hl=l.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=_g(fl,s),i=Ig[a.placedSide];return r.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:r.jsx(Tg,{...o,ref:n,style:{...o.style,display:"block"}})})});hl.displayName=fl;function Og(e){return e!==null}var Dg=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:s,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,c=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[d,h]=ml(n),f={start:"0%",center:"50%",end:"100%"}[h],m=(((y=o.arrow)==null?void 0:y.x)??0)+c/2,g=(((w=o.arrow)==null?void 0:w.y)??0)+u/2;let v="",p="";return d==="bottom"?(v=i?f:`${m}px`,p=`${-u}px`):d==="top"?(v=i?f:`${m}px`,p=`${s.floating.height+u}px`):d==="right"?(v=`${-u}px`,p=i?f:`${g}px`):d==="left"&&(v=`${s.floating.width+u}px`,p=i?f:`${g}px`),{data:{x:v,y:p}}}});function ml(e){const[t,n="center"]=e.split("-");return[t,n]}var pa=cl,Ss=dl,xa=ul,ga=hl,zg="Portal",kr=l.forwardRef((e,t)=>{var c;const{container:n,...s}=e,[o,a]=l.useState(!1);Ce(()=>a(!0),[]);const i=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return i?Uf.createPortal(r.jsx(W.div,{...s,ref:t}),i):null});kr.displayName=zg;function Lg(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var Be=e=>{const{present:t,children:n}=e,s=Fg(t),o=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),a=le(s.ref,$g(o));return typeof n=="function"||s.isPresent?l.cloneElement(o,{ref:a}):null};Be.displayName="Presence";function Fg(e){const[t,n]=l.useState(),s=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),i=e?"mounted":"unmounted",[c,u]=Lg(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=Ur(s.current);a.current=c==="mounted"?d:"none"},[c]),Ce(()=>{const d=s.current,h=o.current;if(h!==e){const m=a.current,g=Ur(d);e?u("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(h&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ce(()=>{if(t){let d;const h=t.ownerDocument.defaultView??window,f=g=>{const p=Ur(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&p&&(u("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",d=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=g=>{g.target===t&&(a.current=Ur(s.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{h.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(d=>{s.current=d?getComputedStyle(d):null,n(d)},[])}}function Ur(e){return(e==null?void 0:e.animationName)||"none"}function $g(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ug=Qo[" useInsertionEffect ".trim().toString()]||Ce;function Ut({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,i]=Vg({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:o;{const h=l.useRef(e!==void 0);l.useEffect(()=>{const f=h.current;f!==c&&console.warn(`${s} is changing from ${f?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=c},[c,s])}const d=l.useCallback(h=>{var f;if(c){const m=Bg(h)?h(e):h;m!==e&&((f=i.current)==null||f.call(i,m))}else a(h)},[c,e,a,i]);return[u,d]}function Vg({defaultProp:e,onChange:t}){const[n,s]=l.useState(e),o=l.useRef(n),a=l.useRef(t);return Ug(()=>{a.current=t},[t]),l.useEffect(()=>{var i;o.current!==n&&((i=a.current)==null||i.call(a,n),o.current=n)},[n,o]),[n,s,a]}function Bg(e){return typeof e=="function"}var Kg=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jn=new WeakMap,Vr=new WeakMap,Br={},eo=0,pl=function(e){return e&&(e.host||pl(e.parentNode))},Hg=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=pl(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},qg=function(e,t,n,s){var o=Hg(t,Array.isArray(e)?e:[e]);Br[n]||(Br[n]=new WeakMap);var a=Br[n],i=[],c=new Set,u=new Set(o),d=function(f){!f||c.has(f)||(c.add(f),d(f.parentNode))};o.forEach(d);var h=function(f){!f||u.has(f)||Array.prototype.forEach.call(f.children,function(m){if(c.has(m))h(m);else try{var g=m.getAttribute(s),v=g!==null&&g!=="false",p=(jn.get(m)||0)+1,x=(a.get(m)||0)+1;jn.set(m,p),a.set(m,x),i.push(m),p===1&&v&&Vr.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return h(t),c.clear(),eo++,function(){i.forEach(function(f){var m=jn.get(f)-1,g=a.get(f)-1;jn.set(f,m),a.set(f,g),m||(Vr.has(f)||f.removeAttribute(s),Vr.delete(f)),g||f.removeAttribute(n)}),eo--,eo||(jn=new WeakMap,jn=new WeakMap,Vr=new WeakMap,Br={})}},Es=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Kg(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),qg(s,o,n,"aria-hidden")):function(){return null}},et=function(){return et=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},et.apply(this,arguments)};function xl(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function Wg(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var Yr="right-scroll-bar-position",Xr="width-before-scroll-bar",Gg="with-scroll-bars-hidden",Qg="--removed-body-scroll-bar-size";function to(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Yg(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var Xg=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ei=new WeakMap;function Zg(e,t){var n=Yg(null,function(s){return e.forEach(function(o){return to(o,s)})});return Xg(function(){var s=Ei.get(n);if(s){var o=new Set(s),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||to(c,null)}),a.forEach(function(c){o.has(c)||to(c,i)})}Ei.set(n,e)},[e]),n}function Jg(e){return e}function ev(e,t){t===void 0&&(t=Jg);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,s);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(s=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){s=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var u=function(){var h=i;i=[],h.forEach(a)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(h){i.push(h),d()},filter:function(h){return i=i.filter(h),n}}}};return o}function tv(e){e===void 0&&(e={});var t=ev(null);return t.options=et({async:!0,ssr:!1},e),t}var gl=function(e){var t=e.sideCar,n=xl(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return l.createElement(s,et({},n))};gl.isSideCarExport=!0;function nv(e,t){return e.useMedium(t),gl}var vl=tv(),no=function(){},Rs=l.forwardRef(function(e,t){var n=l.useRef(null),s=l.useState({onScrollCapture:no,onWheelCapture:no,onTouchMoveCapture:no}),o=s[0],a=s[1],i=e.forwardProps,c=e.children,u=e.className,d=e.removeScrollBar,h=e.enabled,f=e.shards,m=e.sideCar,g=e.noRelative,v=e.noIsolation,p=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,N=e.gapMode,j=xl(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,E=Zg([n,t]),S=et(et({},j),o);return l.createElement(l.Fragment,null,h&&l.createElement(C,{sideCar:vl,removeScrollBar:d,shards:f,noRelative:g,noIsolation:v,inert:p,setCallbacks:a,allowPinchZoom:!!x,lockRef:n,gapMode:N}),i?l.cloneElement(l.Children.only(c),et(et({},S),{ref:E})):l.createElement(w,et({},S,{className:u,ref:E}),c))});Rs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Rs.classNames={fullWidth:Xr,zeroRight:Yr};var rv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=rv();return t&&e.setAttribute("nonce",t),e}function ov(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function av(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var iv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=sv())&&(ov(t,n),av(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cv=function(){var e=iv();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},yl=function(){var e=cv(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},lv={left:0,top:0,right:0,gap:0},ro=function(e){return parseInt(e||"",10)||0},dv=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ro(n),ro(s),ro(o)]},uv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return lv;var t=dv(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},fv=yl(),kn="data-scroll-locked",hv=function(e,t,n,s){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
270
+ .`.concat(Gg,` {
271
+ overflow: hidden `).concat(s,`;
272
+ padding-right: `).concat(c,"px ").concat(s,`;
273
+ }
274
+ body[`).concat(kn,`] {
275
+ overflow: hidden `).concat(s,`;
276
+ overscroll-behavior: contain;
277
+ `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
278
+ padding-left: `.concat(o,`px;
279
+ padding-top: `).concat(a,`px;
280
+ padding-right: `).concat(i,`px;
281
+ margin-left:0;
282
+ margin-top:0;
283
+ margin-right: `).concat(c,"px ").concat(s,`;
284
+ `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
285
+ }
286
+
287
+ .`).concat(Yr,` {
288
+ right: `).concat(c,"px ").concat(s,`;
289
+ }
290
+
291
+ .`).concat(Xr,` {
292
+ margin-right: `).concat(c,"px ").concat(s,`;
293
+ }
294
+
295
+ .`).concat(Yr," .").concat(Yr,` {
296
+ right: 0 `).concat(s,`;
297
+ }
298
+
299
+ .`).concat(Xr," .").concat(Xr,` {
300
+ margin-right: 0 `).concat(s,`;
301
+ }
302
+
303
+ body[`).concat(kn,`] {
304
+ `).concat(Qg,": ").concat(c,`px;
305
+ }
306
+ `)},Ri=function(){var e=parseInt(document.body.getAttribute(kn)||"0",10);return isFinite(e)?e:0},mv=function(){l.useEffect(function(){return document.body.setAttribute(kn,(Ri()+1).toString()),function(){var e=Ri()-1;e<=0?document.body.removeAttribute(kn):document.body.setAttribute(kn,e.toString())}},[])},pv=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;mv();var a=l.useMemo(function(){return uv(o)},[o]);return l.createElement(fv,{styles:hv(a,!t,o,n?"":"!important")})},Do=!1;if(typeof window<"u")try{var Kr=Object.defineProperty({},"passive",{get:function(){return Do=!0,!0}});window.addEventListener("test",Kr,Kr),window.removeEventListener("test",Kr,Kr)}catch{Do=!1}var Nn=Do?{passive:!1}:!1,xv=function(e){return e.tagName==="TEXTAREA"},bl=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xv(e)&&n[t]==="visible")},gv=function(e){return bl(e,"overflowY")},vv=function(e){return bl(e,"overflowX")},Pi=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=wl(e,s);if(o){var a=jl(e,s),i=a[1],c=a[2];if(i>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},yv=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},bv=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},wl=function(e,t){return e==="v"?gv(t):vv(t)},jl=function(e,t){return e==="v"?yv(t):bv(t)},wv=function(e,t){return e==="h"&&t==="rtl"?-1:1},jv=function(e,t,n,s,o){var a=wv(e,window.getComputedStyle(t).direction),i=a*s,c=n.target,u=t.contains(c),d=!1,h=i>0,f=0,m=0;do{if(!c)break;var g=jl(e,c),v=g[0],p=g[1],x=g[2],y=p-x-a*v;(v||y)&&wl(e,c)&&(f+=y,m+=v);var w=c.parentNode;c=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(h&&Math.abs(f)<1||!h&&Math.abs(m)<1)&&(d=!0),d},Hr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ki=function(e){return[e.deltaX,e.deltaY]},Ti=function(e){return e&&"current"in e?e.current:e},Nv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Cv=function(e){return`
307
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
308
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
309
+ `)},Sv=0,Cn=[];function Ev(e){var t=l.useRef([]),n=l.useRef([0,0]),s=l.useRef(),o=l.useState(Sv++)[0],a=l.useState(yl)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Wg([e.lockRef.current],(e.shards||[]).map(Ti),!0).filter(Boolean);return p.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(p,x){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var y=Hr(p),w=n.current,N="deltaX"in p?p.deltaX:w[0]-y[0],j="deltaY"in p?p.deltaY:w[1]-y[1],C,E=p.target,S=Math.abs(N)>Math.abs(j)?"h":"v";if("touches"in p&&S==="h"&&E.type==="range")return!1;var P=window.getSelection(),D=P&&P.anchorNode,O=D?D===E||D.contains(E):!1;if(O)return!1;var $=Pi(S,E);if(!$)return!0;if($?C=S:(C=S==="v"?"h":"v",$=Pi(S,E)),!$)return!1;if(!s.current&&"changedTouches"in p&&(N||j)&&(s.current=C),!C)return!0;var _=s.current||C;return jv(_,x,p,_==="h"?N:j)},[]),u=l.useCallback(function(p){var x=p;if(!(!Cn.length||Cn[Cn.length-1]!==a)){var y="deltaY"in x?ki(x):Hr(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&Nv(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var N=(i.current.shards||[]).map(Ti).filter(Boolean).filter(function(C){return C.contains(x.target)}),j=N.length>0?c(x,N[0]):!i.current.noIsolation;j&&x.cancelable&&x.preventDefault()}}},[]),d=l.useCallback(function(p,x,y,w){var N={name:p,delta:x,target:y,should:w,shadowParent:Rv(y)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(j){return j!==N})},1)},[]),h=l.useCallback(function(p){n.current=Hr(p),s.current=void 0},[]),f=l.useCallback(function(p){d(p.type,ki(p),p.target,c(p,e.lockRef.current))},[]),m=l.useCallback(function(p){d(p.type,Hr(p),p.target,c(p,e.lockRef.current))},[]);l.useEffect(function(){return Cn.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",u,Nn),document.addEventListener("touchmove",u,Nn),document.addEventListener("touchstart",h,Nn),function(){Cn=Cn.filter(function(p){return p!==a}),document.removeEventListener("wheel",u,Nn),document.removeEventListener("touchmove",u,Nn),document.removeEventListener("touchstart",h,Nn)}},[]);var g=e.removeScrollBar,v=e.inert;return l.createElement(l.Fragment,null,v?l.createElement(a,{styles:Cv(o)}):null,g?l.createElement(pv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Rv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Pv=nv(vl,Ev);var Tr=l.forwardRef(function(e,t){return l.createElement(Rs,et({},e,{ref:t,sideCar:Pv}))});Tr.classNames=Rs.classNames;var Ps="Popover",[Nl]=ot(Ps,[tr]),Ar=tr(),[kv,Bt]=Nl(Ps),Cl=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,c=Ar(t),u=l.useRef(null),[d,h]=l.useState(!1),[f,m]=Ut({prop:s,defaultProp:o??!1,onChange:a,caller:Ps});return r.jsx(pa,{...c,children:r.jsx(kv,{scope:t,contentId:je(),triggerRef:u,open:f,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:d,onCustomAnchorAdd:l.useCallback(()=>h(!0),[]),onCustomAnchorRemove:l.useCallback(()=>h(!1),[]),modal:i,children:n})})};Cl.displayName=Ps;var Sl="PopoverAnchor",Tv=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,o=Bt(Sl,n),a=Ar(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:c}=o;return l.useEffect(()=>(i(),()=>c()),[i,c]),r.jsx(Ss,{...a,...s,ref:t})});Tv.displayName=Sl;var El="PopoverTrigger",Rl=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,o=Bt(El,n),a=Ar(n),i=le(t,o.triggerRef),c=r.jsx(W.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ml(o.open),...s,ref:i,onClick:I(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:r.jsx(Ss,{asChild:!0,...a,children:c})});Rl.displayName=El;var va="PopoverPortal",[Av,Mv]=Nl(va,{forceMount:void 0}),Pl=e=>{const{__scopePopover:t,forceMount:n,children:s,container:o}=e,a=Bt(va,t);return r.jsx(Av,{scope:t,forceMount:n,children:r.jsx(Be,{present:n||a.open,children:r.jsx(kr,{asChild:!0,container:o,children:s})})})};Pl.displayName=va;var Hn="PopoverContent",kl=l.forwardRef((e,t)=>{const n=Mv(Hn,e.__scopePopover),{forceMount:s=n.forceMount,...o}=e,a=Bt(Hn,e.__scopePopover);return r.jsx(Be,{present:s||a.open,children:a.modal?r.jsx(Iv,{...o,ref:t}):r.jsx(Ov,{...o,ref:t})})});kl.displayName=Hn;var _v=un("PopoverContent.RemoveScroll"),Iv=l.forwardRef((e,t)=>{const n=Bt(Hn,e.__scopePopover),s=l.useRef(null),o=le(t,s),a=l.useRef(!1);return l.useEffect(()=>{const i=s.current;if(i)return Es(i)},[]),r.jsx(Tr,{as:_v,allowPinchZoom:!0,children:r.jsx(Tl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:I(e.onCloseAutoFocus,i=>{var c;i.preventDefault(),a.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:I(e.onPointerDownOutside,i=>{const c=i.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:I(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ov=l.forwardRef((e,t)=>{const n=Bt(Hn,e.__scopePopover),s=l.useRef(!1),o=l.useRef(!1);return r.jsx(Tl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Tl=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,...f}=e,m=Bt(Hn,n),g=Ar(n);return bs(),r.jsx(Rr,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(Er,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:r.jsx(xa,{"data-state":Ml(m.open),role:"dialog",id:m.contentId,...g,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Al="PopoverClose",Dv=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,o=Bt(Al,n);return r.jsx(W.button,{type:"button",...s,ref:t,onClick:I(e.onClick,()=>o.onOpenChange(!1))})});Dv.displayName=Al;var zv="PopoverArrow",Lv=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,o=Ar(n);return r.jsx(ga,{...o,...s,ref:t})});Lv.displayName=zv;function Ml(e){return e?"open":"closed"}var Fv=Cl,$v=Rl,Uv=Pl,_l=kl;const Vv=Fv,Bv=$v,Il=l.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},o)=>r.jsx(Uv,{children:r.jsx(_l,{ref:o,align:t,sideOffset:n,className:k("z-50 w-72 rounded-md border border-zinc-200 bg-white p-4 text-zinc-900 shadow-md outline-none","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",e),...s})}));Il.displayName=_l.displayName;const Ai=e=>{let t;const n=new Set,s=(d,h)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const m=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,m))}},o=()=>t,c={setState:s,getState:o,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=t=e(s,o,c);return c},Kv=e=>e?Ai(e):Ai,Hv=e=>e;function qv(e,t=Hv){const n=qe.useSyncExternalStore(e.subscribe,qe.useCallback(()=>t(e.getState()),[e,t]),qe.useCallback(()=>t(e.getInitialState()),[e,t]));return qe.useDebugValue(n),n}const Mi=e=>{const t=Kv(e),n=s=>qv(t,s);return Object.assign(n,t),n},ya=e=>e?Mi(e):Mi,Ol=ya(e=>({notifications:[],unreadCount:0,pushNotification:t=>{const n={...t,id:crypto.randomUUID(),at:new Date().toISOString(),read:!1};e(s=>({notifications:[n,...s.notifications].slice(0,50),unreadCount:s.unreadCount+1}))},markAllRead:()=>{e(t=>({notifications:t.notifications.map(n=>({...n,read:!0})),unreadCount:0}))},clearAll:()=>{e({notifications:[],unreadCount:0})}}));function wt(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}function Wv(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function it(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),o=Math.floor(s/1e3),a=Math.floor(o/60),i=Math.floor(a/60),c=Math.floor(i/24);return o<30?"just now":o<60?`${o}s ago`:a<60?`${a}m ago`:i<24?`${i}h ago`:c===1?"yesterday":c<7?`${c} days ago`:c<30?`${Math.floor(c/7)}w ago`:Wv(e)}function Gv({type:e}){return e==="error"?r.jsx(Vm,{className:"h-4 w-4 text-red-500"}):e==="warning"?r.jsx(as,{className:"h-4 w-4 text-amber-500"}):r.jsx(Xm,{className:"h-4 w-4 text-blue-500"})}function Qv(){const{notifications:e,unreadCount:t,markAllRead:n}=Ol(),s=e.slice(0,10);return r.jsxs(Vv,{children:[r.jsx(Bv,{asChild:!0,children:r.jsxs(ue,{variant:"ghost",size:"icon","aria-label":"Notifications",className:"relative text-zinc-500 hover:text-zinc-700",children:[r.jsx(Lm,{className:"h-4 w-4"}),t>0&&r.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white",children:t>9?"9+":t})]})}),r.jsxs(Il,{align:"end",className:"w-80 p-0",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsx("span",{className:"text-sm font-semibold text-zinc-900",children:"Notifications"}),t>0&&r.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 font-medium",children:[r.jsx(Yn,{className:"h-3 w-3"}),"Mark all read"]})]}),r.jsx("div",{className:"max-h-80 overflow-y-auto",children:s.length===0?r.jsx("div",{className:"py-8 text-center text-sm text-zinc-400",children:"No notifications"}):s.map(o=>r.jsxs("div",{className:k("flex gap-3 border-b border-zinc-50 px-4 py-3 last:border-0",!o.read&&"bg-blue-50/30"),children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx(Gv,{type:o.type})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-zinc-900",children:o.title}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500 line-clamp-2",children:o.message}),r.jsx("p",{className:"mt-1 text-[10px] text-zinc-400",children:it(o.at)})]}),!o.read&&r.jsx("div",{className:"mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"})]},o.id))})]})]})}var _i=1,Yv=.9,Xv=.8,Zv=.17,so=.1,oo=.999,Jv=.9999,e0=.99,t0=/[\\\/_+.#"@\[\(\{&]/,n0=/[\\\/_+.#"@\[\(\{&]/g,r0=/[\s-]/,Dl=/[\s-]/g;function zo(e,t,n,s,o,a,i){if(a===t.length)return o===e.length?_i:e0;var c=`${o},${a}`;if(i[c]!==void 0)return i[c];for(var u=s.charAt(a),d=n.indexOf(u,o),h=0,f,m,g,v;d>=0;)f=zo(e,t,n,s,d+1,a+1,i),f>h&&(d===o?f*=_i:t0.test(e.charAt(d-1))?(f*=Xv,g=e.slice(o,d-1).match(n0),g&&o>0&&(f*=Math.pow(oo,g.length))):r0.test(e.charAt(d-1))?(f*=Yv,v=e.slice(o,d-1).match(Dl),v&&o>0&&(f*=Math.pow(oo,v.length))):(f*=Zv,o>0&&(f*=Math.pow(oo,d-o))),e.charAt(d)!==t.charAt(a)&&(f*=Jv)),(f<so&&n.charAt(d-1)===s.charAt(a+1)||s.charAt(a+1)===s.charAt(a)&&n.charAt(d-1)!==s.charAt(a))&&(m=zo(e,t,n,s,d+1,a+2,i),m*so>f&&(f=m*so)),f>h&&(h=f),d=n.indexOf(u,d+1);return i[c]=h,h}function Ii(e){return e.toLowerCase().replace(Dl," ")}function s0(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,zo(e,t,Ii(e),Ii(t),0,0,{})}var ks="Dialog",[zl]=ot(ks),[o0,Qe]=zl(ks),Ll=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),u=l.useRef(null),[d,h]=Ut({prop:s,defaultProp:o??!1,onChange:a,caller:ks});return r.jsx(o0,{scope:t,triggerRef:c,contentRef:u,contentId:je(),titleId:je(),descriptionId:je(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(f=>!f),[h]),modal:i,children:n})};Ll.displayName=ks;var Fl="DialogTrigger",a0=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Qe(Fl,n),a=le(t,o.triggerRef);return r.jsx(W.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ja(o.open),...s,ref:a,onClick:I(e.onClick,o.onOpenToggle)})});a0.displayName=Fl;var ba="DialogPortal",[i0,$l]=zl(ba,{forceMount:void 0}),Ul=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=Qe(ba,t);return r.jsx(i0,{scope:t,forceMount:n,children:l.Children.map(s,i=>r.jsx(Be,{present:n||a.open,children:r.jsx(kr,{asChild:!0,container:o,children:i})}))})};Ul.displayName=ba;var us="DialogOverlay",Vl=l.forwardRef((e,t)=>{const n=$l(us,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Qe(us,e.__scopeDialog);return a.modal?r.jsx(Be,{present:s||a.open,children:r.jsx(l0,{...o,ref:t})}):null});Vl.displayName=us;var c0=un("DialogOverlay.RemoveScroll"),l0=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Qe(us,n);return r.jsx(Tr,{as:c0,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(W.div,{"data-state":ja(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),hn="DialogContent",Bl=l.forwardRef((e,t)=>{const n=$l(hn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Qe(hn,e.__scopeDialog);return r.jsx(Be,{present:s||a.open,children:a.modal?r.jsx(d0,{...o,ref:t}):r.jsx(u0,{...o,ref:t})})});Bl.displayName=hn;var d0=l.forwardRef((e,t)=>{const n=Qe(hn,e.__scopeDialog),s=l.useRef(null),o=le(t,n.contentRef,s);return l.useEffect(()=>{const a=s.current;if(a)return Es(a)},[]),r.jsx(Kl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:I(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:I(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:I(e.onFocusOutside,a=>a.preventDefault())})}),u0=l.forwardRef((e,t)=>{const n=Qe(hn,e.__scopeDialog),s=l.useRef(!1),o=l.useRef(!1);return r.jsx(Kl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Kl=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Qe(hn,n),u=l.useRef(null),d=le(t,u);return bs(),r.jsxs(r.Fragment,{children:[r.jsx(Rr,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(Er,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ja(c.open),...i,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(f0,{titleId:c.titleId}),r.jsx(m0,{contentRef:u,descriptionId:c.descriptionId})]})]})}),wa="DialogTitle",Hl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Qe(wa,n);return r.jsx(W.h2,{id:o.titleId,...s,ref:t})});Hl.displayName=wa;var ql="DialogDescription",Wl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Qe(ql,n);return r.jsx(W.p,{id:o.descriptionId,...s,ref:t})});Wl.displayName=ql;var Gl="DialogClose",Ql=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Qe(Gl,n);return r.jsx(W.button,{type:"button",...s,ref:t,onClick:I(e.onClick,()=>o.onOpenChange(!1))})});Ql.displayName=Gl;function ja(e){return e?"open":"closed"}var Yl="DialogTitleWarning",[aN,Xl]=ex(Yl,{contentName:hn,titleName:wa,docsSlug:"dialog"}),f0=({titleId:e})=>{const t=Xl(Yl),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
310
+
311
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
312
+
313
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},h0="DialogDescriptionWarning",m0=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xl(h0).contentName}}.`;return l.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Na=Ll,Ca=Ul,Ts=Vl,As=Bl,Sa=Hl,Ea=Wl,Zl=Ql,p0=Symbol.for("react.lazy"),fs=Qo[" use ".trim().toString()];function x0(e){return typeof e=="object"&&e!==null&&"then"in e}function Jl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===p0&&"_payload"in e&&x0(e._payload)}function g0(e){const t=v0(e),n=l.forwardRef((s,o)=>{let{children:a,...i}=s;Jl(a)&&typeof fs=="function"&&(a=fs(a._payload));const c=l.Children.toArray(a),u=c.find(b0);if(u){const d=u.props.children,h=c.map(f=>f===u?l.Children.count(d)>1?l.Children.only(null):l.isValidElement(d)?d.props.children:null:f);return r.jsx(t,{...i,ref:o,children:l.isValidElement(d)?l.cloneElement(d,void 0,h):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function v0(e){const t=l.forwardRef((n,s)=>{let{children:o,...a}=n;if(Jl(o)&&typeof fs=="function"&&(o=fs(o._payload)),l.isValidElement(o)){const i=j0(o),c=w0(a,o.props);return o.type!==l.Fragment&&(c.ref=s?rt(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var y0=Symbol("radix.slottable");function b0(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===y0}function w0(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const u=a(...c);return o(...c),u}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function j0(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var N0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],jt=N0.reduce((e,t)=>{const n=g0(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),cr='[cmdk-group=""]',ao='[cmdk-group-items=""]',C0='[cmdk-group-heading=""]',ed='[cmdk-item=""]',Oi=`${ed}:not([aria-disabled="true"])`,Lo="cmdk-item-select",Sn="data-value",S0=(e,t,n)=>s0(e,t,n),td=l.createContext(void 0),Mr=()=>l.useContext(td),nd=l.createContext(void 0),Ra=()=>l.useContext(nd),rd=l.createContext(void 0),sd=l.forwardRef((e,t)=>{let n=En(()=>{var R,B;return{search:"",value:(B=(R=e.value)!=null?R:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=En(()=>new Set),o=En(()=>new Map),a=En(()=>new Map),i=En(()=>new Set),c=od(e),{label:u,children:d,value:h,onValueChange:f,filter:m,shouldFilter:g,loop:v,disablePointerSelection:p=!1,vimBindings:x=!0,...y}=e,w=je(),N=je(),j=je(),C=l.useRef(null),E=D0();mn(()=>{if(h!==void 0){let R=h.trim();n.current.value=R,S.emit()}},[h]),mn(()=>{E(6,G)},[]);let S=l.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,B,H)=>{var z,Z,A,Q;if(!Object.is(n.current[R],B)){if(n.current[R]=B,R==="search")_(),O(),E(1,$);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(j);Y?Y.focus():(z=document.getElementById(w))==null||z.focus()}if(E(7,()=>{var Y;n.current.selectedItemId=(Y=U())==null?void 0:Y.id,S.emit()}),H||E(5,G),((Z=c.current)==null?void 0:Z.value)!==void 0){let Y=B??"";(Q=(A=c.current).onValueChange)==null||Q.call(A,Y);return}}S.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),P=l.useMemo(()=>({value:(R,B,H)=>{var z;B!==((z=a.current.get(R))==null?void 0:z.value)&&(a.current.set(R,{value:B,keywords:H}),n.current.filtered.items.set(R,D(B,H)),E(2,()=>{O(),S.emit()}))},item:(R,B)=>(s.current.add(R),B&&(o.current.has(B)?o.current.get(B).add(R):o.current.set(B,new Set([R]))),E(3,()=>{_(),O(),n.current.value||$(),S.emit()}),()=>{a.current.delete(R),s.current.delete(R),n.current.filtered.items.delete(R);let H=U();E(4,()=>{_(),(H==null?void 0:H.getAttribute("id"))===R&&$(),S.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{a.current.delete(R),o.current.delete(R)}),filter:()=>c.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:w,inputId:j,labelId:N,listInnerRef:C}),[]);function D(R,B){var H,z;let Z=(z=(H=c.current)==null?void 0:H.filter)!=null?z:S0;return R?Z(R,n.current.search,B):0}function O(){if(!n.current.search||c.current.shouldFilter===!1)return;let R=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(z=>{let Z=o.current.get(z),A=0;Z.forEach(Q=>{let Y=R.get(Q);A=Math.max(Y,A)}),B.push([z,A])});let H=C.current;X().sort((z,Z)=>{var A,Q;let Y=z.getAttribute("id"),oe=Z.getAttribute("id");return((A=R.get(oe))!=null?A:0)-((Q=R.get(Y))!=null?Q:0)}).forEach(z=>{let Z=z.closest(ao);Z?Z.appendChild(z.parentElement===Z?z:z.closest(`${ao} > *`)):H.appendChild(z.parentElement===H?z:z.closest(`${ao} > *`))}),B.sort((z,Z)=>Z[1]-z[1]).forEach(z=>{var Z;let A=(Z=C.current)==null?void 0:Z.querySelector(`${cr}[${Sn}="${encodeURIComponent(z[0])}"]`);A==null||A.parentElement.appendChild(A)})}function $(){let R=X().find(H=>H.getAttribute("aria-disabled")!=="true"),B=R==null?void 0:R.getAttribute(Sn);S.setState("value",B||void 0)}function _(){var R,B,H,z;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let Z=0;for(let A of s.current){let Q=(B=(R=a.current.get(A))==null?void 0:R.value)!=null?B:"",Y=(z=(H=a.current.get(A))==null?void 0:H.keywords)!=null?z:[],oe=D(Q,Y);n.current.filtered.items.set(A,oe),oe>0&&Z++}for(let[A,Q]of o.current)for(let Y of Q)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(A);break}n.current.filtered.count=Z}function G(){var R,B,H;let z=U();z&&(((R=z.parentElement)==null?void 0:R.firstChild)===z&&((H=(B=z.closest(cr))==null?void 0:B.querySelector(C0))==null||H.scrollIntoView({block:"nearest"})),z.scrollIntoView({block:"nearest"}))}function U(){var R;return(R=C.current)==null?void 0:R.querySelector(`${ed}[aria-selected="true"]`)}function X(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(Oi))||[])}function V(R){let B=X()[R];B&&S.setState("value",B.getAttribute(Sn))}function re(R){var B;let H=U(),z=X(),Z=z.findIndex(Q=>Q===H),A=z[Z+R];(B=c.current)!=null&&B.loop&&(A=Z+R<0?z[z.length-1]:Z+R===z.length?z[0]:z[Z+R]),A&&S.setState("value",A.getAttribute(Sn))}function L(R){let B=U(),H=B==null?void 0:B.closest(cr),z;for(;H&&!z;)H=R>0?I0(H,cr):O0(H,cr),z=H==null?void 0:H.querySelector(Oi);z?S.setState("value",z.getAttribute(Sn)):re(R)}let T=()=>V(X().length-1),ie=R=>{R.preventDefault(),R.metaKey?T():R.altKey?L(1):re(1)},ce=R=>{R.preventDefault(),R.metaKey?V(0):R.altKey?L(-1):re(-1)};return l.createElement(jt.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var B;(B=y.onKeyDown)==null||B.call(y,R);let H=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||H))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&ie(R);break}case"ArrowDown":{ie(R);break}case"p":case"k":{x&&R.ctrlKey&&ce(R);break}case"ArrowUp":{ce(R);break}case"Home":{R.preventDefault(),V(0);break}case"End":{R.preventDefault(),T();break}case"Enter":{R.preventDefault();let z=U();if(z){let Z=new Event(Lo);z.dispatchEvent(Z)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:L0},u),Ms(e,R=>l.createElement(nd.Provider,{value:S},l.createElement(td.Provider,{value:P},R))))}),E0=l.forwardRef((e,t)=>{var n,s;let o=je(),a=l.useRef(null),i=l.useContext(rd),c=Mr(),u=od(e),d=(s=(n=u.current)==null?void 0:n.forceMount)!=null?s:i==null?void 0:i.forceMount;mn(()=>{if(!d)return c.item(o,i==null?void 0:i.id)},[d]);let h=ad(o,a,[e.value,e.children,a],e.keywords),f=Ra(),m=Vt(E=>E.value&&E.value===h.current),g=Vt(E=>d||c.filter()===!1?!0:E.search?E.filtered.items.get(o)>0:!0);l.useEffect(()=>{let E=a.current;if(!(!E||e.disabled))return E.addEventListener(Lo,v),()=>E.removeEventListener(Lo,v)},[g,e.onSelect,e.disabled]);function v(){var E,S;p(),(S=(E=u.current).onSelect)==null||S.call(E,h.current)}function p(){f.setState("value",h.current,!0)}if(!g)return null;let{disabled:x,value:y,onSelect:w,forceMount:N,keywords:j,...C}=e;return l.createElement(jt.div,{ref:rt(a,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||c.getDisablePointerSelection()?void 0:p,onClick:x?void 0:v},e.children)}),R0=l.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:o,...a}=e,i=je(),c=l.useRef(null),u=l.useRef(null),d=je(),h=Mr(),f=Vt(g=>o||h.filter()===!1?!0:g.search?g.filtered.groups.has(i):!0);mn(()=>h.group(i),[]),ad(i,c,[e.value,e.heading,u]);let m=l.useMemo(()=>({id:i,forceMount:o}),[o]);return l.createElement(jt.div,{ref:rt(c,t),...a,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&l.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),Ms(e,g=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},l.createElement(rd.Provider,{value:m},g))))}),P0=l.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,o=l.useRef(null),a=Vt(i=>!i.search);return!n&&!a?null:l.createElement(jt.div,{ref:rt(o,t),...s,"cmdk-separator":"",role:"separator"})}),k0=l.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,o=e.value!=null,a=Ra(),i=Vt(d=>d.search),c=Vt(d=>d.selectedItemId),u=Mr();return l.useEffect(()=>{e.value!=null&&a.setState("search",e.value)},[e.value]),l.createElement(jt.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":c,id:u.inputId,type:"text",value:o?e.value:i,onChange:d=>{o||a.setState("search",d.target.value),n==null||n(d.target.value)}})}),T0=l.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...o}=e,a=l.useRef(null),i=l.useRef(null),c=Vt(d=>d.selectedItemId),u=Mr();return l.useEffect(()=>{if(i.current&&a.current){let d=i.current,h=a.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let g=d.offsetHeight;h.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(f),m.unobserve(d)}}},[]),l.createElement(jt.div,{ref:rt(a,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":s,id:u.listId},Ms(e,d=>l.createElement("div",{ref:rt(i,u.listInnerRef),"cmdk-list-sizer":""},d)))}),A0=l.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:o,contentClassName:a,container:i,...c}=e;return l.createElement(Na,{open:n,onOpenChange:s},l.createElement(Ca,{container:i},l.createElement(Ts,{"cmdk-overlay":"",className:o}),l.createElement(As,{"aria-label":e.label,"cmdk-dialog":"",className:a},l.createElement(sd,{ref:t,...c}))))}),M0=l.forwardRef((e,t)=>Vt(n=>n.filtered.count===0)?l.createElement(jt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),_0=l.forwardRef((e,t)=>{let{progress:n,children:s,label:o="Loading...",...a}=e;return l.createElement(jt.div,{ref:t,...a,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ms(e,i=>l.createElement("div",{"aria-hidden":!0},i)))}),Me=Object.assign(sd,{List:T0,Item:E0,Input:k0,Group:R0,Separator:P0,Dialog:A0,Empty:M0,Loading:_0});function I0(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function O0(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function od(e){let t=l.useRef(e);return mn(()=>{t.current=e}),t}var mn=typeof window>"u"?l.useEffect:l.useLayoutEffect;function En(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Vt(e){let t=Ra(),n=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,n,n)}function ad(e,t,n,s=[]){let o=l.useRef(),a=Mr();return mn(()=>{var i;let c=(()=>{var d;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(d=h.current.textContent)==null?void 0:d.trim():o.current}})(),u=s.map(d=>d.trim());a.value(e,c,u),(i=t.current)==null||i.setAttribute(Sn,c),o.current=c}),o}var D0=()=>{let[e,t]=l.useState(),n=En(()=>new Map);return mn(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,o)=>{n.current.set(s,o),t({})}};function z0(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ms({asChild:e,children:t},n){return e&&l.isValidElement(t)?l.cloneElement(z0(t),{ref:t.ref},n(t.props.children)):n(t)}var L0={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const id=Na,F0=Ca,cd=l.forwardRef(({className:e,...t},n)=>r.jsx(Ts,{ref:n,className:k("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));cd.displayName=Ts.displayName;const Pa=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(F0,{children:[r.jsx(cd,{}),r.jsxs(As,{ref:s,className:k("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-zinc-200 bg-white 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%]","rounded-lg",e),...n,children:[t,r.jsxs(Zl,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-500",children:[r.jsx(vs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pa.displayName=As.displayName;const ld=({className:e,...t})=>r.jsx("div",{className:k("flex flex-col space-y-1.5 text-left",e),...t});ld.displayName="DialogHeader";const dd=({className:e,...t})=>r.jsx("div",{className:k("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});dd.displayName="DialogFooter";const ud=l.forwardRef(({className:e,...t},n)=>r.jsx(Sa,{ref:n,className:k("text-lg font-semibold leading-none tracking-tight",e),...t}));ud.displayName=Sa.displayName;const $0=l.forwardRef(({className:e,...t},n)=>r.jsx(Ea,{ref:n,className:k("text-sm text-zinc-500",e),...t}));$0.displayName=Ea.displayName;const fd=l.forwardRef(({className:e,...t},n)=>r.jsx(Me,{ref:n,className:k("flex h-full w-full flex-col overflow-hidden rounded-md bg-white text-zinc-900",e),...t}));fd.displayName=Me.displayName;const U0=({children:e,...t})=>r.jsx(id,{...t,children:r.jsx(Pa,{className:"overflow-hidden p-0 shadow-2xl max-w-2xl",children:r.jsx(fd,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-zinc-500 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),hd=l.forwardRef(({className:e,...t},n)=>r.jsxs("div",{className:"flex items-center border-b border-zinc-200 px-3","cmdk-input-wrapper":"",children:[r.jsx(Xn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(Me.Input,{ref:n,className:k("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-zinc-400 disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));hd.displayName=Me.Input.displayName;const md=l.forwardRef(({className:e,...t},n)=>r.jsx(Me.List,{ref:n,className:k("max-h-[400px] overflow-y-auto overflow-x-hidden",e),...t}));md.displayName=Me.List.displayName;const pd=l.forwardRef((e,t)=>r.jsx(Me.Empty,{ref:t,className:"py-6 text-center text-sm text-zinc-500",...e}));pd.displayName=Me.Empty.displayName;const Zr=l.forwardRef(({className:e,...t},n)=>r.jsx(Me.Group,{ref:n,className:k("overflow-hidden p-1 text-zinc-900 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider [&_[cmdk-group-heading]]:text-zinc-500",e),...t}));Zr.displayName=Me.Group.displayName;const Fo=l.forwardRef(({className:e,...t},n)=>r.jsx(Me.Separator,{ref:n,className:k("-mx-1 h-px bg-zinc-100",e),...t}));Fo.displayName=Me.Separator.displayName;const Jr=l.forwardRef(({className:e,...t},n)=>r.jsx(Me.Item,{ref:n,className:k("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","data-[disabled=true]:pointer-events-none data-[selected=true]:bg-zinc-100 data-[selected=true]:text-zinc-900 data-[disabled=true]:opacity-50","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));Jr.displayName=Me.Item.displayName;const xd=ya(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(t=>({isOpen:!t.isOpen}))}));function V0(e){return Ae({queryKey:["search",e],queryFn:()=>ae.get("/api/admin/search",{q:e}),enabled:e.length>=2,staleTime:1e4})}function B0(e,t){const[n,s]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>s(e),t);return()=>clearTimeout(o)},[e,t]),n}function K0(){const{isOpen:e,close:t}=xd(),n=yt(),[s,o]=l.useState(""),a=B0(s,300),{data:i}=V0(a),c=l.useCallback(u=>{t(),u()},[t]);return r.jsxs(U0,{open:e,onOpenChange:u=>!u&&t(),children:[r.jsx(hd,{placeholder:"Search orders, products, customers...",value:s,onValueChange:o,"data-testid":q("search","input")}),r.jsxs(md,{"data-testid":q("search"),children:[r.jsx(pd,{children:a.length<2?r.jsx("span",{className:"text-zinc-400",children:"Type at least 2 characters to search"}):r.jsxs("span",{children:['No results for "',a,'"']})}),(i==null?void 0:i.orders)&&i.orders.length>0&&r.jsx(Zr,{heading:"Orders",children:i.orders.slice(0,5).map(u=>r.jsxs(Jr,{value:`order-${u.orderNumber}`,onSelect:()=>c(()=>n(`/orders/${u.orderNumber}`)),children:[r.jsx(Bn,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("span",{className:"font-mono text-sm font-medium",children:["#",u.orderNumber]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:u.email})]})]},u.id))}),(i==null?void 0:i.products)&&i.products.length>0&&r.jsxs(r.Fragment,{children:[i.orders&&i.orders.length>0&&r.jsx(Fo,{}),r.jsx(Zr,{heading:"Products",children:i.products.slice(0,5).map(u=>r.jsxs(Jr,{value:`product-${u.id}`,onSelect:()=>c(()=>n(`/products/${u.slug}`)),children:[r.jsx(dn,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsx("span",{className:"text-sm font-medium truncate",children:u.name}),r.jsx("span",{className:"text-xs text-zinc-500 capitalize",children:u.status})]})]},u.id))})]}),(i==null?void 0:i.customers)&&i.customers.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Fo,{}),r.jsx(Zr,{heading:"Customers",children:i.customers.slice(0,5).map(u=>r.jsxs(Jr,{value:`customer-${u.id}`,onSelect:()=>c(()=>n(`/customers/${u.id}`)),children:[r.jsx(oa,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("span",{className:"text-sm font-medium",children:[u.firstName," ",u.lastName]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:u.email})]})]},u.id))})]})]})]})}function H0(){const{open:e}=xd();return l.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="k"&&(n.preventDefault(),e())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),r.jsxs("button",{onClick:e,className:"flex items-center gap-2 rounded-md border border-zinc-200 bg-white px-3 py-1.5 text-sm text-zinc-500 hover:border-zinc-300 hover:text-zinc-700 transition-colors","data-testid":q("search","trigger"),children:[r.jsx(Xn,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"hidden sm:inline",children:"Search"}),r.jsxs("kbd",{className:"hidden sm:inline-flex items-center gap-1 rounded border border-zinc-200 bg-zinc-50 px-1.5 text-[10px] font-medium text-zinc-400",children:[r.jsx("span",{children:"⌘"}),"K"]})]})}const gd=["orders","list"],Wt=e=>e===void 0;function vd(e,t){return Wt(e.status)||e.status===t.status}function q0(e,t){return vd(e,t)&&Wt(e.q)&&Wt(e.dateFrom)&&Wt(e.dateTo)&&Wt(e.customer)&&(Wt(e.offset)||e.offset===0)&&(Wt(e.sort)||e.sort==="createdAt:desc")}function W0(e,t){for(const n of e.getQueryCache().findAll({queryKey:gd})){const s=n.queryKey[2]??{};if(!vd(s,t))continue;const o=e.getQueryData(n.queryKey);if(o&&q0(s,t)){const a=[t,...o.filter(i=>i.id!==t.id)];e.setQueryData(n.queryKey,a.slice(0,s.limit??a.length))}else e.invalidateQueries({queryKey:n.queryKey,exact:!0})}}function G0(e){const t=Ol.getState().pushNotification;function n(s){switch(s.type){case"order.placed.v1":{const{order:o}=s.payload;W0(e,o),e.invalidateQueries({queryKey:["dashboard"]}),t({type:"info",title:"New Order",message:`Order #${o.orderNumber} placed by ${o.email}`});break}case"order.paid.v1":case"order.fulfilled.v1":case"order.shipped.v1":case"order.delivered.v1":case"order.cancelled.v1":case"order.refunded.v1":case"order.partially_refunded.v1":{e.invalidateQueries({queryKey:gd}),e.invalidateQueries({queryKey:["orders","detail"]}),e.invalidateQueries({queryKey:["dashboard"]});break}case"inventory.changed.v1":{e.invalidateQueries({queryKey:["inventory","list"]});break}case"inventory.low_stock.v1":{const{variantId:o,currentQty:a,threshold:i}=s.payload;t({type:"warning",title:"Low Stock Alert",message:`Variant ${o} is running low: ${a} left (threshold ${i})`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"inventory.out_of_stock.v1":{t({type:"error",title:"Out of Stock",message:`Variant ${s.payload.variantId} is out of stock`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"payment.failed.v1":{const{orderId:o,reason:a}=s.payload;t({type:"error",title:"Payment Failed",message:`Payment failed for order ${o}: ${a}`});break}case"adapter.error.v1":{const{adapterType:o,adapterName:a,error:i}=s.payload;t({type:"error",title:"Adapter Error",message:`${o} adapter ${a}: ${i.message}`});break}}}return function(o,a){n({type:o,payload:a})}}const yd=ya(e=>({events:[],pushEvent:(t,n)=>{const s={id:crypto.randomUUID(),type:t,label:n,at:new Date().toISOString()};e(o=>({events:[s,...o.events].slice(0,20)}))}}));function Q0(e){return e.includes("error")||e.includes("failed")||e.includes("out_of_stock")?"bg-red-500/10 text-red-500 border-red-500/20":e.includes("low_stock")||e.includes("warning")?"bg-amber-500/10 text-amber-600 border-amber-500/20":e.includes("placed")||e.includes("paid")?"bg-green-500/10 text-green-600 border-green-500/20":"bg-zinc-100 text-zinc-600 border-zinc-200"}function Y0(){const e=yd(s=>s.events),t=l.useRef(null),n=e.slice(0,3);return l.useEffect(()=>{t.current&&e.length>0&&(t.current.scrollLeft=0)},[e.length]),n.length===0?r.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),r.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400",children:"Live"})]}),r.jsx("span",{className:"text-zinc-300",children:"—"}),r.jsx("span",{className:"text-zinc-400",children:"No recent events"})]}):r.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",ref:t,children:[r.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),r.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400 shrink-0",children:"Live"})]}),r.jsx("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:n.map(s=>r.jsx("span",{className:k("flex shrink-0 items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium whitespace-nowrap",Q0(s.type)),children:s.label},s.id))})]})}function X0({navOpen:e,onToggleNav:t}){return r.jsxs(r.Fragment,{children:[r.jsxs("header",{className:"fixed left-0 right-0 top-0 z-30 flex h-14 items-center border-b border-zinc-200 bg-white px-3 sm:px-5 md:left-60",children:[r.jsx("button",{type:"button","data-testid":q("nav","toggle"),"aria-label":"Navigation","aria-controls":"admin-sidebar","aria-expanded":e,onClick:t,className:"mr-2 rounded p-1.5 text-zinc-600 hover:bg-zinc-100 md:hidden",children:r.jsx(tp,{className:"h-5 w-5"})}),r.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:r.jsx(Zp,{})}),r.jsx("div",{className:"mx-8 hidden flex-1 items-center justify-center overflow-hidden md:flex",children:r.jsx(Y0,{})}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(H0,{}),r.jsx(Qv,{})]})]}),r.jsx(K0,{})]})}const Di=[1e3,2e3,5e3,1e4,3e4];function Z0(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"payload"in t)return t.payload}catch{}}function J0(e){let t=null,n=0,s=null,o=!1;async function a(){return(await ae.post("/api/admin/events/ticket")).ticket}function i(){if(o)return;const u=Di[Math.min(n,Di.length-1)]??3e4;n++,s=setTimeout(()=>{c()},u)}async function c(){if(!o)try{const u=await a();if(o)return;t=new EventSource(`/api/admin/events?ticket=${encodeURIComponent(u)}`),t.onopen=()=>{n=0};for(const d of wm)t.addEventListener(d,h=>{const f=Z0(h.data);f!==void 0&&e(d,f)});t.onerror=()=>{t==null||t.close(),t=null,i()}}catch{i()}}return{connect(){o=!1,c()},disconnect(){o=!0,s!==null&&(clearTimeout(s),s=null),t==null||t.close(),t=null}}}function ey(e){switch(e.type){case"order.placed.v1":return`New order #${e.payload.order.orderNumber}`;case"order.paid.v1":return"Payment received";case"order.shipped.v1":return`Order shipped (${e.payload.carrier})`;case"order.delivered.v1":return"Order delivered";case"inventory.low_stock.v1":return`Low stock: ${e.payload.currentQty} left`;case"inventory.out_of_stock.v1":return"Out of stock";case"payment.failed.v1":return"Payment failed";default:return e.type.replace(/\./g," ").replace(/v\d+$/,"").trim()}}function ty({children:e}){const t=be(),n=l.useRef(null),s=yd(o=>o.pushEvent);return l.useEffect(()=>{if(!ss())return;const o=G0(t),a=J0((i,c)=>{o(i,c),s(i,ey({type:i,payload:c}))});return n.current=a,a.connect(),()=>{a.disconnect(),n.current=null}},[t,s]),r.jsx(r.Fragment,{children:e})}function ny(){const[e,t]=l.useState(!1);return r.jsx(ty,{children:r.jsxs("div",{className:"min-h-screen bg-zinc-100",children:[e&&r.jsx("div",{"aria-hidden":"true",className:"fixed inset-0 z-40 bg-zinc-950/50 md:hidden",onClick:()=>t(!1)}),r.jsx(Xp,{open:e,onClose:()=>t(!1)}),r.jsx(X0,{navOpen:e,onToggleNav:()=>t(n=>!n)}),r.jsx("main",{className:"md:ml-60 pt-14 min-h-screen",children:r.jsx("div",{className:"p-6",children:r.jsx(Vf,{})})})]})})}const xe=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:k("flex h-9 w-full rounded-md border border-zinc-200 bg-white px-3 py-1 text-sm shadow-none transition-colors","placeholder:text-zinc-400","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-0 focus:border-blue-500","disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));xe.displayName="Input";var ry="Label",bd=l.forwardRef((e,t)=>r.jsx(jt.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));bd.displayName=ry;var wd=bd;const sy=ys("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ze=l.forwardRef(({className:e,...t},n)=>r.jsx(wd,{ref:n,className:k(sy(),e),...t}));ze.displayName=wd.displayName;function oy({size:e="md",className:t}){return r.jsx("div",{className:k("inline-block animate-spin rounded-full border-2 border-zinc-200 border-t-blue-600",e==="sm"&&"h-4 w-4",e==="md"&&"h-6 w-6",e==="lg"&&"h-8 w-8",t),role:"status","aria-label":"Loading"})}function ay(){const{login:e}=_c(),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(null),[c,u]=l.useState(!1),d=async h=>{h.preventDefault(),i(null),u(!0);try{await e(t,s)}catch(f){i(f instanceof Error?f.message:"Login failed")}finally{u(!1)}};return r.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-zinc-950 px-4",children:[r.jsx("div",{className:"pointer-events-none fixed inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle, #fff 1px, transparent 1px)",backgroundSize:"24px 24px"}}),r.jsxs("div",{className:"relative w-full max-w-sm",children:[r.jsxs("div",{className:"mb-8 flex flex-col items-center gap-3",children:[r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-blue-600 shadow-lg shadow-blue-500/20",children:r.jsx("span",{className:"text-xl font-bold text-white",children:"N"})}),r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-xl font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Admin Dashboard"})]})]}),r.jsxs("div",{className:"rounded-xl border border-zinc-800 bg-zinc-900 p-6 shadow-2xl",children:[r.jsx("h2",{className:"mb-1 text-base font-semibold text-zinc-100",children:"Sign in"}),r.jsx("p",{className:"mb-6 text-sm text-zinc-500",children:"Enter your admin credentials"}),r.jsxs("form",{onSubmit:h=>void d(h),"data-testid":q("login","form"),className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ze,{className:"text-zinc-300 text-xs",children:"Email"}),r.jsx(xe,{type:"email",value:t,onChange:h=>n(h.target.value),placeholder:"admin@yourstore.com",autoComplete:"email",required:!0,disabled:c,"data-testid":q("login","email"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ze,{className:"text-zinc-300 text-xs",children:"Password"}),r.jsx(xe,{type:"password",value:s,onChange:h=>o(h.target.value),placeholder:"••••••••",autoComplete:"current-password",required:!0,disabled:c,"data-testid":q("login","password"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),a&&r.jsx("div",{role:"alert","data-testid":q("login","error"),className:"rounded-md border border-red-800/50 bg-red-900/20 px-3 py-2 text-sm text-red-400",children:a}),r.jsx(ue,{type:"submit",className:"w-full",disabled:c||!t||!s,"data-testid":q("login","submit"),children:c?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(oy,{size:"sm",className:"border-blue-200 border-t-white"}),"Signing in..."]}):"Sign in"})]})]}),r.jsx("p",{className:"mt-4 text-center text-xs text-zinc-600",children:"Nymbal Admin · Precision Workspace"})]})]})}function ve({className:e,...t}){return r.jsx("div",{className:k("animate-pulse rounded-md bg-zinc-200",e),...t})}const iy={pending:"bg-zinc-100 text-zinc-700",confirmed:"bg-blue-100 text-blue-700",processing:"bg-indigo-100 text-indigo-700",shipped:"bg-violet-100 text-violet-700",delivered:"bg-green-100 text-green-700",cancelled:"bg-red-100 text-red-700",refunded:"bg-orange-100 text-orange-700",partially_refunded:"bg-amber-100 text-amber-700"},cy={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Part. Refunded"};function qn({status:e,size:t="md",className:n,"data-testid":s}){return r.jsx("span",{"data-testid":s,className:k("inline-flex items-center rounded-full font-medium",t==="sm"?"px-2 py-0.5 text-[10px]":"px-2.5 py-0.5 text-xs",iy[e],n),children:cy[e]})}function vt({icon:e,title:t,description:n,action:s,className:o}){return r.jsxs("div",{className:k("flex flex-col items-center justify-center py-16 px-4 text-center",o),children:[e&&r.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-zinc-100 text-zinc-400",children:e}),r.jsx("h3",{className:"text-sm font-medium text-zinc-900",children:t}),n&&r.jsx("p",{className:"mt-1 text-sm text-zinc-500",children:n}),s&&r.jsx("div",{className:"mt-4",children:s})]})}function ly(){return Ae({queryKey:["dashboard"],queryFn:()=>ae.get("/api/admin/dashboard"),refetchInterval:6e4})}function pe(e,t){return new Intl.NumberFormat("en-GB",{style:"currency",currency:t,minimumFractionDigits:2}).format(e/100)}function dy(e){const t=e.trim();if(!/^\d+(\.\d{1,2})?$/.test(t))return null;const[n="0",s=""]=t.split(".");return Number(n)*100+Number(s.padEnd(2,"0"))}function uy(e,t){const n=e/100,s=fy(t);return n>=1e6?`${s}${(n/1e6).toFixed(1)}M`:n>=1e3?`${s}${(n/1e3).toFixed(1)}k`:pe(e,t)}function fy(e){try{return new Intl.NumberFormat("en-GB",{style:"currency",currency:e,minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/[\d\s,]/g,"").trim()}catch{return e}}function hy(){return r.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-green-50 border border-green-200 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-green-600",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-green-500"})]}),"Live"]})}function io({icon:e,label:t,value:n,subtext:s,loading:o,color:a="blue"}){const i={blue:"bg-blue-50 text-blue-600",green:"bg-green-50 text-green-600",violet:"bg-violet-50 text-violet-600"};return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsx("div",{className:k("flex h-9 w-9 items-center justify-center rounded-lg",i[a]),children:e}),r.jsx(To,{className:"h-4 w-4 text-zinc-300"})]}),o?r.jsxs(r.Fragment,{children:[r.jsx(ve,{className:"h-7 w-24 mb-1"}),r.jsx(ve,{className:"h-3.5 w-16"})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900",children:n}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:t}),s&&r.jsx("p",{className:"mt-1 text-[11px] text-zinc-400",children:s})]})]})}function my(){var a,i;const{data:e}=Mc(),{data:t,isLoading:n}=ly(),s=yt(),o="GBP";return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:(e==null?void 0:e.storeName)??"Dashboard"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Today's performance at a glance"})]}),r.jsx(hy,{})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsx(io,{icon:r.jsx(Bn,{className:"h-4.5 w-4.5"}),label:"Orders today",value:String((t==null?void 0:t.today.orderCount)??0),loading:n,color:"blue"}),r.jsx(io,{icon:r.jsx(Wm,{className:"h-4.5 w-4.5"}),label:"Revenue today",value:t?uy(t.today.revenueMinor,o):"—",subtext:t?pe(t.today.revenueMinor,o):void 0,loading:n,color:"green"}),r.jsx(io,{icon:r.jsx(Ac,{className:"h-4.5 w-4.5"}),label:"Items shipped",value:String((t==null?void 0:t.today.itemsShipped)??0),loading:n,color:"violet"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Recent Orders"}),r.jsx("button",{onClick:()=>s("/orders"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"View all →"})]}),n?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:5}).map((c,u)=>r.jsx(ve,{className:"h-11 w-full"},u))}):(a=t==null?void 0:t.recentOrders)!=null&&a.length?r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"border-b border-zinc-100",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Order"}),r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Customer"}),r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Status"}),r.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Total"}),r.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Time"})]})}),r.jsx("tbody",{children:t.recentOrders.map(c=>r.jsxs("tr",{className:"cursor-pointer border-b border-zinc-50 last:border-0 hover:bg-zinc-50 transition-colors",onClick:()=>s(`/orders/${c.orderNumber}`),children:[r.jsx("td",{className:"px-4 py-2.5",children:r.jsxs("span",{className:"font-mono text-sm font-medium text-blue-600",children:["#",c.orderNumber]})}),r.jsx("td",{className:"px-4 py-2.5 text-zinc-600 truncate max-w-[160px]",children:c.email}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx(qn,{status:c.status,size:"sm"})}),r.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-sm text-zinc-700",children:pe(c.totalMinor,c.currency)}),r.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-zinc-400",children:it(c.createdAt)})]},c.id))})]}):r.jsx(vt,{icon:r.jsx(Bn,{className:"h-5 w-5"}),title:"No orders yet",description:"Orders will appear here as they come in."})]})}),r.jsx("div",{children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Low Stock"}),(t==null?void 0:t.lowStock)&&t.lowStock.length>0&&r.jsx("span",{className:"rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:t.lowStock.length})]}),r.jsx("button",{onClick:()=>s("/inventory"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"Manage →"})]}),n?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:4}).map((c,u)=>r.jsx(ve,{className:"h-10 w-full"},u))}):(i=t==null?void 0:t.lowStock)!=null&&i.length?r.jsx("div",{className:"divide-y divide-zinc-50",children:t.lowStock.map(c=>r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-zinc-50 transition-colors",onClick:()=>s("/inventory"),children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-xs font-medium text-zinc-700",children:c.productName}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:c.sku})]}),r.jsxs("div",{className:"ml-3 text-right",children:[r.jsx("span",{className:k("font-mono text-sm font-semibold",c.status==="out_of_stock"?"text-red-600":"text-amber-600"),children:c.stock}),r.jsxs("p",{className:"text-[10px] text-zinc-400",children:["/",c.threshold]})]})]},c.variantId))}):r.jsxs("div",{className:"p-6 text-center",children:[r.jsx("div",{className:"mx-auto mb-2 flex h-8 w-8 items-center justify-center rounded-full bg-green-50",children:r.jsx(as,{className:"h-4 w-4 text-green-500"})}),r.jsx("p",{className:"text-xs text-zinc-500",children:"All stock levels are healthy"})]})]})})]})]})}const gn=l.forwardRef(({className:e,...t},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:k("w-full caption-bottom text-sm",e),...t})}));gn.displayName="Table";const vn=l.forwardRef(({className:e,...t},n)=>r.jsx("thead",{ref:n,className:k("[&_tr]:border-b [&_tr]:border-zinc-200",e),...t}));vn.displayName="TableHeader";const yn=l.forwardRef(({className:e,...t},n)=>r.jsx("tbody",{ref:n,className:k("[&_tr:last-child]:border-0",e),...t}));yn.displayName="TableBody";const py=l.forwardRef(({className:e,...t},n)=>r.jsx("tfoot",{ref:n,className:k("border-t border-zinc-200 bg-zinc-50/50 font-medium [&>tr]:last:border-b-0",e),...t}));py.displayName="TableFooter";const Fe=l.forwardRef(({className:e,...t},n)=>r.jsx("tr",{ref:n,className:k("border-b border-zinc-100 transition-colors hover:bg-zinc-50/60 data-[state=selected]:bg-blue-50",e),...t}));Fe.displayName="TableRow";const te=l.forwardRef(({className:e,...t},n)=>r.jsx("th",{ref:n,className:k("h-10 px-4 text-left align-middle text-xs font-medium uppercase tracking-wider text-zinc-500 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));te.displayName="TableHead";const ne=l.forwardRef(({className:e,...t},n)=>r.jsx("td",{ref:n,className:k("h-11 px-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));ne.displayName="TableCell";const xy=l.forwardRef(({className:e,...t},n)=>r.jsx("caption",{ref:n,className:k("mt-4 text-sm text-zinc-500",e),...t}));xy.displayName="TableCaption";function jd(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _s="Checkbox",[gy]=ot(_s),[vy,ka]=gy(_s);function yy(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:o,disabled:a,form:i,name:c,onCheckedChange:u,required:d,value:h="on",internal_do_not_use_render:f}=e,[m,g]=Ut({prop:n,defaultProp:o??!1,onChange:u,caller:_s}),[v,p]=l.useState(null),[x,y]=l.useState(null),w=l.useRef(!1),N=v?!!i||!!v.closest("form"):!0,j={checked:m,disabled:a,setChecked:g,control:v,setControl:p,name:c,form:i,value:h,hasConsumerStoppedPropagationRef:w,required:d,defaultChecked:Lt(o)?!1:o,isFormControl:N,bubbleInput:x,setBubbleInput:y};return r.jsx(vy,{scope:t,...j,children:by(f)?f(j):s})}var Nd="CheckboxTrigger",Cd=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},o)=>{const{control:a,value:i,disabled:c,checked:u,required:d,setControl:h,setChecked:f,hasConsumerStoppedPropagationRef:m,isFormControl:g,bubbleInput:v}=ka(Nd,e),p=le(o,h),x=l.useRef(u);return l.useEffect(()=>{const y=a==null?void 0:a.form;if(y){const w=()=>f(x.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[a,f]),r.jsx(W.button,{type:"button",role:"checkbox","aria-checked":Lt(u)?"mixed":u,"aria-required":d,"data-state":kd(u),"data-disabled":c?"":void 0,disabled:c,value:i,...s,ref:p,onKeyDown:I(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:I(n,y=>{f(w=>Lt(w)?!0:!w),v&&g&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})})});Cd.displayName=Nd;var Ta=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:o,defaultChecked:a,required:i,disabled:c,value:u,onCheckedChange:d,form:h,...f}=e;return r.jsx(yy,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:c,required:i,onCheckedChange:d,name:s,form:h,value:u,internal_do_not_use_render:({isFormControl:m})=>r.jsxs(r.Fragment,{children:[r.jsx(Cd,{...f,ref:t,__scopeCheckbox:n}),m&&r.jsx(Pd,{__scopeCheckbox:n})]})})});Ta.displayName=_s;var Sd="CheckboxIndicator",Ed=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=ka(Sd,n);return r.jsx(Be,{present:s||Lt(a.checked)||a.checked===!0,children:r.jsx(W.span,{"data-state":kd(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Ed.displayName=Sd;var Rd="CheckboxBubbleInput",Pd=l.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:i,required:c,disabled:u,name:d,value:h,form:f,bubbleInput:m,setBubbleInput:g}=ka(Rd,e),v=le(n,g),p=jd(a),x=ol(s);l.useEffect(()=>{const w=m;if(!w)return;const N=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(N,"checked").set,E=!o.current;if(p!==a&&C){const S=new Event("click",{bubbles:E});w.indeterminate=Lt(a),C.call(w,Lt(a)?!1:a),w.dispatchEvent(S)}},[m,p,a,o]);const y=l.useRef(Lt(a)?!1:a);return r.jsx(W.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??y.current,required:c,disabled:u,name:d,value:h,form:f,...t,tabIndex:-1,ref:v,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Pd.displayName=Rd;function by(e){return typeof e=="function"}function Lt(e){return e==="indeterminate"}function kd(e){return Lt(e)?"indeterminate":e?"checked":"unchecked"}const $o=l.forwardRef(({className:e,...t},n)=>r.jsx(Ta,{ref:n,className:k("peer h-4 w-4 shrink-0 rounded-sm border border-zinc-300 ring-offset-white","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:bg-blue-600 data-[state=checked]:border-blue-600 data-[state=checked]:text-white",e),...t,children:r.jsx(Ed,{className:k("flex items-center justify-center text-current"),children:r.jsx(Yn,{className:"h-3 w-3",strokeWidth:3})})}));$o.displayName=Ta.displayName;function Aa(e){const t=e+"CollectionProvider",[n,s]=ot(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:x,children:y}=p,w=qe.useRef(null),N=qe.useRef(new Map).current;return r.jsx(o,{scope:x,itemMap:N,collectionRef:w,children:y})};i.displayName=t;const c=e+"CollectionSlot",u=un(c),d=qe.forwardRef((p,x)=>{const{scope:y,children:w}=p,N=a(c,y),j=le(x,N.collectionRef);return r.jsx(u,{ref:j,children:w})});d.displayName=c;const h=e+"CollectionItemSlot",f="data-radix-collection-item",m=un(h),g=qe.forwardRef((p,x)=>{const{scope:y,children:w,...N}=p,j=qe.useRef(null),C=le(x,j),E=a(h,y);return qe.useEffect(()=>(E.itemMap.set(j,{ref:j,...N}),()=>void E.itemMap.delete(j))),r.jsx(m,{[f]:"",ref:C,children:w})});g.displayName=h;function v(p){const x=a(e+"CollectionConsumer",p);return qe.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const N=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((E,S)=>N.indexOf(E.ref.current)-N.indexOf(S.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:d,ItemSlot:g},v,s]}var wy=l.createContext(void 0);function Is(e){const t=l.useContext(wy);return e||t||"ltr"}var co="rovingFocusGroup.onEntryFocus",jy={bubbles:!1,cancelable:!0},_r="RovingFocusGroup",[Uo,Td,Ny]=Aa(_r),[Cy,Os]=ot(_r,[Ny]),[Sy,Ey]=Cy(_r),Ad=l.forwardRef((e,t)=>r.jsx(Uo.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Uo.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Ry,{...e,ref:t})})}));Ad.displayName=_r;var Ry=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...f}=e,m=l.useRef(null),g=le(t,m),v=Is(a),[p,x]=Ut({prop:i,defaultProp:c??null,onChange:u,caller:_r}),[y,w]=l.useState(!1),N=st(d),j=Td(n),C=l.useRef(!1),[E,S]=l.useState(0);return l.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(co,N),()=>P.removeEventListener(co,N)},[N]),r.jsx(Sy,{scope:n,orientation:s,dir:v,loop:o,currentTabStopId:p,onItemFocus:l.useCallback(P=>x(P),[x]),onItemShiftTab:l.useCallback(()=>w(!0),[]),onFocusableItemAdd:l.useCallback(()=>S(P=>P+1),[]),onFocusableItemRemove:l.useCallback(()=>S(P=>P-1),[]),children:r.jsx(W.div,{tabIndex:y||E===0?-1:0,"data-orientation":s,...f,ref:g,style:{outline:"none",...e.style},onMouseDown:I(e.onMouseDown,()=>{C.current=!0}),onFocus:I(e.onFocus,P=>{const D=!C.current;if(P.target===P.currentTarget&&D&&!y){const O=new CustomEvent(co,jy);if(P.currentTarget.dispatchEvent(O),!O.defaultPrevented){const $=j().filter(V=>V.focusable),_=$.find(V=>V.active),G=$.find(V=>V.id===p),X=[_,G,...$].filter(Boolean).map(V=>V.ref.current);Id(X,h)}}C.current=!1}),onBlur:I(e.onBlur,()=>w(!1))})})}),Md="RovingFocusGroupItem",_d=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,u=je(),d=a||u,h=Ey(Md,n),f=h.currentTabStopId===d,m=Td(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:p}=h;return l.useEffect(()=>{if(s)return g(),()=>v()},[s,g,v]),r.jsx(Uo.ItemSlot,{scope:n,id:d,focusable:s,active:o,children:r.jsx(W.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...c,ref:t,onMouseDown:I(e.onMouseDown,x=>{s?h.onItemFocus(d):x.preventDefault()}),onFocus:I(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:I(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ty(x,h.orientation,h.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let N=m().filter(j=>j.focusable).map(j=>j.ref.current);if(y==="last")N.reverse();else if(y==="prev"||y==="next"){y==="prev"&&N.reverse();const j=N.indexOf(x.currentTarget);N=h.loop?Ay(N,j+1):N.slice(j+1)}setTimeout(()=>Id(N))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:p!=null}):i})})});_d.displayName=Md;var Py={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ty(e,t,n){const s=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Py[s]}function Id(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Ay(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Od=Ad,Dd=_d,Vo=["Enter"," "],My=["ArrowDown","PageUp","Home"],zd=["ArrowUp","PageDown","End"],_y=[...My,...zd],Iy={ltr:[...Vo,"ArrowRight"],rtl:[...Vo,"ArrowLeft"]},Oy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ir="Menu",[xr,Dy,zy]=Aa(Ir),[bn,Ld]=ot(Ir,[zy,tr,Os]),Ds=tr(),Fd=Os(),[Ly,wn]=bn(Ir),[Fy,Or]=bn(Ir),$d=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:o,onOpenChange:a,modal:i=!0}=e,c=Ds(t),[u,d]=l.useState(null),h=l.useRef(!1),f=st(a),m=Is(o);return l.useEffect(()=>{const g=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),r.jsx(pa,{...c,children:r.jsx(Ly,{scope:t,open:n,onOpenChange:f,content:u,onContentChange:d,children:r.jsx(Fy,{scope:t,onClose:l.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:m,modal:i,children:s})})})};$d.displayName=Ir;var $y="MenuAnchor",Ma=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=Ds(n);return r.jsx(Ss,{...o,...s,ref:t})});Ma.displayName=$y;var _a="MenuPortal",[Uy,Ud]=bn(_a,{forceMount:void 0}),Vd=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:o}=e,a=wn(_a,t);return r.jsx(Uy,{scope:t,forceMount:n,children:r.jsx(Be,{present:n||a.open,children:r.jsx(kr,{asChild:!0,container:o,children:s})})})};Vd.displayName=_a;var Ve="MenuContent",[Vy,Ia]=bn(Ve),Bd=l.forwardRef((e,t)=>{const n=Ud(Ve,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=wn(Ve,e.__scopeMenu),i=Or(Ve,e.__scopeMenu);return r.jsx(xr.Provider,{scope:e.__scopeMenu,children:r.jsx(Be,{present:s||a.open,children:r.jsx(xr.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(By,{...o,ref:t}):r.jsx(Ky,{...o,ref:t})})})})}),By=l.forwardRef((e,t)=>{const n=wn(Ve,e.__scopeMenu),s=l.useRef(null),o=le(t,s);return l.useEffect(()=>{const a=s.current;if(a)return Es(a)},[]),r.jsx(Oa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:I(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ky=l.forwardRef((e,t)=>{const n=wn(Ve,e.__scopeMenu);return r.jsx(Oa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Hy=un("MenuContent.ScrollLock"),Oa=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:m,onDismiss:g,disableOutsideScroll:v,...p}=e,x=wn(Ve,n),y=Or(Ve,n),w=Ds(n),N=Fd(n),j=Dy(n),[C,E]=l.useState(null),S=l.useRef(null),P=le(t,S,x.onContentChange),D=l.useRef(0),O=l.useRef(""),$=l.useRef(0),_=l.useRef(null),G=l.useRef("right"),U=l.useRef(0),X=v?Tr:l.Fragment,V=v?{as:Hy,allowPinchZoom:!0}:void 0,re=T=>{var A,Q;const ie=O.current+T,ce=j().filter(Y=>!Y.disabled),R=document.activeElement,B=(A=ce.find(Y=>Y.ref.current===R))==null?void 0:A.textValue,H=ce.map(Y=>Y.textValue),z=rb(H,ie,B),Z=(Q=ce.find(Y=>Y.textValue===z))==null?void 0:Q.ref.current;(function Y(oe){O.current=oe,window.clearTimeout(D.current),oe!==""&&(D.current=window.setTimeout(()=>Y(""),1e3))})(ie),Z&&setTimeout(()=>Z.focus())};l.useEffect(()=>()=>window.clearTimeout(D.current),[]),bs();const L=l.useCallback(T=>{var ce,R;return G.current===((ce=_.current)==null?void 0:ce.side)&&ob(T,(R=_.current)==null?void 0:R.area)},[]);return r.jsx(Vy,{scope:n,searchRef:O,onItemEnter:l.useCallback(T=>{L(T)&&T.preventDefault()},[L]),onItemLeave:l.useCallback(T=>{var ie;L(T)||((ie=S.current)==null||ie.focus(),E(null))},[L]),onTriggerLeave:l.useCallback(T=>{L(T)&&T.preventDefault()},[L]),pointerGraceTimerRef:$,onPointerGraceIntentChange:l.useCallback(T=>{_.current=T},[]),children:r.jsx(X,{...V,children:r.jsx(Rr,{asChild:!0,trapped:o,onMountAutoFocus:I(a,T=>{var ie;T.preventDefault(),(ie=S.current)==null||ie.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(Er,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:m,onDismiss:g,children:r.jsx(Od,{asChild:!0,...N,dir:y.dir,orientation:"vertical",loop:s,currentTabStopId:C,onCurrentTabStopIdChange:E,onEntryFocus:I(u,T=>{y.isUsingKeyboardRef.current||T.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(xa,{role:"menu","aria-orientation":"vertical","data-state":ou(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...p,ref:P,style:{outline:"none",...p.style},onKeyDown:I(p.onKeyDown,T=>{const ce=T.target.closest("[data-radix-menu-content]")===T.currentTarget,R=T.ctrlKey||T.altKey||T.metaKey,B=T.key.length===1;ce&&(T.key==="Tab"&&T.preventDefault(),!R&&B&&re(T.key));const H=S.current;if(T.target!==H||!_y.includes(T.key))return;T.preventDefault();const Z=j().filter(A=>!A.disabled).map(A=>A.ref.current);zd.includes(T.key)&&Z.reverse(),tb(Z)}),onBlur:I(e.onBlur,T=>{T.currentTarget.contains(T.target)||(window.clearTimeout(D.current),O.current="")}),onPointerMove:I(e.onPointerMove,gr(T=>{const ie=T.target,ce=U.current!==T.clientX;if(T.currentTarget.contains(ie)&&ce){const R=T.clientX>U.current?"right":"left";G.current=R,U.current=T.clientX}}))})})})})})})});Bd.displayName=Ve;var qy="MenuGroup",Da=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(W.div,{role:"group",...s,ref:t})});Da.displayName=qy;var Wy="MenuLabel",Kd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(W.div,{...s,ref:t})});Kd.displayName=Wy;var hs="MenuItem",zi="menu.itemSelect",zs=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...o}=e,a=l.useRef(null),i=Or(hs,e.__scopeMenu),c=Ia(hs,e.__scopeMenu),u=le(t,a),d=l.useRef(!1),h=()=>{const f=a.current;if(!n&&f){const m=new CustomEvent(zi,{bubbles:!0,cancelable:!0});f.addEventListener(zi,g=>s==null?void 0:s(g),{once:!0}),Bc(f,m),m.defaultPrevented?d.current=!1:i.onClose()}};return r.jsx(Hd,{...o,ref:u,disabled:n,onClick:I(e.onClick,h),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),d.current=!0},onPointerUp:I(e.onPointerUp,f=>{var m;d.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:I(e.onKeyDown,f=>{const m=c.searchRef.current!=="";n||m&&f.key===" "||Vo.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});zs.displayName=hs;var Hd=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:o,...a}=e,i=Ia(hs,n),c=Fd(n),u=l.useRef(null),d=le(t,u),[h,f]=l.useState(!1),[m,g]=l.useState("");return l.useEffect(()=>{const v=u.current;v&&g((v.textContent??"").trim())},[a.children]),r.jsx(xr.ItemSlot,{scope:n,disabled:s,textValue:o??m,children:r.jsx(Dd,{asChild:!0,...c,focusable:!s,children:r.jsx(W.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:d,onPointerMove:I(e.onPointerMove,gr(v=>{s?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:I(e.onPointerLeave,gr(v=>i.onItemLeave(v))),onFocus:I(e.onFocus,()=>f(!0)),onBlur:I(e.onBlur,()=>f(!1))})})})}),Gy="MenuCheckboxItem",qd=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...o}=e;return r.jsx(Xd,{scope:e.__scopeMenu,checked:n,children:r.jsx(zs,{role:"menuitemcheckbox","aria-checked":ms(n)?"mixed":n,...o,ref:t,"data-state":La(n),onSelect:I(o.onSelect,()=>s==null?void 0:s(ms(n)?!0:!n),{checkForDefaultPrevented:!1})})})});qd.displayName=Gy;var Wd="MenuRadioGroup",[Qy,Yy]=bn(Wd,{value:void 0,onValueChange:()=>{}}),Gd=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...o}=e,a=st(s);return r.jsx(Qy,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(Da,{...o,ref:t})})});Gd.displayName=Wd;var Qd="MenuRadioItem",Yd=l.forwardRef((e,t)=>{const{value:n,...s}=e,o=Yy(Qd,e.__scopeMenu),a=n===o.value;return r.jsx(Xd,{scope:e.__scopeMenu,checked:a,children:r.jsx(zs,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":La(a),onSelect:I(s.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Yd.displayName=Qd;var za="MenuItemIndicator",[Xd,Xy]=bn(za,{checked:!1}),Zd=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...o}=e,a=Xy(za,n);return r.jsx(Be,{present:s||ms(a.checked)||a.checked===!0,children:r.jsx(W.span,{...o,ref:t,"data-state":La(a.checked)})})});Zd.displayName=za;var Zy="MenuSeparator",Jd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(W.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Jd.displayName=Zy;var Jy="MenuArrow",eu=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=Ds(n);return r.jsx(ga,{...o,...s,ref:t})});eu.displayName=Jy;var eb="MenuSub",[iN,tu]=bn(eb),dr="MenuSubTrigger",nu=l.forwardRef((e,t)=>{const n=wn(dr,e.__scopeMenu),s=Or(dr,e.__scopeMenu),o=tu(dr,e.__scopeMenu),a=Ia(dr,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=a,d={__scopeMenu:e.__scopeMenu},h=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>h,[h]),l.useEffect(()=>{const f=c.current;return()=>{window.clearTimeout(f),u(null)}},[c,u]),r.jsx(Ma,{asChild:!0,...d,children:r.jsx(Hd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ou(n.open),...e,ref:rt(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:I(e.onPointerMove,gr(f=>{a.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:I(e.onPointerLeave,gr(f=>{var g,v;h();const m=(g=n.content)==null?void 0:g.getBoundingClientRect();if(m){const p=(v=n.content)==null?void 0:v.dataset.side,x=p==="right",y=x?-5:5,w=m[x?"left":"right"],N=m[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:w,y:m.top},{x:N,y:m.top},{x:N,y:m.bottom},{x:w,y:m.bottom}],side:p}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(f),f.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:I(e.onKeyDown,f=>{var g;const m=a.searchRef.current!=="";e.disabled||m&&f.key===" "||Iy[s.dir].includes(f.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),f.preventDefault())})})})});nu.displayName=dr;var ru="MenuSubContent",su=l.forwardRef((e,t)=>{const n=Ud(Ve,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=wn(Ve,e.__scopeMenu),i=Or(Ve,e.__scopeMenu),c=tu(ru,e.__scopeMenu),u=l.useRef(null),d=le(t,u);return r.jsx(xr.Provider,{scope:e.__scopeMenu,children:r.jsx(Be,{present:s||a.open,children:r.jsx(xr.Slot,{scope:e.__scopeMenu,children:r.jsx(Oa,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:d,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var f;i.isUsingKeyboardRef.current&&((f=u.current)==null||f.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:I(e.onFocusOutside,h=>{h.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:I(e.onEscapeKeyDown,h=>{i.onClose(),h.preventDefault()}),onKeyDown:I(e.onKeyDown,h=>{var g;const f=h.currentTarget.contains(h.target),m=Oy[i.dir].includes(h.key);f&&m&&(a.onOpenChange(!1),(g=c.trigger)==null||g.focus(),h.preventDefault())})})})})})});su.displayName=ru;function ou(e){return e?"open":"closed"}function ms(e){return e==="indeterminate"}function La(e){return ms(e)?"indeterminate":e?"checked":"unchecked"}function tb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function nb(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function rb(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=nb(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const u=i.find(d=>d.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function sb(e,t){const{x:n,y:s}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],u=t[i],d=c.x,h=c.y,f=u.x,m=u.y;h>s!=m>s&&n<(f-d)*(s-h)/(m-h)+d&&(o=!o)}return o}function ob(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sb(n,t)}function gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ab=$d,ib=Ma,cb=Vd,lb=Bd,db=Da,ub=Kd,fb=zs,hb=qd,mb=Gd,pb=Yd,xb=Zd,gb=Jd,vb=eu,yb=nu,bb=su,Ls="DropdownMenu",[wb]=ot(Ls,[Ld]),Pe=Ld(),[jb,au]=wb(Ls),iu=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,u=Pe(t),d=l.useRef(null),[h,f]=Ut({prop:o,defaultProp:a??!1,onChange:i,caller:Ls});return r.jsx(jb,{scope:t,triggerId:je(),triggerRef:d,contentId:je(),open:h,onOpenChange:f,onOpenToggle:l.useCallback(()=>f(m=>!m),[f]),modal:c,children:r.jsx(ab,{...u,open:h,onOpenChange:f,dir:s,modal:c,children:n})})};iu.displayName=Ls;var cu="DropdownMenuTrigger",lu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...o}=e,a=au(cu,n),i=Pe(n);return r.jsx(ib,{asChild:!0,...i,children:r.jsx(W.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...o,ref:rt(t,a.triggerRef),onPointerDown:I(e.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:I(e.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});lu.displayName=cu;var Nb="DropdownMenuPortal",du=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Pe(t);return r.jsx(cb,{...s,...n})};du.displayName=Nb;var uu="DropdownMenuContent",fu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=au(uu,n),a=Pe(n),i=l.useRef(!1);return r.jsx(lb,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...s,ref:t,onCloseAutoFocus:I(e.onCloseAutoFocus,c=>{var u;i.current||(u=o.triggerRef.current)==null||u.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:I(e.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;(!o.modal||h)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fu.displayName=uu;var Cb="DropdownMenuGroup",Sb=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(db,{...o,...s,ref:t})});Sb.displayName=Cb;var Eb="DropdownMenuLabel",hu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(ub,{...o,...s,ref:t})});hu.displayName=Eb;var Rb="DropdownMenuItem",mu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(fb,{...o,...s,ref:t})});mu.displayName=Rb;var Pb="DropdownMenuCheckboxItem",pu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(hb,{...o,...s,ref:t})});pu.displayName=Pb;var kb="DropdownMenuRadioGroup",Tb=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(mb,{...o,...s,ref:t})});Tb.displayName=kb;var Ab="DropdownMenuRadioItem",xu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(pb,{...o,...s,ref:t})});xu.displayName=Ab;var Mb="DropdownMenuItemIndicator",gu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(xb,{...o,...s,ref:t})});gu.displayName=Mb;var _b="DropdownMenuSeparator",vu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(gb,{...o,...s,ref:t})});vu.displayName=_b;var Ib="DropdownMenuArrow",Ob=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(vb,{...o,...s,ref:t})});Ob.displayName=Ib;var Db="DropdownMenuSubTrigger",yu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(yb,{...o,...s,ref:t})});yu.displayName=Db;var zb="DropdownMenuSubContent",bu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Pe(n);return r.jsx(bb,{...o,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});bu.displayName=zb;var Lb=iu,Fb=lu,$b=du,wu=fu,ju=hu,Nu=mu,Cu=pu,Su=xu,Eu=gu,Ru=vu,Pu=yu,ku=bu;const Fa=Lb,$a=Fb,Ub=l.forwardRef(({className:e,inset:t,children:n,...s},o)=>r.jsxs(Pu,{ref:o,className:k("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-zinc-100 data-[state=open]:bg-zinc-100 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...s,children:[n,r.jsx(Ec,{className:"ml-auto"})]}));Ub.displayName=Pu.displayName;const Vb=l.forwardRef(({className:e,...t},n)=>r.jsx(ku,{ref:n,className:k("z-50 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white p-1 text-zinc-900 shadow-lg","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",e),...t}));Vb.displayName=ku.displayName;const Fs=l.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx($b,{children:r.jsx(wu,{ref:s,sideOffset:t,className:k("z-50 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white p-1 text-zinc-900 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",e),...n})}));Fs.displayName=wu.displayName;const mt=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(Nu,{ref:s,className:k("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","focus:bg-zinc-100 focus:text-zinc-900","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n}));mt.displayName=Nu.displayName;const Bb=l.forwardRef(({className:e,children:t,checked:n=!1,...s},o)=>r.jsxs(Cu,{ref:o,className:k("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-zinc-100 focus:text-zinc-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...s,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Eu,{children:r.jsx(Yn,{className:"h-4 w-4"})})}),t]}));Bb.displayName=Cu.displayName;const Kb=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Su,{ref:s,className:k("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-zinc-100 focus:text-zinc-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Eu,{children:r.jsx(Km,{className:"h-2 w-2 fill-current"})})}),t]}));Kb.displayName=Su.displayName;const Hb=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(ju,{ref:s,className:k("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",t&&"pl-8",e),...n}));Hb.displayName=ju.displayName;const $s=l.forwardRef(({className:e,...t},n)=>r.jsx(Ru,{ref:n,className:k("-mx-1 my-1 h-px bg-zinc-100",e),...t}));$s.displayName=Ru.displayName;const qb=[{label:"All",value:"all"},{label:"Pending",value:"pending"},{label:"Confirmed",value:"confirmed"},{label:"Processing",value:"processing"},{label:"Shipped",value:"shipped"},{label:"Delivered",value:"delivered"},{label:"Cancelled",value:"cancelled"},{label:"Refunded",value:"refunded"},{label:"Partially refunded",value:"partially_refunded"}],Wb={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"};function Gb(){const e=yt(),[t,n]=l.useState("all"),[s,o]=l.useState(""),[a,i]=l.useState(new Set),{data:c,isLoading:u}=Ic({status:t==="all"?void 0:t,q:s||void 0,sort:"createdAt:desc",limit:100}),d=m=>{i(g=>{const v=new Set(g);return v.has(m)?v.delete(m):v.add(m),v})},h=()=>{c&&(a.size===c.length?i(new Set):i(new Set(c.map(m=>m.id))))},f=c?a.size===c.length&&c.length>0:!1;return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Orders"}),r.jsx("p",{className:"text-sm text-zinc-500",children:c?`${c.length} orders`:"Loading..."})]})}),r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:qb.map(m=>r.jsx("button",{onClick:()=>n(m.value),className:k("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===m.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:m.label},m.value))}),r.jsxs("div",{className:"flex flex-1 items-center gap-2 sm:justify-end",children:[r.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[r.jsx(Xn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(xe,{placeholder:"Search orders...",value:s,onChange:m=>o(m.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsxs(ue,{variant:"outline",size:"sm",className:"gap-1.5",children:[r.jsx(Qm,{className:"h-3.5 w-3.5"}),"Filter"]})]})]}),a.size>0&&r.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-blue-200 bg-blue-50 px-4 py-2.5",children:[r.jsxs("span",{className:"text-sm font-medium text-blue-700",children:[a.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[r.jsxs(ue,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-blue-200 text-blue-700 hover:bg-blue-100",children:[r.jsx($m,{className:"h-3.5 w-3.5"}),"Confirm All"]}),r.jsxs(ue,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-red-200 text-red-600 hover:bg-red-50",children:[r.jsx(Tc,{className:"h-3.5 w-3.5"}),"Cancel All"]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:u?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,g)=>r.jsx(ve,{className:"h-11 w-full"},g))}):c!=null&&c.length?r.jsxs(gn,{children:[r.jsx(vn,{children:r.jsxs(Fe,{children:[r.jsx(te,{className:"w-10 pl-4",children:r.jsx($o,{checked:f,onCheckedChange:h,"aria-label":"Select all"})}),r.jsx(te,{children:"Order #"}),r.jsx(te,{children:"Customer"}),r.jsx(te,{children:"Status"}),r.jsx(te,{children:"Payment"}),r.jsx(te,{className:"text-center",children:"Items"}),r.jsx(te,{className:"text-right",children:"Total"}),r.jsx(te,{className:"text-right",children:"Date"}),r.jsx(te,{className:"w-10",children:r.jsx("span",{className:"sr-only",children:"Actions"})})]})}),r.jsx(yn,{children:c.map(m=>r.jsxs(Fe,{"data-testid":q("orders","row",m.orderNumber),"data-state":a.has(m.id)?"selected":void 0,className:k("cursor-pointer",a.has(m.id)&&"bg-blue-50/50"),children:[r.jsx(ne,{className:"pl-4",onClick:g=>g.stopPropagation(),children:r.jsx($o,{checked:a.has(m.id),onCheckedChange:()=>d(m.id),"aria-label":`Select order ${m.orderNumber}`})}),r.jsxs(ne,{className:"font-mono text-sm font-medium text-blue-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:["#",m.orderNumber]}),r.jsx(ne,{className:"text-zinc-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx("div",{className:"truncate max-w-[180px]",children:m.email})}),r.jsx(ne,{onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx(qn,{status:m.status})}),r.jsx(ne,{className:"text-sm text-zinc-600",onClick:()=>e(`/orders/${m.orderNumber}`),"data-testid":q("orders","payment",m.orderNumber),children:Wb[zh(m)]}),r.jsx(ne,{className:"text-center text-zinc-500",onClick:()=>e(`/orders/${m.orderNumber}`),children:m.lineItems.length}),r.jsx(ne,{className:"text-right font-mono text-sm",onClick:()=>e(`/orders/${m.orderNumber}`),children:pe(m.totalMinor,m.currency)}),r.jsx(ne,{className:"text-right text-sm text-zinc-400",onClick:()=>e(`/orders/${m.orderNumber}`),children:it(m.createdAt)}),r.jsx(ne,{onClick:g=>g.stopPropagation(),children:r.jsxs(Fa,{children:[r.jsx($a,{asChild:!0,children:r.jsx(ue,{variant:"ghost",size:"icon","aria-label":`Actions for order ${m.orderNumber}`,className:"h-8 w-8 text-zinc-400",children:r.jsx(Rc,{className:"h-4 w-4"})})}),r.jsxs(Fs,{align:"end",children:[r.jsx(mt,{onClick:()=>e(`/orders/${m.orderNumber}`),children:"View details"}),r.jsx($s,{}),r.jsx(mt,{className:"text-red-600",children:"Cancel order"})]})]})})]},m.id))})]}):r.jsx(vt,{icon:r.jsx(dn,{className:"h-5 w-5"}),title:"No orders found",description:s||t!=="all"?"Try adjusting your filters.":"Orders will appear here as they come in."})})]})}const Qb={breadcrumb:()=>"Orders"};var Us="Tabs",[Yb]=ot(Us,[Os]),Tu=Os(),[Xb,Ua]=Yb(Us),Au=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:u="automatic",...d}=e,h=Is(c),[f,m]=Ut({prop:s,onChange:o,defaultProp:a??"",caller:Us});return r.jsx(Xb,{scope:n,baseId:je(),value:f,onValueChange:m,orientation:i,dir:h,activationMode:u,children:r.jsx(W.div,{dir:h,"data-orientation":i,...d,ref:t})})});Au.displayName=Us;var Mu="TabsList",_u=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Ua(Mu,n),i=Tu(n);return r.jsx(Od,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(W.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});_u.displayName=Mu;var Iu="TabsTrigger",Ou=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=Ua(Iu,n),c=Tu(n),u=Lu(i.baseId,s),d=Fu(i.baseId,s),h=s===i.value;return r.jsx(Dd,{asChild:!0,...c,focusable:!o,active:h,children:r.jsx(W.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":d,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...a,ref:t,onMouseDown:I(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(s):f.preventDefault()}),onKeyDown:I(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(s)}),onFocus:I(e.onFocus,()=>{const f=i.activationMode!=="manual";!h&&!o&&f&&i.onValueChange(s)})})})});Ou.displayName=Iu;var Du="TabsContent",zu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=Ua(Du,n),u=Lu(c.baseId,s),d=Fu(c.baseId,s),h=s===c.value,f=l.useRef(h);return l.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(Be,{present:o||h,children:({present:m})=>r.jsx(W.div,{"data-state":h?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&a})})});zu.displayName=Du;function Lu(e,t){return`${e}-trigger-${t}`}function Fu(e,t){return`${e}-content-${t}`}var Zb=Au,$u=_u,Uu=Ou,Vu=zu;const Bu=Zb,Va=l.forwardRef(({className:e,...t},n)=>r.jsx($u,{ref:n,className:k("inline-flex h-9 items-center justify-center rounded-lg bg-zinc-100 p-1 text-zinc-500",e),...t}));Va.displayName=$u.displayName;const Qt=l.forwardRef(({className:e,...t},n)=>r.jsx(Uu,{ref:n,className:k("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-white transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","data-[state=active]:bg-white data-[state=active]:text-zinc-900 data-[state=active]:shadow-sm",e),...t}));Qt.displayName=Uu.displayName;const Yt=l.forwardRef(({className:e,...t},n)=>r.jsx(Vu,{ref:n,className:k("mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",e),...t}));Yt.displayName=Vu.displayName;function Li(e,[t,n]){return Math.min(n,Math.max(t,e))}var Ku=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Jb="VisuallyHidden",ew=l.forwardRef((e,t)=>r.jsx(W.span,{...e,ref:t,style:{...Ku,...e.style}}));ew.displayName=Jb;var tw=[" ","Enter","ArrowUp","ArrowDown"],nw=[" ","Enter"],pn="Select",[Vs,Bs,rw]=Aa(pn),[nr]=ot(pn,[rw,tr]),Ks=tr(),[sw,Kt]=nr(pn),[ow,aw]=nr(pn),Hu=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:u,dir:d,name:h,autoComplete:f,disabled:m,required:g,form:v}=e,p=Ks(t),[x,y]=l.useState(null),[w,N]=l.useState(null),[j,C]=l.useState(!1),E=Is(d),[S,P]=Ut({prop:s,defaultProp:o??!1,onChange:a,caller:pn}),[D,O]=Ut({prop:i,defaultProp:c,onChange:u,caller:pn}),$=l.useRef(null),_=x?v||!!x.closest("form"):!0,[G,U]=l.useState(new Set),X=Array.from(G).map(V=>V.props.value).join(";");return r.jsx(pa,{...p,children:r.jsxs(sw,{required:g,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:j,onValueNodeHasChildrenChange:C,contentId:je(),value:D,onValueChange:O,open:S,onOpenChange:P,dir:E,triggerPointerDownPosRef:$,disabled:m,children:[r.jsx(Vs.Provider,{scope:t,children:r.jsx(ow,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(V=>{U(re=>new Set(re).add(V))},[]),onNativeOptionRemove:l.useCallback(V=>{U(re=>{const L=new Set(re);return L.delete(V),L})},[]),children:n})}),_?r.jsxs(xf,{"aria-hidden":!0,required:g,tabIndex:-1,name:h,autoComplete:f,value:D,onChange:V=>O(V.target.value),disabled:m,form:v,children:[D===void 0?r.jsx("option",{value:""}):null,Array.from(G)]},X):null]})})};Hu.displayName=pn;var qu="SelectTrigger",Wu=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Ks(n),i=Kt(qu,n),c=i.disabled||s,u=le(t,i.onTriggerChange),d=Bs(n),h=l.useRef("touch"),[f,m,g]=vf(p=>{const x=d().filter(N=>!N.disabled),y=x.find(N=>N.value===i.value),w=yf(x,p,y);w!==void 0&&i.onValueChange(w.value)}),v=p=>{c||(i.onOpenChange(!0),g()),p&&(i.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(Ss,{asChild:!0,...a,children:r.jsx(W.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":gf(i.value)?"":void 0,...o,ref:u,onClick:I(o.onClick,p=>{p.currentTarget.focus(),h.current!=="mouse"&&v(p)}),onPointerDown:I(o.onPointerDown,p=>{h.current=p.pointerType;const x=p.target;x.hasPointerCapture(p.pointerId)&&x.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(v(p),p.preventDefault())}),onKeyDown:I(o.onKeyDown,p=>{const x=f.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&m(p.key),!(x&&p.key===" ")&&tw.includes(p.key)&&(v(),p.preventDefault())})})})});Wu.displayName=qu;var Gu="SelectValue",Qu=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:i="",...c}=e,u=Kt(Gu,n),{onValueNodeHasChildrenChange:d}=u,h=a!==void 0,f=le(t,u.onValueNodeChange);return Ce(()=>{d(h)},[d,h]),r.jsx(W.span,{...c,ref:f,style:{pointerEvents:"none"},children:gf(u.value)?r.jsx(r.Fragment,{children:i}):a})});Qu.displayName=Gu;var iw="SelectIcon",Yu=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(W.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});Yu.displayName=iw;var cw="SelectPortal",Xu=e=>r.jsx(kr,{asChild:!0,...e});Xu.displayName=cw;var xn="SelectContent",Zu=l.forwardRef((e,t)=>{const n=Kt(xn,e.__scopeSelect),[s,o]=l.useState();if(Ce(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?Sr.createPortal(r.jsx(Ju,{scope:e.__scopeSelect,children:r.jsx(Vs.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(ef,{...e,ref:t})});Zu.displayName=xn;var Ke=10,[Ju,Ht]=nr(xn),lw="SelectContentImpl",dw=un("SelectContent.RemoveScroll"),ef=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:m,collisionPadding:g,sticky:v,hideWhenDetached:p,avoidCollisions:x,...y}=e,w=Kt(xn,n),[N,j]=l.useState(null),[C,E]=l.useState(null),S=le(t,A=>j(A)),[P,D]=l.useState(null),[O,$]=l.useState(null),_=Bs(n),[G,U]=l.useState(!1),X=l.useRef(!1);l.useEffect(()=>{if(N)return Es(N)},[N]),bs();const V=l.useCallback(A=>{const[Q,...Y]=_().map(he=>he.ref.current),[oe]=Y.slice(-1),fe=document.activeElement;for(const he of A)if(he===fe||(he==null||he.scrollIntoView({block:"nearest"}),he===Q&&C&&(C.scrollTop=0),he===oe&&C&&(C.scrollTop=C.scrollHeight),he==null||he.focus(),document.activeElement!==fe))return},[_,C]),re=l.useCallback(()=>V([P,N]),[V,P,N]);l.useEffect(()=>{G&&re()},[G,re]);const{onOpenChange:L,triggerPointerDownPosRef:T}=w;l.useEffect(()=>{if(N){let A={x:0,y:0};const Q=oe=>{var fe,he;A={x:Math.abs(Math.round(oe.pageX)-(((fe=T.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(oe.pageY)-(((he=T.current)==null?void 0:he.y)??0))}},Y=oe=>{A.x<=10&&A.y<=10?oe.preventDefault():N.contains(oe.target)||L(!1),document.removeEventListener("pointermove",Q),T.current=null};return T.current!==null&&(document.addEventListener("pointermove",Q),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Q),document.removeEventListener("pointerup",Y,{capture:!0})}}},[N,L,T]),l.useEffect(()=>{const A=()=>L(!1);return window.addEventListener("blur",A),window.addEventListener("resize",A),()=>{window.removeEventListener("blur",A),window.removeEventListener("resize",A)}},[L]);const[ie,ce]=vf(A=>{const Q=_().filter(fe=>!fe.disabled),Y=Q.find(fe=>fe.ref.current===document.activeElement),oe=yf(Q,A,Y);oe&&setTimeout(()=>oe.ref.current.focus())}),R=l.useCallback((A,Q,Y)=>{const oe=!X.current&&!Y;(w.value!==void 0&&w.value===Q||oe)&&(D(A),oe&&(X.current=!0))},[w.value]),B=l.useCallback(()=>N==null?void 0:N.focus(),[N]),H=l.useCallback((A,Q,Y)=>{const oe=!X.current&&!Y;(w.value!==void 0&&w.value===Q||oe)&&$(A)},[w.value]),z=s==="popper"?Bo:tf,Z=z===Bo?{side:c,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:m,collisionPadding:g,sticky:v,hideWhenDetached:p,avoidCollisions:x}:{};return r.jsx(Ju,{scope:n,content:N,viewport:C,onViewportChange:E,itemRefCallback:R,selectedItem:P,onItemLeave:B,itemTextRefCallback:H,focusSelectedItem:re,selectedItemText:O,position:s,isPositioned:G,searchRef:ie,children:r.jsx(Tr,{as:dw,allowPinchZoom:!0,children:r.jsx(Rr,{asChild:!0,trapped:w.open,onMountAutoFocus:A=>{A.preventDefault()},onUnmountAutoFocus:I(o,A=>{var Q;(Q=w.trigger)==null||Q.focus({preventScroll:!0}),A.preventDefault()}),children:r.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:A=>A.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:r.jsx(z,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:A=>A.preventDefault(),...y,...Z,onPlaced:()=>U(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:I(y.onKeyDown,A=>{const Q=A.ctrlKey||A.altKey||A.metaKey;if(A.key==="Tab"&&A.preventDefault(),!Q&&A.key.length===1&&ce(A.key),["ArrowUp","ArrowDown","Home","End"].includes(A.key)){let oe=_().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(A.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(A.key)){const fe=A.target,he=oe.indexOf(fe);oe=oe.slice(he+1)}setTimeout(()=>V(oe)),A.preventDefault()}})})})})})})});ef.displayName=lw;var uw="SelectItemAlignedPosition",tf=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=Kt(xn,n),i=Ht(xn,n),[c,u]=l.useState(null),[d,h]=l.useState(null),f=le(t,S=>h(S)),m=Bs(n),g=l.useRef(!1),v=l.useRef(!0),{viewport:p,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,N=l.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&d&&p&&x&&y){const S=a.trigger.getBoundingClientRect(),P=d.getBoundingClientRect(),D=a.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(a.dir!=="rtl"){const fe=O.left-P.left,he=D.left-fe,_e=S.left-he,Ye=S.width+_e,rr=Math.max(Ye,P.width),sr=window.innerWidth-Ke,or=Li(he,[Ke,Math.max(Ke,sr-rr)]);c.style.minWidth=Ye+"px",c.style.left=or+"px"}else{const fe=P.right-O.right,he=window.innerWidth-D.right-fe,_e=window.innerWidth-S.right-he,Ye=S.width+_e,rr=Math.max(Ye,P.width),sr=window.innerWidth-Ke,or=Li(he,[Ke,Math.max(Ke,sr-rr)]);c.style.minWidth=Ye+"px",c.style.right=or+"px"}const $=m(),_=window.innerHeight-Ke*2,G=p.scrollHeight,U=window.getComputedStyle(d),X=parseInt(U.borderTopWidth,10),V=parseInt(U.paddingTop,10),re=parseInt(U.borderBottomWidth,10),L=parseInt(U.paddingBottom,10),T=X+V+G+L+re,ie=Math.min(x.offsetHeight*5,T),ce=window.getComputedStyle(p),R=parseInt(ce.paddingTop,10),B=parseInt(ce.paddingBottom,10),H=S.top+S.height/2-Ke,z=_-H,Z=x.offsetHeight/2,A=x.offsetTop+Z,Q=X+V+A,Y=T-Q;if(Q<=H){const fe=$.length>0&&x===$[$.length-1].ref.current;c.style.bottom="0px";const he=d.clientHeight-p.offsetTop-p.offsetHeight,_e=Math.max(z,Z+(fe?B:0)+he+re),Ye=Q+_e;c.style.height=Ye+"px"}else{const fe=$.length>0&&x===$[0].ref.current;c.style.top="0px";const _e=Math.max(H,X+p.offsetTop+(fe?R:0)+Z)+Y;c.style.height=_e+"px",p.scrollTop=Q-H+p.offsetTop}c.style.margin=`${Ke}px 0`,c.style.minHeight=ie+"px",c.style.maxHeight=_+"px",s==null||s(),requestAnimationFrame(()=>g.current=!0)}},[m,a.trigger,a.valueNode,c,d,p,x,y,a.dir,s]);Ce(()=>N(),[N]);const[j,C]=l.useState();Ce(()=>{d&&C(window.getComputedStyle(d).zIndex)},[d]);const E=l.useCallback(S=>{S&&v.current===!0&&(N(),w==null||w(),v.current=!1)},[N,w]);return r.jsx(hw,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(W.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});tf.displayName=uw;var fw="SelectPopperPosition",Bo=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Ke,...a}=e,i=Ks(n);return r.jsx(xa,{...i,...a,ref:t,align:s,collisionPadding:o,style:{boxSizing:"border-box",...a.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)"}})});Bo.displayName=fw;var[hw,Ba]=nr(xn,{}),Ko="SelectViewport",nf=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=Ht(Ko,n),i=Ba(Ko,n),c=le(t,a.onViewportChange),u=l.useRef(0);return r.jsxs(r.Fragment,{children:[r.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:s}),r.jsx(Vs.Slot,{scope:n,children:r.jsx(W.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:I(o.onScroll,d=>{const h=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const g=Math.abs(u.current-h.scrollTop);if(g>0){const v=window.innerHeight-Ke*2,p=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(p,x);if(y<v){const w=y+g,N=Math.min(v,w),j=w-N;f.style.height=N+"px",f.style.bottom==="0px"&&(h.scrollTop=j>0?j:0,f.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});nf.displayName=Ko;var rf="SelectGroup",[mw,pw]=nr(rf),xw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=je();return r.jsx(mw,{scope:n,id:o,children:r.jsx(W.div,{role:"group","aria-labelledby":o,...s,ref:t})})});xw.displayName=rf;var sf="SelectLabel",of=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=pw(sf,n);return r.jsx(W.div,{id:o.id,...s,ref:t})});of.displayName=sf;var ps="SelectItem",[gw,af]=nr(ps),cf=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...i}=e,c=Kt(ps,n),u=Ht(ps,n),d=c.value===s,[h,f]=l.useState(a??""),[m,g]=l.useState(!1),v=le(t,w=>{var N;return(N=u.itemRefCallback)==null?void 0:N.call(u,w,s,o)}),p=je(),x=l.useRef("touch"),y=()=>{o||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")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 r.jsx(gw,{scope:n,value:s,disabled:o,textId:p,isSelected:d,onItemTextChange:l.useCallback(w=>{f(N=>N||((w==null?void 0:w.textContent)??"").trim())},[]),children:r.jsx(Vs.ItemSlot,{scope:n,value:s,disabled:o,textValue:h,children:r.jsx(W.div,{role:"option","aria-labelledby":p,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:I(i.onFocus,()=>g(!0)),onBlur:I(i.onBlur,()=>g(!1)),onClick:I(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:I(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:I(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:I(i.onPointerMove,w=>{var N;x.current=w.pointerType,o?(N=u.onItemLeave)==null||N.call(u):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:I(i.onPointerLeave,w=>{var N;w.currentTarget===document.activeElement&&((N=u.onItemLeave)==null||N.call(u))}),onKeyDown:I(i.onKeyDown,w=>{var j;((j=u.searchRef)==null?void 0:j.current)!==""&&w.key===" "||(nw.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});cf.displayName=ps;var ur="SelectItemText",lf=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,i=Kt(ur,n),c=Ht(ur,n),u=af(ur,n),d=aw(ur,n),[h,f]=l.useState(null),m=le(t,y=>f(y),u.onItemTextChange,y=>{var w;return(w=c.itemTextRefCallback)==null?void 0:w.call(c,y,u.value,u.disabled)}),g=h==null?void 0:h.textContent,v=l.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:p,onNativeOptionRemove:x}=d;return Ce(()=>(p(v),()=>x(v)),[p,x,v]),r.jsxs(r.Fragment,{children:[r.jsx(W.span,{id:u.textId,...a,ref:m}),u.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Sr.createPortal(a.children,i.valueNode):null]})});lf.displayName=ur;var df="SelectItemIndicator",uf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return af(df,n).isSelected?r.jsx(W.span,{"aria-hidden":!0,...s,ref:t}):null});uf.displayName=df;var Ho="SelectScrollUpButton",ff=l.forwardRef((e,t)=>{const n=Ht(Ho,e.__scopeSelect),s=Ba(Ho,e.__scopeSelect),[o,a]=l.useState(!1),i=le(t,s.onScrollButtonChange);return Ce(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=u.scrollTop>0;a(d)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(mf,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});ff.displayName=Ho;var qo="SelectScrollDownButton",hf=l.forwardRef((e,t)=>{const n=Ht(qo,e.__scopeSelect),s=Ba(qo,e.__scopeSelect),[o,a]=l.useState(!1),i=le(t,s.onScrollButtonChange);return Ce(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)<d;a(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(mf,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});hf.displayName=qo;var mf=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=Ht("SelectScrollButton",n),i=l.useRef(null),c=Bs(n),u=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>u(),[u]),Ce(()=>{var h;const d=c().find(f=>f.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[c]),r.jsx(W.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:I(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(s,50))}),onPointerMove:I(o.onPointerMove,()=>{var d;(d=a.onItemLeave)==null||d.call(a),i.current===null&&(i.current=window.setInterval(s,50))}),onPointerLeave:I(o.onPointerLeave,()=>{u()})})}),vw="SelectSeparator",pf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(W.div,{"aria-hidden":!0,...s,ref:t})});pf.displayName=vw;var Wo="SelectArrow",yw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ks(n),a=Kt(Wo,n),i=Ht(Wo,n);return a.open&&i.position==="popper"?r.jsx(ga,{...o,...s,ref:t}):null});yw.displayName=Wo;var bw="SelectBubbleInput",xf=l.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=l.useRef(null),a=le(s,o),i=jd(t);return l.useEffect(()=>{const c=o.current;if(!c)return;const u=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(i!==t&&h){const f=new Event("change",{bubbles:!0});h.call(c,t),c.dispatchEvent(f)}},[i,t]),r.jsx(W.select,{...n,style:{...Ku,...n.style},ref:a,defaultValue:t})});xf.displayName=bw;function gf(e){return e===""||e===void 0}function vf(e){const t=st(e),n=l.useRef(""),s=l.useRef(0),o=l.useCallback(i=>{const c=n.current+i;t(c),function u(d){n.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>u(""),1e3))}(c)},[t]),a=l.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,a]}function yf(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=ww(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const u=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function ww(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var jw=Hu,bf=Wu,Nw=Qu,Cw=Yu,Sw=Xu,wf=Zu,Ew=nf,jf=of,Nf=cf,Rw=lf,Pw=uf,Cf=ff,Sf=hf,Ef=pf;const vr=jw,yr=Nw,Wn=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(bf,{ref:s,className:k("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm shadow-none ring-offset-white","placeholder:text-zinc-400","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-0","disabled:cursor-not-allowed disabled:opacity-50","[&>span]:line-clamp-1",e),...n,children:[t,r.jsx(Cw,{asChild:!0,children:r.jsx(Sc,{className:"h-4 w-4 opacity-50 shrink-0"})})]}));Wn.displayName=bf.displayName;const Rf=l.forwardRef(({className:e,...t},n)=>r.jsx(Cf,{ref:n,className:k("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Um,{className:"h-4 w-4"})}));Rf.displayName=Cf.displayName;const Pf=l.forwardRef(({className:e,...t},n)=>r.jsx(Sf,{ref:n,className:k("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Sc,{className:"h-4 w-4"})}));Pf.displayName=Sf.displayName;const Gn=l.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Sw,{children:r.jsxs(wf,{ref:o,className:k("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white text-zinc-900 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",n==="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",e),position:n,...s,children:[r.jsx(Rf,{}),r.jsx(Ew,{className:k("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(Pf,{})]})}));Gn.displayName=wf.displayName;const kw=l.forwardRef(({className:e,...t},n)=>r.jsx(jf,{ref:n,className:k("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",e),...t}));kw.displayName=jf.displayName;const Ue=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Nf,{ref:s,className:k("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none","focus:bg-zinc-100 focus:text-zinc-900","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Pw,{children:r.jsx(Yn,{className:"h-4 w-4"})})}),r.jsx(Rw,{children:t})]}));Ue.displayName=Nf.displayName;const Tw=l.forwardRef(({className:e,...t},n)=>r.jsx(Ef,{ref:n,className:k("-mx-1 my-1 h-px bg-zinc-100",e),...t}));Tw.displayName=Ef.displayName;const qr="record-payment",lo={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Partially Refunded"},Aw={confirmed:"confirm",processing:"process",shipped:"ship",delivered:"mark-delivered",cancelled:"cancel"};function Mw(e,t){return Dh[e].filter(n=>n!=="refunded"&&n!=="partially_refunded"&&n!=="confirmed"&&!(n==="cancelled"&&t>0))}function _w({orderId:e,currentStatus:t,orderNumber:n,capturedMinor:s}){const o=be(),{mutateAsync:a,isPending:i}=up(),{mutateAsync:c,isPending:u}=Oc(),[d,h]=l.useState(null),f=Mw(t,s),m=t==="pending"&&s===0,g=d??t,v=i||u;if(f.length===0&&!m)return r.jsx("span",{className:"text-sm text-zinc-500 font-medium capitalize",children:lo[t]});const p=async x=>{const y=x===qr?"confirmed":x;h(y);try{x===qr?await c({orderId:e}):await a({orderId:e,action:Aw[y]??y})}catch(w){console.error("[OrderStatusSelect] status update failed",w),h(null),o.invalidateQueries({queryKey:["orders","detail",n]})}};return r.jsxs(vr,{value:g,onValueChange:x=>void p(x),disabled:v,children:[r.jsx(Wn,{className:k("w-44 h-8 text-xs",v&&"opacity-50"),"aria-label":"Order status","data-testid":q("order","status-select"),children:r.jsx(yr,{})}),r.jsxs(Gn,{children:[r.jsxs(Ue,{value:t,disabled:!0,"data-testid":q("order","status-option",t),children:[lo[t]," (current)"]}),m&&r.jsx(Ue,{value:qr,"data-testid":q("order","status-option",qr),children:"Record payment"}),f.map(x=>r.jsx(Ue,{value:x,"data-testid":q("order","status-option",x),children:lo[x]},x))]})]})}function Iw({entries:e}){const t=[...e].sort((n,s)=>new Date(s.timestamp).getTime()-new Date(n.timestamp).getTime());return r.jsx("div",{className:"flow-root",children:r.jsx("ul",{className:"-mb-8",children:t.map((n,s)=>r.jsx("li",{"data-testid":q("order","timeline-entry",n.toStatus),children:r.jsxs("div",{className:"relative pb-8",children:[s<t.length-1&&r.jsx("span",{className:"absolute left-4 top-5 -ml-px h-full w-0.5 bg-zinc-200","aria-hidden":"true"}),r.jsxs("div",{className:"relative flex gap-3",children:[r.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-zinc-200 bg-white",children:r.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})}),r.jsxs("div",{className:"min-w-0 flex-1 pt-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.fromStatus&&r.jsxs(r.Fragment,{children:[r.jsx(qn,{status:n.fromStatus,size:"sm"}),r.jsx("span",{className:"text-zinc-400 text-xs",children:"→"})]}),r.jsx(qn,{status:n.toStatus,size:"sm"})]}),n.note&&r.jsx("p",{className:"mt-1 text-sm text-zinc-600",children:n.note}),r.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{children:n.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:n.timestamp,title:wt(n.timestamp),children:it(n.timestamp)})]})]})]})]})},n.id))})})}const cn=l.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{className:k("flex min-h-[80px] w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm","placeholder:text-zinc-400","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","disabled:cursor-not-allowed disabled:opacity-50","resize-none",e),ref:n,...t}));cn.displayName="Textarea";function Ow({orderId:e,notes:t}){const[n,s]=l.useState(""),o=xp(),a=async i=>{i.preventDefault(),n.trim()&&(await o.mutateAsync({orderId:e,body:n.trim()}),s(""))};return r.jsxs("div",{"data-testid":q("order","notes"),children:[r.jsx("div",{className:"space-y-3",children:t.length===0?r.jsx("p",{className:"text-sm text-zinc-400 italic",children:"No notes yet."}):[...t].sort((i,c)=>new Date(c.at).getTime()-new Date(i.at).getTime()).map((i,c)=>r.jsx(Dw,{note:i},c))}),r.jsxs("form",{onSubmit:i=>void a(i),className:"mt-4 flex gap-2",children:[r.jsx(cn,{placeholder:"Add an internal note...",value:n,onChange:i=>s(i.target.value),rows:2,className:"flex-1 text-sm",onKeyDown:i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),a(i))}}),r.jsx(ue,{type:"submit",size:"icon","aria-label":"Add note",disabled:!n.trim()||o.isPending,className:"self-end h-9 w-9",children:r.jsx(kc,{className:"h-4 w-4"})})]})]})}function Dw({note:e}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:e.body}),r.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{className:"font-medium text-zinc-500",children:e.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:e.at,title:wt(e.at),children:it(e.at)})]})]})}function zw(e,t){if(!(e instanceof Vn))return"The refund could not be made.";const{amountMinor:n,refundableMinor:s}=e.context??{};return e.code==="refund.exceeds_captured"&&typeof n=="number"&&typeof s=="number"?`A refund of ${pe(n,t)} is more than the ${pe(s,t)} left to refund.`:e.message}function Lw({order:e,onClose:t}){const{refundableMinor:n,currency:s}=e.payment,[o,a]=l.useState((n/100).toFixed(2)),[i,c]=l.useState(""),[u,d]=l.useState(null),[h,f]=l.useState(()=>crypto.randomUUID()),m=l.useRef(!1),[g,v]=l.useState(!1),p=pp(),x=dy(o),y=x!==null&&x>0&&x<=n,w=async()=>{if(!(!y||x===null||m.current)){m.current=!0,v(!0),d(null);try{if((await p.mutateAsync({orderId:e.id,amountMinor:x,requestId:h,...i.trim()&&{reason:i.trim()}})).refund.status==="failed"){f(crypto.randomUUID()),d("The payment provider refused the refund.");return}t()}catch(N){d(zw(N,s))}finally{m.current=!1,v(!1)}}};return r.jsx(id,{open:!0,onOpenChange:N=>!N&&t(),children:r.jsxs(Pa,{className:"max-w-md","data-testid":q("order","refund-dialog"),children:[r.jsx(ld,{children:r.jsxs(ud,{children:["Refund Order #",e.orderNumber]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-md border border-zinc-200 p-3 bg-zinc-50",children:r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-zinc-600",children:"Refundable"}),r.jsx("span",{className:"font-mono font-semibold text-zinc-900",children:pe(n,s)})]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(ze,{htmlFor:"refund-amount",children:["Amount (",s,")"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(xe,{id:"refund-amount",inputMode:"decimal",value:o,onChange:N=>a(N.target.value),"aria-invalid":!y,"data-testid":q("order","refund-amount")}),r.jsx(ue,{variant:"outline",type:"button",onClick:()=>a((n/100).toFixed(2)),children:"Full refund"})]}),!y&&r.jsxs("p",{className:"text-xs text-red-600",children:["Enter an amount above 0 and up to ",pe(n,s),"."]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ze,{htmlFor:"refund-reason",children:"Reason (optional)"}),r.jsx(cn,{id:"refund-reason",placeholder:"Enter refund reason...",value:i,onChange:N=>c(N.target.value),rows:3,"data-testid":q("order","refund-reason")})]}),u&&r.jsx("p",{role:"alert",className:"text-sm text-red-600",children:u})]}),r.jsxs(dd,{children:[r.jsx(ue,{variant:"outline",type:"button",onClick:t,children:"Cancel"}),r.jsx(ue,{variant:"destructive",type:"button",onClick:()=>void w(),disabled:!y||g,"data-testid":q("order","refund-confirm"),children:g?"Processing...":`Refund ${x!==null?pe(x,s):""}`})]})]})})}const Fw={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"},$w={unpaid:"bg-zinc-100 text-zinc-700",paid:"bg-green-100 text-green-700",partially_refunded:"bg-amber-100 text-amber-700",refunded:"bg-orange-100 text-orange-700"},Uw={provider:"Payment provider",manual:"Recorded manually",import:"Imported"},Vw={pending:"Refund pending",succeeded:"Refunded",failed:"Failed"};function Bw({order:e}){const{payment:t}=e;return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Payment"}),r.jsx("span",{className:k("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",$w[t.state]),"data-testid":q("order","payment-state"),children:Fw[t.state]})]}),r.jsxs("dl",{className:"space-y-1.5 text-sm",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Captured"}),r.jsx("dd",{className:"font-mono text-zinc-700","data-testid":q("order","captured"),children:pe(t.capturedMinor,t.currency)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Refunded"}),r.jsx("dd",{className:"font-mono text-zinc-700","data-testid":q("order","refunded"),children:pe(t.refundedMinor,t.currency)})]}),r.jsxs("div",{className:"flex justify-between font-semibold",children:[r.jsx("dt",{className:"text-zinc-700",children:"Net"}),r.jsx("dd",{className:"font-mono text-zinc-900","data-testid":q("order","net"),children:pe(t.capturedMinor-t.refundedMinor,t.currency)})]}),e.captureMethod&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Method"}),r.jsx("dd",{className:"text-zinc-700",children:Uw[e.captureMethod]})]}),e.paymentIntentId&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Intent ID"}),r.jsx("dd",{className:"font-mono text-xs text-zinc-600 truncate max-w-[120px]",children:e.paymentIntentId})]})]}),t.refunds.length>0&&r.jsx("ul",{className:"space-y-1 border-t border-zinc-100 pt-2 text-sm",children:t.refunds.map(n=>r.jsxs("li",{className:"flex justify-between gap-2","data-testid":q("order","refund-row",n.id),children:[r.jsxs("span",{className:"text-zinc-500",children:[Vw[n.status]," · ",wt(n.createdAt)]}),r.jsx("span",{className:"font-mono text-zinc-700",children:pe(n.amountMinor,n.currency)})]},n.id))})]})}function Fi({address:e,label:t}){return r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-1.5",children:t}),r.jsxs("div",{className:"text-sm text-zinc-600 space-y-0.5",children:[r.jsxs("p",{children:[e.firstName," ",e.lastName]}),e.company&&r.jsx("p",{children:e.company}),r.jsx("p",{children:e.addressLine1}),e.addressLine2&&r.jsx("p",{children:e.addressLine2}),r.jsxs("p",{children:[e.city,", ",e.region," ",e.postalCode]}),r.jsx("p",{children:e.country})]})]})}function Kw(){const{orderNumber:e}=Yo(),[t,n]=l.useState(!1),{data:s,isLoading:o}=lp(e??""),{data:a=[]}=dp((s==null?void 0:s.id)??""),i=Oc(),c=fp(),u=hp(),d=mp();if(o)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(ve,{className:"h-8 w-40"}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[r.jsxs("div",{className:"md:col-span-3 space-y-4",children:[r.jsx(ve,{className:"h-48 w-full"}),r.jsx(ve,{className:"h-32 w-full"})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsx(ve,{className:"h-40 w-full"}),r.jsx(ve,{className:"h-48 w-full"})]})]})]});if(!s)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(dn,{className:"mb-3 h-8 w-8 text-zinc-300"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Order not found"}),r.jsx(an,{to:"/orders",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to orders"})]});const f=s.status==="pending"&&s.payment.capturedMinor===0?{label:"Record payment",icon:ti,action:()=>void i.mutateAsync({orderId:s.id})}:s.status==="processing"?{label:"Mark Shipped",icon:Ac,action:()=>void d.mutateAsync({orderId:s.id,trackingNumber:"",carrier:""})}:s.status==="shipped"?{label:"Mark Delivered",icon:ti,action:()=>void u.mutateAsync(s.id)}:null;return r.jsxs("div",{className:"space-y-4","data-testid":q("order","detail"),children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(an,{to:"/orders",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700 transition-colors",children:[r.jsx(ra,{className:"h-4 w-4"}),"Orders"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsxs("h1",{className:"font-mono text-base font-semibold text-zinc-900",children:["#",s.orderNumber]}),r.jsx(qn,{status:s.status,"data-testid":q("order","status-badge")})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[f&&r.jsxs(ue,{size:"sm",onClick:f.action,className:"gap-1.5",children:[r.jsx(f.icon,{className:"h-4 w-4"}),f.label]}),r.jsxs(Fa,{children:[r.jsx($a,{asChild:!0,children:r.jsx(ue,{variant:"outline",size:"sm","data-testid":q("order","actions"),children:"Actions"})}),r.jsxs(Fs,{align:"end",className:"w-44",children:[r.jsxs(mt,{className:"gap-2",children:[r.jsx(Pc,{className:"h-4 w-4"}),"Resend confirmation"]}),r.jsx($s,{}),s.payment.refundableMinor>0&&r.jsxs(mt,{onClick:()=>n(!0),className:"gap-2","data-testid":q("order","action","refund"),children:[r.jsx(qm,{className:"h-4 w-4"}),"Issue refund"]}),r.jsxs(mt,{onClick:()=>void c.mutateAsync({orderId:s.id}),className:"gap-2 text-red-600",disabled:s.payment.capturedMinor>0||["cancelled","refunded","delivered"].includes(s.status),children:[r.jsx(Bm,{className:"h-4 w-4"}),"Cancel order"]})]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(ni,{className:"h-3.5 w-3.5"}),"Placed ",wt(s.createdAt)]}),r.jsx("span",{className:"text-zinc-300",children:"·"}),r.jsx(_w,{orderId:s.id,currentStatus:s.status,orderNumber:s.orderNumber,capturedMinor:s.payment.capturedMinor})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[r.jsxs("div",{className:"md:col-span-3 space-y-5",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:r.jsxs("h2",{className:"text-sm font-semibold text-zinc-900",children:["Items (",s.lineItems.length,")"]})}),r.jsx("div",{className:"divide-y divide-zinc-50",children:s.lineItems.map(m=>r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[m.imageUrl?r.jsx("img",{src:m.imageUrl,alt:m.productName,className:"h-12 w-12 rounded border border-zinc-100 object-cover"}):r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:r.jsx(dn,{className:"h-5 w-5 text-zinc-300"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:m.productName}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[m.variantName," · ",m.sku]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("p",{className:"font-mono text-sm text-zinc-700",children:pe(m.lineTotalMinor,s.currency)}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[m.qty," × ",pe(m.unitPriceMinor,s.currency)]})]})]},m.variantId))}),r.jsxs("div",{className:"border-t border-zinc-100 bg-zinc-50 px-4 py-3 space-y-1",children:[r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Subtotal"}),r.jsx("span",{className:"font-mono",children:pe(s.subtotalMinor,s.currency)})]}),s.taxTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Tax"}),r.jsx("span",{className:"font-mono",children:pe(s.taxTotalMinor,s.currency)})]}),s.shippingTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Shipping"}),r.jsx("span",{className:"font-mono",children:pe(s.shippingTotalMinor,s.currency)})]}),s.discountTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[r.jsx("span",{children:"Discount"}),r.jsxs("span",{className:"font-mono",children:["-",pe(s.discountTotalMinor,s.currency)]})]}),r.jsxs("div",{className:"flex justify-between border-t border-zinc-200 pt-2 text-sm font-semibold text-zinc-800",children:[r.jsx("span",{children:"Total"}),r.jsx("span",{className:"font-mono text-base",children:pe(s.totalMinor,s.currency)})]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:r.jsxs(Bu,{defaultValue:"notes",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-2",children:r.jsxs(Va,{className:"h-8",children:[r.jsxs(Qt,{value:"notes",className:"gap-1.5 text-xs",children:[r.jsx(np,{className:"h-3.5 w-3.5"}),"Notes",a.length>0&&r.jsx("span",{className:"rounded-full bg-zinc-100 px-1.5 text-[10px]",children:a.length})]}),r.jsxs(Qt,{value:"timeline",className:"gap-1.5 text-xs","data-testid":q("order","tab","timeline"),children:[r.jsx(ni,{className:"h-3.5 w-3.5"}),"Timeline"]})]})}),r.jsx(Yt,{value:"notes",className:"p-4",children:r.jsx(Ow,{orderId:s.id,notes:a})}),r.jsx(Yt,{value:"timeline",className:"p-4",children:s.history&&s.history.length>0?r.jsx(Iw,{entries:s.history}):r.jsx("p",{className:"text-sm text-zinc-400 text-center py-4",children:"No history yet."})})]})})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Customer"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-100 text-sm font-semibold text-zinc-600",children:(s.email[0]??"?").toUpperCase()}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:s.email}),s.customerId&&r.jsx(an,{to:`/customers/${s.customerId}`,className:"text-xs text-blue-600 hover:underline",children:"View customer →"})]})]})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400 mb-3",children:"Addresses"}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[r.jsx(Fi,{address:s.shippingAddress,label:"Shipping"}),r.jsx(Fi,{address:s.billingAddress,label:"Billing"})]})]}),r.jsx(Bw,{order:s}),s.notes&&r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-amber-50 p-4",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-600 mb-1.5",children:"Order Note"}),r.jsx("p",{className:"text-sm text-amber-800",children:s.notes})]})]})]}),t&&r.jsx(Lw,{order:s,onClose:()=>n(!1)})]})}const Hw={breadcrumb:e=>`#${e.orderNumber??""}`},qw=ys("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"bg-zinc-100 text-zinc-700",secondary:"bg-zinc-200 text-zinc-800",destructive:"bg-red-100 text-red-700",outline:"border border-zinc-200 text-zinc-700",success:"bg-green-100 text-green-700",warning:"bg-amber-100 text-amber-700",info:"bg-blue-100 text-blue-700"}},defaultVariants:{variant:"default"}});function kf({className:e,variant:t,...n}){return r.jsx("div",{className:k(qw({variant:t}),e),...n})}function Ww(e={}){return Ae({queryKey:["products","list",e],queryFn:()=>ae.get("/api/admin/products",e)})}function Gw(e){return Ae({queryKey:["products","detail",e],queryFn:()=>ae.get(`/api/admin/products/${e}`),enabled:!!e&&e!=="new"})}function Qw(){const e=be();return Se({mutationFn:({product:t,idempotencyKey:n})=>ae.post("/api/admin/products",t,n===void 0?void 0:{idempotencyKey:n}),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function Yw(){const e=be();return Se({mutationFn:({id:t,data:n,idempotencyKey:s})=>ae.patch(`/api/admin/products/${t}`,n,s===void 0?void 0:{idempotencyKey:s}),onSuccess:t=>{e.setQueryData(["products","detail",t.id],t),e.setQueryData(["products","detail",t.slug],t),e.invalidateQueries({queryKey:["products","list"]})}})}function Xw(){const e=be();return Se({mutationFn:t=>ae.post(`/api/admin/products/${t}/duplicate`),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function Zw(){const e=be();return Se({mutationFn:t=>ae.post(`/api/admin/products/${t}/archive`),onSuccess:()=>{e.invalidateQueries({queryKey:["products"]})}})}function Jw(){return Se({mutationFn:({id:e,field:t,context:n})=>ae.post(`/api/admin/products/${e}/enhance`,{field:t,context:n})})}const ej=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Draft",value:"draft"},{label:"Archived",value:"archived"}],tj={active:"success",draft:"default",archived:"secondary"};function nj(){const e=yt(),[t,n]=l.useState("all"),[s,o]=l.useState(""),{data:a,isLoading:i}=Ww({status:t==="all"?void 0:t,q:s||void 0,limit:100}),c=Xw(),u=Zw();return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Products"}),r.jsx("p",{className:"text-sm text-zinc-500",children:a?`${a.length} products`:"Loading..."})]}),r.jsxs(ue,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(mr,{className:"h-4 w-4"}),"Add Product"]})]}),r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:ej.map(d=>r.jsx("button",{onClick:()=>n(d.value),className:k("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===d.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:d.label},d.value))}),r.jsxs("div",{className:"relative flex-1 sm:max-w-xs sm:ml-auto",children:[r.jsx(Xn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(xe,{placeholder:"Search products...",value:s,onChange:d=>o(d.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:i?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:6}).map((d,h)=>r.jsx(ve,{className:"h-11 w-full"},h))}):a!=null&&a.length?r.jsxs(gn,{children:[r.jsx(vn,{children:r.jsxs(Fe,{children:[r.jsx(te,{className:"w-12",children:"Image"}),r.jsx(te,{children:"Name"}),r.jsx(te,{children:"Status"}),r.jsx(te,{children:"Type"}),r.jsx(te,{className:"text-right",children:"Price"}),r.jsx(te,{children:"Stock"}),r.jsx(te,{className:"text-right",children:"Updated"}),r.jsx(te,{className:"w-10"})]})}),r.jsx(yn,{children:a.map(d=>{const h=d.media[0],f=d.variants[0],m=d.variants.reduce((p,x)=>p+x.stock,0),g=d.variants.some(p=>p.stock<=p.lowStockThreshold),v=d.variants.some(p=>p.stock===0);return r.jsxs(Fe,{"data-testid":q("products","row",d.id),className:"cursor-pointer",onClick:()=>e(`/products/${d.slug}`),children:[r.jsx(ne,{children:h?r.jsx("img",{src:h.url,alt:h.altText,className:"h-8 w-8 rounded border border-zinc-100 object-cover"}):r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:r.jsx(dn,{className:"h-3.5 w-3.5 text-zinc-300"})})}),r.jsx(ne,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-zinc-800",children:d.name}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:d.slug})]})}),r.jsx(ne,{children:r.jsx(kf,{variant:tj[d.status],className:"capitalize",children:d.status})}),r.jsx(ne,{className:"text-xs text-zinc-500 capitalize",children:d.type}),r.jsx(ne,{className:"text-right font-mono text-sm",children:f?pe(f.priceMinor,"GBP"):"—"}),r.jsx(ne,{children:r.jsx("span",{className:k("text-sm font-mono font-medium",v?"text-red-600":g?"text-amber-600":"text-zinc-700"),children:m})}),r.jsx(ne,{className:"text-right text-xs text-zinc-400",children:it(d.updatedAt)}),r.jsx(ne,{onClick:p=>p.stopPropagation(),children:r.jsxs(Fa,{children:[r.jsx($a,{asChild:!0,children:r.jsx(ue,{variant:"ghost",size:"icon",className:"h-7 w-7 text-zinc-400 opacity-0 group-hover:opacity-100",children:r.jsx(Rc,{className:"h-4 w-4"})})}),r.jsxs(Fs,{align:"end",children:[r.jsx(mt,{onClick:()=>e(`/products/${d.slug}`),children:"Edit"}),r.jsxs(mt,{onClick:()=>void c.mutateAsync(d.id),className:"gap-2",children:[r.jsx(Hm,{className:"h-3.5 w-3.5"}),"Duplicate"]}),r.jsx($s,{}),r.jsxs(mt,{onClick:()=>void u.mutateAsync(d.id),className:"gap-2 text-zinc-500",children:[r.jsx(zm,{className:"h-3.5 w-3.5"}),"Archive"]})]})]})})]},d.id)})})]}):r.jsx(vt,{icon:r.jsx(dn,{className:"h-5 w-5"}),title:"No products found",description:s?"Try a different search.":"Create your first product.",action:r.jsxs(ue,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(mr,{className:"h-4 w-4"}),"Add Product"]})})})]})}const rj={breadcrumb:()=>"Products"};function sj(e){return{id:`new-${crypto.randomUUID()}`,productId:e,sku:"",name:"New Variant",priceMinor:0,compareAtPriceMinor:null,weightGrams:null,dimensions:null,stock:0,lowStockThreshold:5,options:[],status:"active",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}function oj({productId:e,variants:t,onChange:n,currency:s}){const[o,a]=l.useState(t.map(d=>({...d,_priceDisplay:(d.priceMinor/100).toFixed(2)}))),i=(d,h,f)=>{a(m=>{const g=m.map(v=>{if(v.id!==d)return v;if(h==="_priceDisplay"){const p=parseFloat(f);return{...v,_priceDisplay:f,priceMinor:isNaN(p)?v.priceMinor:Math.round(p*100)}}return{...v,[h]:f}});return n(g.map(({_priceDisplay:v,...p})=>p)),g})},c=()=>{const d=sj(e),h=[...o,{...d,_priceDisplay:"0.00"}];a(h),n(h.map(({_priceDisplay:f,...m})=>m))},u=d=>{const h=o.filter(f=>f.id!==d);a(h),n(h.map(({_priceDisplay:f,...m})=>m))};return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"SKU"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Name"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Price"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Stock"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Status"}),r.jsx("th",{className:"w-10 px-3 py-2"})]})}),r.jsxs("tbody",{children:[o.length===0&&r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-3 py-6 text-center text-sm text-zinc-400",children:"No variants yet. Add one below."})}),o.map(d=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0","data-testid":q("product","variant-row",d.id),children:[r.jsx("td",{className:"px-3 py-2",children:r.jsx(xe,{value:d.sku,onChange:h=>i(d.id,"sku",h.target.value),placeholder:"SKU-001",className:"h-7 font-mono text-xs w-28"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(xe,{value:d.name,onChange:h=>i(d.id,"name",h.target.value),placeholder:"Variant name",className:"h-7 text-xs"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx("span",{className:"text-xs text-zinc-400",children:s}),r.jsx(xe,{value:d._priceDisplay,onChange:h=>i(d.id,"_priceDisplay",h.target.value),onBlur:h=>{const f=parseFloat(h.target.value);isNaN(f)||i(d.id,"_priceDisplay",f.toFixed(2))},className:"h-7 w-20 text-right font-mono text-xs"})]})}),r.jsx("td",{className:"px-3 py-2 text-right",children:r.jsx(xe,{type:"number",value:d.stock,onChange:h=>i(d.id,"stock",parseInt(h.target.value)||0),className:"h-7 w-16 text-right font-mono text-xs ml-auto",min:0})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs(vr,{value:d.status,onValueChange:h=>i(d.id,"status",h),children:[r.jsx(Wn,{className:"h-7 w-24 text-xs",children:r.jsx(yr,{})}),r.jsxs(Gn,{children:[r.jsx(Ue,{value:"active",children:"Active"}),r.jsx(Ue,{value:"inactive",children:"Inactive"})]})]})}),r.jsx("td",{className:"px-3 py-2",children:r.jsx("button",{onClick:()=>u(d.id),className:"rounded p-1 text-zinc-400 hover:bg-red-50 hover:text-red-500 transition-colors",title:"Remove variant",children:r.jsx(Tc,{className:"h-3.5 w-3.5"})})})]},d.id))]})]})}),r.jsxs("div",{className:"flex items-center justify-between pt-1",children:[r.jsxs("p",{className:"text-xs text-zinc-400",children:[o.length," variant",o.length!==1?"s":"",o.length>0&&r.jsxs(r.Fragment,{children:[" · Total stock: ",o.reduce((d,h)=>d+h.stock,0)]})]}),r.jsxs(ue,{variant:"outline",size:"sm",onClick:c,className:"gap-1.5",children:[r.jsx(mr,{className:"h-3.5 w-3.5"}),"Add Variant"]})]})]})}function aj({media:e,onChange:t}){const[n,s]=l.useState(""),[o,a]=l.useState(""),[i,c]=l.useState(!1),[u,d]=l.useState(null),h=()=>{if(!n.trim())return;const v=[...e,{url:n.trim(),altText:o.trim(),position:e.length}];t(v),s(""),a("")},f=v=>{const p=e.filter((x,y)=>y!==v).map((x,y)=>({...x,position:y}));t(p)},m=v=>{const p=e[v];if(!p)return;const x=[p,...e.filter((y,w)=>w!==v)].map((y,w)=>({...y,position:w}));t(x)},g=(v,p)=>{const x=e.map((y,w)=>w===v?{...y,altText:p}:y);t(x)};return r.jsxs("div",{className:"space-y-3",children:[e.length>0&&r.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:e.map((v,p)=>r.jsxs("div",{className:k("group relative rounded-md border bg-zinc-50 overflow-hidden",p===0?"border-blue-300 ring-1 ring-blue-300":"border-zinc-200"),children:[r.jsx("div",{className:"aspect-square flex items-center justify-center",children:v.url?r.jsx("img",{src:v.url,alt:v.altText||"Product image",className:"h-full w-full object-cover",onError:x=>{x.target.style.display="none"}}):r.jsx(Ym,{className:"h-6 w-6 text-zinc-300"})}),p===0&&r.jsx("div",{className:"absolute left-1 top-1 rounded bg-blue-500 px-1 py-0.5 text-[9px] font-semibold text-white",children:"Primary"}),r.jsxs("div",{className:"absolute inset-0 flex items-center justify-center gap-1 bg-black/40 opacity-0 transition-opacity group-hover:opacity-100",children:[p!==0&&r.jsx("button",{onClick:()=>m(p),className:"rounded bg-white/90 p-1 text-zinc-700 hover:bg-white",title:"Set as primary",children:r.jsx(cp,{className:"h-3 w-3"})}),r.jsx("button",{onClick:()=>f(p),className:"rounded bg-white/90 p-1 text-red-600 hover:bg-white",title:"Remove",children:r.jsx(vs,{className:"h-3 w-3"})})]}),r.jsx("div",{className:"border-t border-zinc-100 px-1.5 py-1",children:u===p?r.jsx("input",{autoFocus:!0,value:v.altText,onChange:x=>g(p,x.target.value),onBlur:()=>d(null),className:"w-full text-[10px] bg-transparent border-b border-zinc-300 outline-none",placeholder:"Alt text..."}):r.jsx("button",{onClick:()=>d(p),className:"w-full text-left text-[10px] text-zinc-400 hover:text-zinc-600 truncate",children:v.altText||"Add alt text"})})]},p))}),r.jsx("div",{className:k("rounded-md border-2 border-dashed p-4 transition-colors",i?"border-blue-400 bg-blue-50":"border-zinc-200"),onDragOver:v=>{v.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:v=>{v.preventDefault(),c(!1)},children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs text-zinc-500 text-center",children:"Add image by URL"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(ze,{className:"text-xs",children:"Image URL"}),r.jsx(xe,{value:n,onChange:v=>s(v.target.value),placeholder:"https://cdn.example.com/image.jpg",className:"text-xs h-8",onKeyDown:v=>v.key==="Enter"&&h()})]}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(ze,{className:"text-xs",children:"Alt Text"}),r.jsx(xe,{value:o,onChange:v=>a(v.target.value),placeholder:"Describe the image",className:"text-xs h-8",onKeyDown:v=>v.key==="Enter"&&h()})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(ue,{type:"button",size:"sm",onClick:h,disabled:!n.trim(),className:"h-8 gap-1",children:[r.jsx(mr,{className:"h-3.5 w-3.5"}),"Add"]})})]})]})}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[e.length," image",e.length!==1?"s":""," · Drag to reorder (coming soon)"]})]})}function ij({title:e,description:t,url:n}){const a=e.length>60,i=t.length>155,c=a?e.slice(0,60)+"...":e,u=i?t.slice(0,155)+"...":t;return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:r.jsxs("div",{className:"max-w-lg",children:[r.jsx("p",{className:"text-xs text-zinc-400 mb-1 truncate",children:n||"https://yourstore.com/products/..."}),r.jsx("p",{className:k("text-[17px] leading-snug text-blue-700 cursor-pointer hover:underline mb-1",!e&&"text-zinc-300 italic"),children:c||"Page title appears here"}),r.jsx("p",{className:k("text-sm leading-relaxed text-zinc-500",!t&&"text-zinc-300 italic"),children:u||"Meta description appears here..."})]})}),(a||i)&&r.jsxs("div",{className:"space-y-1.5",children:[a&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(as,{className:"h-3.5 w-3.5 shrink-0"}),"Title is ",e.length," chars — Google shows ~60. Consider shortening."]}),i&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(as,{className:"h-3.5 w-3.5 shrink-0"}),"Description is ",t.length," chars — Google shows ~155. Consider shortening."]})]}),r.jsxs("div",{className:"flex gap-4 text-xs text-zinc-400",children:[r.jsxs("span",{className:k(a?"text-amber-500":"text-zinc-400"),children:["Title: ",e.length,"/",60]}),r.jsxs("span",{className:k(i?"text-amber-500":"text-zinc-400"),children:["Description: ",t.length,"/",155]})]})]})}function uo({productId:e,field:t,context:n,onApply:s,className:o}){const[a,i]=l.useState(null),c=Jw(),u=async()=>{i(null);const f={};n.name&&(f.name=n.name),n.current&&(f.current=n.current);const m=await c.mutateAsync({id:e,field:t,context:f});i(m.suggestion)},d=()=>{a&&(s(a),i(null))},h=()=>{i(null)};return r.jsxs("div",{className:k("space-y-2",o),"data-testid":q("product","ai-enrich",t),children:[r.jsxs(ue,{type:"button",variant:"outline",size:"sm",onClick:()=>void u(),disabled:c.isPending,className:"gap-1.5 text-xs text-purple-700 border-purple-200 hover:bg-purple-50 hover:border-purple-300",children:[r.jsx(ip,{className:k("h-3.5 w-3.5",c.isPending&&"animate-spin")}),c.isPending?"Enhancing...":"Enhance with AI"]}),a&&r.jsxs("div",{className:"rounded-md border border-purple-200 bg-purple-50 p-3 space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-purple-800 uppercase tracking-wider",children:"AI Suggestion"}),r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:a}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsxs(ue,{type:"button",size:"sm",onClick:d,className:"gap-1.5 bg-purple-600 hover:bg-purple-700 text-white text-xs",children:[r.jsx(Yn,{className:"h-3.5 w-3.5"}),"Apply"]}),r.jsxs(ue,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"gap-1.5 text-zinc-500 text-xs",children:[r.jsx(vs,{className:"h-3.5 w-3.5"}),"Dismiss"]})]})]})]})}function Tf(){const[e,t]=l.useState(Po),n=l.useCallback(()=>t(Po()),[]);return[e,n]}const cj={name:"",slug:"",description:"",shortDescription:"",status:"draft",type:"simple",seoTitle:"",seoDescription:"",media:[],variants:[],categoryIds:[],metadata:{}};function lj(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function $i(){const{slug:e}=Yo(),t=yt(),n=!e||e==="new",{data:s,isLoading:o}=Gw(n?"":e??""),a=Qw(),i=Yw(),[c,u]=l.useState(cj),[d,h]=l.useState(!1),[f,m]=l.useState(!1),[g,v]=Tf();l.useEffect(()=>{s&&u(s)},[s]);const p=(j,C)=>{h(!0),u(E=>{const S={...E,[j]:C};return j==="name"&&!f&&(S.slug=lj(C)),S})},x=async()=>{const j=g;if(v(),n){const C=await a.mutateAsync({product:c,idempotencyKey:j});t(`/products/${C.slug}`)}else s&&(await i.mutateAsync({id:s.id,data:c,idempotencyKey:j}),h(!1))},y=a.isPending||i.isPending;if(!n&&o)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(ve,{className:"h-8 w-48"}),r.jsx(ve,{className:"h-96 w-full"})]});const w=(s==null?void 0:s.id)??"new";return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(an,{to:"/products",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(ra,{className:"h-4 w-4"}),"Products"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("h1",{className:"text-base font-semibold text-zinc-900",children:n?"New Product":c.name||"Edit Product"}),d&&r.jsx("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:"Unsaved changes"})]}),r.jsx(ue,{onClick:()=>void x(),disabled:y||!c.name,className:"gap-1.5","data-testid":q("product","save"),children:y?r.jsxs(r.Fragment,{children:[r.jsx(sa,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(op,{className:"h-4 w-4"}),n?"Create Product":"Save Changes"]})})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs(Bu,{defaultValue:"general",children:[r.jsxs(Va,{className:"mb-4",children:[r.jsx(Qt,{value:"general",children:"General"}),r.jsx(Qt,{value:"variants",children:"Variants"}),r.jsx(Qt,{value:"media",children:"Media"}),r.jsx(Qt,{value:"seo",children:"SEO"})]}),r.jsx(Yt,{value:"general",className:"space-y-4",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(ze,{children:["Product Name ",r.jsx("span",{className:"text-red-500",children:"*"})]}),r.jsx(xe,{value:c.name??"",onChange:j=>p("name",j.target.value),placeholder:"e.g. Classic White T-Shirt","data-testid":q("product","name"),className:"text-base"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ze,{children:"Slug"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-zinc-400 shrink-0",children:"/products/"}),r.jsx(xe,{value:c.slug??"",onChange:j=>{m(!0),p("slug",j.target.value)},placeholder:"classic-white-t-shirt",className:"font-mono text-sm"})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(ze,{children:"Description"}),!n&&r.jsx(uo,{productId:w,field:"description",context:{...c.name?{name:c.name}:{},...c.description?{current:c.description}:{}},onApply:j=>p("description",j)})]}),r.jsx(cn,{value:c.description??"",onChange:j=>p("description",j.target.value),placeholder:"Describe this product...",rows:5})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(ze,{children:"Short Description"}),r.jsx(cn,{value:c.shortDescription??"",onChange:j=>p("shortDescription",j.target.value),placeholder:"Brief one-line description...",rows:2})]})]})}),r.jsx(Yt,{value:"variants",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Variants"}),r.jsx(oj,{productId:w,variants:c.variants??[],onChange:j=>p("variants",j),currency:"GBP"})]})}),r.jsx(Yt,{value:"media",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Media"}),r.jsx(aj,{media:c.media??[],onChange:j=>p("media",j)})]})}),r.jsx(Yt,{value:"seo",className:"space-y-4",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(ze,{children:"SEO Title"}),!n&&r.jsx(uo,{productId:w,field:"title",context:c.name?{name:c.name}:{},onApply:j=>p("seoTitle",j),className:"scale-90 origin-right"})]}),r.jsx(xe,{value:c.seoTitle??"",onChange:j=>p("seoTitle",j.target.value),placeholder:c.name??"SEO title..."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(ze,{children:"SEO Description"}),!n&&r.jsx(uo,{productId:w,field:"seoDescription",context:{...c.name?{name:c.name}:{},...c.seoDescription?{current:c.seoDescription}:{}},onApply:j=>p("seoDescription",j),className:"scale-90 origin-right"})]}),r.jsx(cn,{value:c.seoDescription??"",onChange:j=>p("seoDescription",j.target.value),placeholder:"Meta description for search engines...",rows:3})]}),r.jsxs("div",{className:"pt-2 border-t border-zinc-100",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-3",children:"Preview"}),r.jsx(ij,{title:c.seoTitle||c.name||"",description:c.seoDescription||c.shortDescription||"",url:`https://yourstore.com/products/${c.slug??""}`})]})]})})]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Status"}),r.jsxs(vr,{value:c.status??"draft",onValueChange:j=>p("status",j),children:[r.jsx(Wn,{"data-testid":q("product","status"),children:r.jsx(yr,{})}),r.jsxs(Gn,{children:[r.jsx(Ue,{value:"draft",children:"Draft"}),r.jsx(Ue,{value:"active",children:"Active"}),r.jsx(Ue,{value:"archived",children:"Archived"})]})]}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[c.status==="draft"&&"Not visible to customers.",c.status==="active"&&"Visible and purchasable.",c.status==="archived"&&"Hidden, not purchasable."]})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Product Type"}),r.jsxs(vr,{value:c.type??"simple",onValueChange:j=>p("type",j),children:[r.jsx(Wn,{children:r.jsx(yr,{})}),r.jsxs(Gn,{children:[r.jsx(Ue,{value:"simple",children:"Simple"}),r.jsx(Ue,{value:"variable",children:"Variable"})]})]})]}),!n&&s&&r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-2 text-xs text-zinc-500",children:[r.jsx("h3",{className:"font-semibold uppercase tracking-wider text-zinc-400",children:"Summary"}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Variants"}),r.jsx("span",{className:"font-medium text-zinc-700",children:s.variants.length})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Total stock"}),r.jsx("span",{className:"font-mono font-medium text-zinc-700",children:s.variants.reduce((j,C)=>j+C.stock,0)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Media"}),r.jsx("span",{className:"font-medium text-zinc-700",children:s.media.length})]})]})]})]})]})}const dj={breadcrumb:e=>"Edit"},uj={breadcrumb:()=>"New Product"},fj=[{value:"manual",label:"Manual"},{value:"return",label:"Return"},{value:"import",label:"Import"},{value:"sale",label:"Sale"},{value:"reservation-commit",label:"Reservation"},{value:"reservation-release",label:"Release"}];function hj({row:e,onAdjust:t}){const[n,s]=l.useState(0),[o,a]=l.useState("manual"),[i,c]=l.useState(!1),[u,d]=Tf(),h=()=>{n!==0&&(t(n,o,u),d(),s(0),c(!0),setTimeout(()=>c(!1),1500))};return r.jsxs("div",{className:"flex items-center gap-2","data-testid":q("inventory","adjust",e.variantId),children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>s(f=>f-1),className:"flex h-7 w-7 items-center justify-center rounded border border-zinc-200 text-zinc-500 hover:bg-zinc-50 hover:text-zinc-700",children:r.jsx(rp,{className:"h-3 w-3"})}),r.jsx("input",{type:"number",value:n,onChange:f=>s(parseInt(f.target.value)||0),className:k("h-7 w-16 rounded border text-center text-sm font-mono focus:outline-none focus:ring-1 focus:ring-blue-500",n>0&&"border-green-300 text-green-700 bg-green-50",n<0&&"border-red-300 text-red-700 bg-red-50",n===0&&"border-zinc-200")}),r.jsx("button",{onClick:()=>s(f=>f+1),className:"flex h-7 w-7 items-center justify-center rounded border border-zinc-200 text-zinc-500 hover:bg-zinc-50 hover:text-zinc-700",children:r.jsx(mr,{className:"h-3 w-3"})})]}),r.jsxs(vr,{value:o,onValueChange:f=>a(f),children:[r.jsx(Wn,{className:"h-7 w-28 text-xs",children:r.jsx(yr,{})}),r.jsx(Gn,{children:fj.map(f=>r.jsx(Ue,{value:f.value,children:f.label},f.value))})]}),r.jsx(ue,{size:"sm",variant:i?"secondary":"default",className:"h-7 px-2 text-xs gap-1",onClick:h,disabled:n===0||i,children:i?r.jsxs(r.Fragment,{children:[r.jsx(Yn,{className:"h-3 w-3 text-green-600"}),r.jsx("span",{className:"text-green-600",children:"Done"})]}):"Apply"})]})}const mj=Na,pj=Ca,Af=l.forwardRef(({className:e,...t},n)=>r.jsx(Ts,{className:k("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Af.displayName="SheetOverlay";const xj=ys("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-lg"}},defaultVariants:{side:"right"}}),Mf=l.forwardRef(({side:e="right",className:t,children:n,...s},o)=>r.jsxs(pj,{children:[r.jsx(Af,{}),r.jsxs(As,{ref:o,className:k(xj({side:e}),"border-zinc-200",t),...s,children:[n,r.jsxs(Zl,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:pointer-events-none",children:[r.jsx(vs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mf.displayName="SheetContent";const _f=({className:e,...t})=>r.jsx("div",{className:k("flex flex-col space-y-2 text-left",e),...t});_f.displayName="SheetHeader";const If=l.forwardRef(({className:e,...t},n)=>r.jsx(Sa,{ref:n,className:k("text-lg font-semibold text-zinc-900",e),...t}));If.displayName="SheetTitle";const gj=l.forwardRef(({className:e,...t},n)=>r.jsx(Ea,{ref:n,className:k("text-sm text-zinc-500",e),...t}));gj.displayName="SheetDescription";function vj(e={}){return Ae({queryKey:["inventory","list",e],queryFn:()=>ae.get("/api/admin/inventory",e)})}function yj(e){return Ae({queryKey:["inventory","history",e],queryFn:()=>ae.get(`/api/admin/inventory/${e}/history`),enabled:!!e})}function bj(){const e=be();return Se({mutationFn:({variantId:t,delta:n,reason:s,idempotencyKey:o})=>ae.post(`/api/admin/inventory/${t}/adjust`,{delta:n,reason:s},o===void 0?void 0:{idempotencyKey:o}),onMutate:async({variantId:t,delta:n})=>{await e.cancelQueries({queryKey:["inventory","list"]});const s=e.getQueryData(["inventory","list",{}]);return s&&e.setQueryData(["inventory","list",{}],s.map(o=>o.variantId===t?{...o,stock:Math.max(0,o.stock+n)}:o)),{previousData:s}},onError:(t,n,s)=>{s!=null&&s.previousData&&e.setQueryData(["inventory","list",{}],s.previousData)},onSuccess:()=>{e.invalidateQueries({queryKey:["inventory"]})}})}function wj({variantId:e,productName:t,sku:n,onClose:s}){const{data:o,isLoading:a}=yj(e);return r.jsx(mj,{open:!0,onOpenChange:i=>!i&&s(),children:r.jsxs(Mf,{className:"w-[480px] sm:max-w-[480px] overflow-y-auto",children:[r.jsxs(_f,{children:[r.jsx(If,{children:"Stock History"}),r.jsxs("div",{className:"mt-1",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-700",children:t}),r.jsx("p",{className:"font-mono text-xs text-zinc-400",children:n})]})]}),r.jsx("div",{className:"mt-6",children:a?r.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((i,c)=>r.jsx(ve,{className:"h-12 w-full"},c))}):!o||o.length===0?r.jsx("p",{className:"text-sm text-zinc-400 text-center py-8",children:"No adjustment history found."}):r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Date"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Adj"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"New Qty"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Reason"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Actor"})]})}),r.jsx("tbody",{children:o.map(i=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0",children:[r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 whitespace-nowrap",children:wt(i.timestamp)}),r.jsxs("td",{className:k("px-3 py-2 text-right font-mono text-sm font-medium",i.adjustment>0?"text-green-600":"text-red-600"),children:[i.adjustment>0?"+":"",i.adjustment]}),r.jsx("td",{className:"px-3 py-2 text-right font-mono text-sm text-zinc-700",children:i.newQty}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 capitalize",children:i.reason.replace(/-/g," ")}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500",children:i.actor})]},i.id))})]})})})]})})}const jj={in_stock:"success",low_stock:"warning",out_of_stock:"destructive"},Ui={in_stock:"In Stock",low_stock:"Low Stock",out_of_stock:"Out of Stock"};function Nj(){const[e,t]=l.useState(""),[n,s]=l.useState("all"),[o,a]=l.useState(null),{data:i,isLoading:c}=vj({q:e||void 0,status:n==="all"?void 0:n,sort:"urgency",limit:200}),u=bj(),d=f=>(m,g,v)=>{u.mutateAsync({variantId:f,delta:m,reason:g,idempotencyKey:v})},h=f=>f==="out_of_stock"?"border-l-4 border-l-red-300":f==="low_stock"?"border-l-4 border-l-amber-300":"";return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inventory"}),r.jsx("p",{className:"text-sm text-zinc-500",children:i?`${i.length} variants`:"Loading..."})]})}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx("div",{className:"flex gap-1.5",children:["all","out_of_stock","low_stock","in_stock"].map(f=>r.jsx("button",{onClick:()=>s(f),className:k("rounded-full px-3 py-1 text-xs font-medium transition-colors",n===f?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:f==="all"?"All":Ui[f]},f))}),r.jsxs("div",{className:"relative ml-auto max-w-xs flex-1",children:[r.jsx(Xn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(xe,{placeholder:"Search SKU or product...",value:e,onChange:f=>t(f.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:c?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((f,m)=>r.jsx(ve,{className:"h-11 w-full"},m))}):i!=null&&i.length?r.jsxs(gn,{children:[r.jsx(vn,{children:r.jsxs(Fe,{children:[r.jsx(te,{children:"Product"}),r.jsx(te,{children:"SKU / Options"}),r.jsx(te,{className:"text-right",children:"Stock"}),r.jsx(te,{className:"text-right",children:"Threshold"}),r.jsx(te,{children:"Status"}),r.jsx(te,{children:"Adjust"}),r.jsx(te,{className:"text-right",children:"History"})]})}),r.jsx(yn,{children:i.map(f=>r.jsxs(Fe,{"data-testid":q("inventory","row",f.variantId),className:k("transition-colors",h(f.status)),children:[r.jsx(ne,{children:r.jsx("p",{className:"font-medium text-zinc-800 text-sm",children:f.productName})}),r.jsx(ne,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-mono text-xs text-zinc-500",children:f.sku}),f.options.length>0&&r.jsx("p",{className:"text-[10px] text-zinc-400",children:f.options.map(m=>`${m.name}: ${m.value}`).join(" · ")})]})}),r.jsx(ne,{className:k("text-right font-mono text-base font-semibold",f.status==="out_of_stock"?"text-red-600":f.status==="low_stock"?"text-amber-600":"text-zinc-800"),children:f.stock}),r.jsx(ne,{className:"text-right font-mono text-sm text-zinc-400",children:f.threshold}),r.jsx(ne,{children:r.jsx(kf,{variant:jj[f.status],className:"text-[10px]",children:Ui[f.status]})}),r.jsx(ne,{children:r.jsx(hj,{row:f,onAdjust:d(f.variantId)})}),r.jsx(ne,{className:"text-right",children:r.jsxs("button",{onClick:()=>a(f),className:"flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-700 font-medium ml-auto",children:[r.jsx(os,{className:"h-3.5 w-3.5"}),"History"]})})]},f.variantId))})]}):r.jsx(vt,{icon:r.jsx(Cc,{className:"h-5 w-5"}),title:"No inventory found",description:"No variants match your filters."})}),o&&r.jsx(wj,{variantId:o.variantId,productName:o.productName,sku:o.sku,onClose:()=>a(null)})]})}const Cj={breadcrumb:()=>"Inventory"};function Sj(e={}){return Ae({queryKey:["customers","list",e],queryFn:async()=>(await ae.get("/api/admin/customers",e)).customers})}function Ej(e){return Ae({queryKey:["customers","detail",e],queryFn:()=>ae.get(`/api/admin/customers/${e}`),enabled:!!e})}function Rj(e){return Ae({queryKey:["customers","orders",e],queryFn:async()=>(await ae.get(`/api/admin/customers/${e}/orders`)).orders,enabled:!!e})}function Pj(){const e=be();return Se({mutationFn:({customerId:t,body:n})=>ae.post(`/api/admin/customers/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["customers","detail",n.customerId]})}})}function kj(){const e=yt(),[t,n]=l.useState(""),{data:s,isLoading:o}=Sj({q:t||void 0,limit:100});return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Customers"}),r.jsx("p",{className:"text-sm text-zinc-500",children:s?`${s.length} customers`:"Loading..."})]})}),r.jsxs("div",{className:"relative max-w-sm",children:[r.jsx(Xn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(xe,{placeholder:"Search by name or email...",value:t,onChange:a=>n(a.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:o?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((a,i)=>r.jsx(ve,{className:"h-11 w-full"},i))}):s!=null&&s.length?r.jsxs(gn,{children:[r.jsx(vn,{children:r.jsxs(Fe,{children:[r.jsx(te,{children:"Customer"}),r.jsx(te,{className:"text-right",children:"Orders"}),r.jsx(te,{className:"text-right",children:"Total Spent"}),r.jsx(te,{children:"Since"}),r.jsx(te,{className:"text-right",children:"Last Order"})]})}),r.jsx(yn,{children:s.map(a=>{var c;const i=[a.firstName,a.lastName].filter(Boolean).join(" ");return r.jsxs(Fe,{"data-testid":q("customers","row",a.id),className:"cursor-pointer",onClick:()=>e(`/customers/${a.id}`),children:[r.jsx(ne,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-zinc-100 text-xs font-semibold text-zinc-600",children:(((c=a.firstName)==null?void 0:c[0])??a.email[0]??"?").toUpperCase()}),r.jsxs("div",{children:[i&&r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:i}),r.jsx("p",{className:"text-xs text-zinc-500",children:a.email})]})]})}),r.jsx(ne,{className:"text-right font-mono text-sm text-zinc-700",children:a.orderCount}),r.jsx(ne,{className:"text-right font-mono text-sm text-zinc-700",children:pe(a.totalSpentMinor,"GBP")}),r.jsx(ne,{className:"text-sm text-zinc-500",children:wt(a.createdAt)}),r.jsx(ne,{className:"text-right text-sm text-zinc-400",children:a.orderCount>0?it(a.updatedAt):"—"})]},a.id)})})]}):r.jsx(vt,{icon:r.jsx(oa,{className:"h-5 w-5"}),title:"No customers found",description:t?"Try a different search.":"Customers will appear as orders are placed."})})]})}const Tj={breadcrumb:()=>"Customers"};function Aj({customer:e,stats:t}){var s;const n=[e.firstName,e.lastName].filter(Boolean).join(" ")||e.email;return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-zinc-200 text-lg font-semibold text-zinc-600",children:(((s=e.firstName)==null?void 0:s[0])??e.email[0]??"?").toUpperCase()}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h2",{className:"text-base font-semibold text-zinc-900 truncate",children:n}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Pc,{className:"h-3.5 w-3.5"}),e.email]}),e.phone&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(sp,{className:"h-3.5 w-3.5"}),e.phone]})]}),r.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-zinc-400",children:[r.jsx(Fm,{className:"h-3 w-3"}),"Customer since ",wt(e.createdAt)]})]}),e.requiresPasswordReset&&r.jsx("span",{className:"shrink-0 rounded-full bg-amber-100 px-2.5 py-0.5 text-xs font-medium text-amber-700",children:"Needs reset"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[r.jsx(fo,{icon:r.jsx(Bn,{className:"h-4 w-4 text-blue-500"}),label:"Total Orders",value:String(t.orderCount)}),r.jsx(fo,{icon:r.jsx(To,{className:"h-4 w-4 text-green-500"}),label:"Lifetime Value",value:pe(t.lifetimeRevenueMinor,"GBP"),mono:!0}),r.jsx(fo,{icon:r.jsx(To,{className:"h-4 w-4 text-indigo-500"}),label:"Avg Order",value:pe(t.avgOrderValueMinor,"GBP"),mono:!0})]}),t.lastOrderAt&&r.jsxs("p",{className:"text-xs text-zinc-400",children:["Last order: ",it(t.lastOrderAt)]})]})}function fo({icon:e,label:t,value:n,mono:s}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-white p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e,r.jsx("span",{className:"text-xs text-zinc-500",children:t})]}),r.jsx("p",{className:`text-base font-semibold text-zinc-900 ${s?"font-mono":""}`,children:n})]})}function Mj({orders:e,isLoading:t}){const n=yt();return t?r.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,o)=>r.jsx(ve,{className:"h-11 w-full"},o))}):!e||e.length===0?r.jsx(vt,{icon:r.jsx(Bn,{className:"h-5 w-5"}),title:"No orders",description:"This customer hasn't placed any orders yet."}):r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs(gn,{children:[r.jsx(vn,{children:r.jsxs(Fe,{children:[r.jsx(te,{children:"Order #"}),r.jsx(te,{children:"Status"}),r.jsx(te,{children:"Items"}),r.jsx(te,{className:"text-right",children:"Total"}),r.jsx(te,{className:"text-right",children:"Date"})]})}),r.jsx(yn,{children:e.map(s=>r.jsxs(Fe,{className:"cursor-pointer",onClick:()=>n(`/orders/${s.orderNumber}`),children:[r.jsxs(ne,{className:"font-mono text-sm font-medium text-blue-600",children:["#",s.orderNumber]}),r.jsx(ne,{children:r.jsx(qn,{status:s.status})}),r.jsxs(ne,{className:"text-zinc-500",children:[s.lineItems.length," item",s.lineItems.length!==1?"s":""]}),r.jsx(ne,{className:"text-right font-mono text-sm",children:pe(s.totalMinor,s.currency)}),r.jsx(ne,{className:"text-right text-sm text-zinc-500",children:it(s.createdAt)})]},s.id))})]})})}function _j({notes:e}){return r.jsx("div",{className:"space-y-2",children:e.length===0?r.jsx("p",{className:"text-sm text-zinc-400 italic",children:"No notes yet."}):[...e].sort((t,n)=>new Date(n.at).getTime()-new Date(t.at).getTime()).map((t,n)=>r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:t.body}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{className:"font-medium text-zinc-500",children:t.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:t.at,title:wt(t.at),children:it(t.at)})]})]},n))})}function Ij(){const{id:e}=Yo(),[t,n]=l.useState(""),{data:s,isLoading:o}=Ej(e??""),{data:a,isLoading:i}=Rj(e??""),c=Pj(),u=async g=>{g.preventDefault(),!(!t.trim()||!e)&&(await c.mutateAsync({customerId:e,body:t.trim()}),n(""))};if(o)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(ve,{className:"h-8 w-32"}),r.jsx(ve,{className:"h-32 w-full"}),r.jsx(ve,{className:"h-48 w-full"})]});if(!s)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx("p",{className:"text-sm text-zinc-500",children:"Customer not found"}),r.jsx(an,{to:"/customers",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to customers"})]});const{customer:d,stats:h}=s,f=[d.firstName,d.lastName].filter(Boolean).join(" ")||d.email,m=d.notes??[];return r.jsxs("div",{className:"space-y-5","data-testid":q("customer","detail"),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(an,{to:"/customers",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(ra,{className:"h-4 w-4"}),"Customers"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("span",{className:"text-sm font-medium text-zinc-900",children:f})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(Aj,{customer:d,stats:h})}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Order History"})}),r.jsx("div",{className:"p-4",children:r.jsx(Mj,{orders:a,isLoading:i})})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-3","data-testid":q("customer","notes"),children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Notes"}),r.jsx(_j,{notes:m}),r.jsxs("form",{onSubmit:g=>void u(g),className:"flex gap-2 pt-2",children:[r.jsx(cn,{placeholder:"Add a note about this customer...",value:t,onChange:g=>n(g.target.value),rows:2,className:"flex-1 text-sm"}),r.jsx(ue,{type:"submit",size:"icon",disabled:!t.trim()||c.isPending,className:"self-end h-9 w-9",children:r.jsx(kc,{className:"h-4 w-4"})})]})]})]})}const Oj={breadcrumb:e=>"Customer"},Of=(e,t)=>`/api/admin/settings/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;function Dj(){return Ae({queryKey:["settings"],queryFn:()=>ae.get("/api/admin/settings")})}function zj(){const e=be();return Se({mutationFn:({slot:t,path:n,value:s})=>ae.put(Of(t,n),{value:s}),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}function Lj(){const e=be();return Se({mutationFn:({slot:t,path:n})=>ae.delete(Of(t,n)),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}const Fj={payments:"Payments",email:"Email",reviews:"Reviews",search:"Search",analytics:"Analytics",shipping:"Shipping",tax:"Tax",ai:"AI"},$j=(e,t)=>`${e}-${t}`;function Uj(e){return e.source==="config"||e.source==="env"?"Set by environment":e.secret?e.state==="set"?"Set":"Not set":e.state==="set"?String(e.value??""):"Not set"}function Vj({slot:e,field:t,onSaved:n}){const s=l.useRef(null),o=zj(),a=Lj(),[i,c]=l.useState(null),u=l.useRef(!1),d=$j(e,t.path),h=t.source==="config"||t.source==="env",f=async()=>{var v;const g=((v=s.current)==null?void 0:v.value)??"";if(!(g===""||u.current)){u.current=!0,c(null);try{await o.mutateAsync({slot:e,path:t.path,value:g}),s.current&&(s.current.value=""),n()}catch(p){c(p instanceof Vn?p.message:"The value was not saved")}finally{u.current=!1}}},m=async()=>{c(null);try{await a.mutateAsync({slot:e,path:t.path}),n()}catch(g){c(g instanceof Vn?g.message:"The value was not cleared")}};return r.jsxs("div",{"data-testid":`settings-field-${d}`,className:"flex flex-col gap-2 border-b border-zinc-100 py-3 last:border-b-0 sm:flex-row sm:items-center",children:[r.jsxs("div",{className:"min-w-0 sm:w-56",children:[r.jsx("label",{htmlFor:`settings-input-${d}`,className:"text-sm font-medium text-zinc-900",children:t.label}),r.jsx("p",{className:"font-mono text-[11px] text-zinc-500",children:t.path})]}),r.jsx("span",{"data-testid":`settings-state-${d}`,className:"min-w-0 truncate text-sm text-zinc-600 sm:w-44",children:Uj(t)}),!h&&r.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(xe,{ref:s,id:`settings-input-${d}`,"data-testid":`settings-input-${d}`,type:t.secret?"password":"text",autoComplete:"off",spellCheck:!1,placeholder:t.secret&&t.state==="set"?"Enter a new value":""}),r.jsx(ue,{type:"button",size:"sm",className:"h-9","data-testid":`settings-save-${d}`,disabled:o.isPending,onClick:()=>void f(),children:"Save"}),t.source==="settings"&&r.jsx(ue,{type:"button",size:"sm",variant:"outline",className:"h-9","data-testid":`settings-clear-${d}`,disabled:a.isPending,onClick:()=>void m(),children:"Clear"})]}),i!==null&&r.jsx("p",{role:"alert",className:"text-xs text-red-600",children:i})]})]})}function Bj({slot:e,onSaved:t}){return r.jsxs("section",{className:"rounded-lg border border-zinc-200 bg-white px-4",children:[r.jsxs("header",{className:"flex items-baseline gap-2 border-b border-zinc-100 py-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:Fj[e.slot]??e.slot}),r.jsx("span",{className:"text-xs text-zinc-500",children:e.provider})]}),e.fields.map(n=>r.jsx(Vj,{slot:e.slot,field:n,onSaved:t},n.path))]})}function Kj(){const{data:e,isLoading:t}=Dj(),[n,s]=l.useState(!1);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Settings"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Keys and credentials for the services this store uses. The config and environment always win."})]}),n&&r.jsx("p",{"data-testid":"settings-restart-note",role:"status",className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:"Saved. Restart the store to apply."}),t?r.jsx(ve,{className:"h-40 w-full"}):e===void 0||e.slots.length===0?r.jsx(vt,{icon:r.jsx(Zm,{className:"h-5 w-5"}),title:"Nothing to set here",description:"None of this store's providers takes keys from Settings."}):e.slots.map(o=>r.jsx(Bj,{slot:o,onSaved:()=>s(!0)},o.slot))]})}const Hj={breadcrumb:()=>"Settings"},qj=100;function Wj(e){return Oh({queryKey:["activity",e],initialPageParam:void 0,queryFn:({pageParam:t})=>ae.getPage("/api/admin/activity",{...e,limit:qj,cursor:t}),getNextPageParam:t=>{var s;const n=(s=t.meta)==null?void 0:s.nextCursor;return typeof n=="string"&&n!==""?n:void 0}})}function Gj(e){return ae.getText("/api/admin/activity/export",e)}const Qj={applied:"bg-green-50 text-green-700",refused:"bg-red-50 text-red-700",replayed:"bg-zinc-100 text-zinc-600"};function Vi(e){if(e==="")return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function Yj(e){const t={};for(const o of["actor","command","subject","correlation","outcome"]){const a=e[o].trim();a!==""&&(t[o]=a)}const n=Vi(e.since),s=Vi(e.until);return n!==void 0&&(t.since=n),s!==void 0&&(t.until=s),t}function Xj(e){const t=URL.createObjectURL(new Blob([e],{type:"application/x-ndjson"})),n=document.createElement("a");n.href=t,n.download=`activity-${new Date().toISOString().slice(0,10)}.ndjson`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)}const Zj={actor:"",command:"",subject:"",correlation:"",outcome:"",since:"",until:""};function Jj(){const[e,t]=l.useState(Zj),[n,s]=l.useState(!1),[o,a]=l.useState(null),i=Yj(e),{data:c,isLoading:u,isError:d,fetchNextPage:h,hasNextPage:f,isFetchingNextPage:m}=Wj(i),g=(c==null?void 0:c.pages.flatMap(x=>x.data))??[],v=x=>y=>t(w=>({...w,[x]:y})),p=async()=>{s(!0),a(null);try{const{since:x,until:y,correlation:w}=i;Xj(await Gj({...x!==void 0&&{since:x},...y!==void 0&&{until:y},...w!==void 0&&{correlation:w}}))}catch(x){a(x instanceof Error?x.message:String(x))}finally{s(!1)}};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Activity"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Who changed what, newest first. The export covers the time and correlation filters."})]}),r.jsxs(ue,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void p(),disabled:n,"data-testid":"activity-export",children:[n?r.jsx(sa,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(Gm,{className:"h-3.5 w-3.5"}),"Export"]})]}),o&&r.jsxs("p",{className:"text-sm text-red-600",children:["Export failed: ",o]}),r.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(xe,{placeholder:"Actor (admin:<id>, system, …)",value:e.actor,onChange:x=>v("actor")(x.target.value),className:"h-8 text-sm","aria-label":"Actor","data-testid":"activity-filter-actor"}),r.jsx(xe,{placeholder:"Command (inventory.adjust, …)",value:e.command,onChange:x=>v("command")(x.target.value),className:"h-8 text-sm","aria-label":"Command","data-testid":"activity-filter-command"}),r.jsx(xe,{placeholder:"Subject id",value:e.subject,onChange:x=>v("subject")(x.target.value),className:"h-8 text-sm","aria-label":"Subject","data-testid":"activity-filter-subject"}),r.jsx(xe,{placeholder:"Correlation id",value:e.correlation,onChange:x=>v("correlation")(x.target.value),className:"h-8 text-sm","aria-label":"Correlation id","data-testid":"activity-filter-correlation"}),r.jsxs("select",{value:e.outcome,onChange:x=>v("outcome")(x.target.value),className:"h-8 rounded-md border border-zinc-200 bg-white px-2 text-sm","aria-label":"Outcome","data-testid":"activity-filter-outcome",children:[r.jsx("option",{value:"",children:"Any outcome"}),r.jsx("option",{value:"applied",children:"Applied"}),r.jsx("option",{value:"refused",children:"Refused"}),r.jsx("option",{value:"replayed",children:"Replayed"})]}),r.jsx(xe,{type:"datetime-local",value:e.since,onChange:x=>v("since")(x.target.value),className:"h-8 text-sm","aria-label":"From","data-testid":"activity-filter-since"}),r.jsx(xe,{type:"datetime-local",value:e.until,onChange:x=>v("until")(x.target.value),className:"h-8 text-sm","aria-label":"Until","data-testid":"activity-filter-until"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-x-auto",children:u?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((x,y)=>r.jsx(ve,{className:"h-11 w-full"},y))}):d?r.jsx(vt,{icon:r.jsx(os,{className:"h-5 w-5"}),title:"Activity could not be loaded"}):g.length===0?r.jsx(vt,{icon:r.jsx(os,{className:"h-5 w-5"}),title:"No activity found",description:"Changes to the store appear here as they are made."}):r.jsxs(gn,{children:[r.jsx(vn,{children:r.jsxs(Fe,{children:[r.jsx(te,{children:"Time"}),r.jsx(te,{children:"Actor"}),r.jsx(te,{children:"Command"}),r.jsx(te,{children:"Subjects"}),r.jsx(te,{children:"Outcome"}),r.jsx(te,{children:"Correlation id"})]})}),r.jsx(yn,{children:g.map(x=>r.jsxs(Fe,{"data-testid":`activity-row-${x.id}`,children:[r.jsx(ne,{className:"whitespace-nowrap text-xs text-zinc-500",children:wt(x.at)}),r.jsxs(ne,{className:"font-mono text-xs",children:[x.actor.kind,":",x.actor.id]}),r.jsx(ne,{className:"font-mono text-xs",children:x.command}),r.jsx(ne,{className:"font-mono text-xs text-zinc-600",children:x.subjects.map(y=>r.jsxs("div",{children:[y.type,":",y.id]},`${y.type}:${y.id}`))}),r.jsx(ne,{children:r.jsxs("span",{className:k("rounded-full px-2 py-0.5 text-[11px] font-medium",Qj[x.outcome]),children:[x.outcome,x.responseStatus!==null&&` ${x.responseStatus}`]})}),r.jsx(ne,{className:"font-mono text-xs text-zinc-500",children:x.correlationId??""})]},x.id))})]})}),f&&r.jsx(ue,{variant:"outline",size:"sm",onClick:()=>void h(),disabled:m,children:m?"Loading…":"Load more"})]})}const eN={breadcrumb:()=>"Activity"};function tN(){const e=yt();return r.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[r.jsx("p",{className:"font-mono text-5xl font-bold text-zinc-200",children:"404"}),r.jsx("h2",{className:"mt-3 text-base font-semibold text-zinc-700",children:"Page not found"}),r.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"The page you're looking for doesn't exist."}),r.jsx("div",{className:"mt-6",children:r.jsx(ue,{variant:"outline",onClick:()=>e("/"),children:"Go to Dashboard"})})]})}let Bi=null;async function nN(){return ss()?null:(Bi??(Bi=_m()),await Bi,ss()?null:Kf("/login"))}const Df=Bf([{path:"/login",element:r.jsx(ay,{})},{path:"/",element:r.jsx(ny,{}),loader:nN,handle:{breadcrumb:()=>null},children:[{index:!0,element:r.jsx(my,{}),handle:{breadcrumb:()=>"Dashboard"}},{path:"orders",handle:Qb,children:[{index:!0,element:r.jsx(Gb,{})},{path:":orderNumber",element:r.jsx(Kw,{}),handle:Hw}]},{path:"products",handle:rj,children:[{index:!0,element:r.jsx(nj,{})},{path:"new",element:r.jsx($i,{}),handle:uj},{path:":slug",element:r.jsx($i,{}),handle:dj}]},{path:"inventory",element:r.jsx(Nj,{}),handle:Cj},{path:"customers",handle:Tj,children:[{index:!0,element:r.jsx(kj,{})},{path:":id",element:r.jsx(Ij,{}),handle:Oj}]},{path:"activity",element:r.jsx(Jj,{}),handle:eN},{path:"settings",element:r.jsx(Kj,{}),handle:Hj},{path:"*",element:r.jsx(tN,{})}]}],{basename:"/admin"});km(()=>{rs.clear(),Df.navigate("/login")});const zf=document.getElementById("root");if(!zf)throw new Error("Root element not found");rc(zf).render(r.jsx(l.StrictMode,{children:r.jsx(Ch,{client:rs,children:r.jsx(Hf,{router:Df})})}));