@nymbalhq/admin 1.7.0 → 1.8.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,323 @@
1
+ var hi=e=>{throw TypeError(e)};var la=(e,t,n)=>t.has(e)||hi("Cannot "+n);var b=(e,t,n)=>(la(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?hi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_=(e,t,n,s)=>(la(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),ee=(e,t,n)=>(la(e,t,"access private method"),n);var Qr=(e,t,n,s)=>({set _(a){_(e,t,a,n)},get _(){return b(e,t,s)}});import{r as hh,a as mh,b as l,u as Ct,N as ph,c as xh,L as Ve,d as Ts,R as go,e as gh,f as Ze,g as vh,O as yh,h as vo,i as Ac,j as bh,k as wh,l as jh}from"./vendor-0v2ry8Wl.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var da={exports:{}},ur={};/**
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 mi;function Nh(){if(mi)return ur;mi=1;var e=hh(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(i,f,u){var d,h={},m=null,x=null;u!==void 0&&(m=""+u),f.key!==void 0&&(m=""+f.key),f.ref!==void 0&&(x=f.ref);for(d in f)s.call(f,d)&&!o.hasOwnProperty(d)&&(h[d]=f[d]);if(i&&i.defaultProps)for(d in f=i.defaultProps,f)h[d]===void 0&&(h[d]=f[d]);return{$$typeof:t,type:i,key:m,ref:x,props:h,_owner:a.current}}return ur.Fragment=n,ur.jsx=c,ur.jsxs=c,ur}var pi;function Ch(){return pi||(pi=1,da.exports=Nh()),da.exports}var r=Ch(),Yr={},xi;function Sh(){if(xi)return Yr;xi=1;var e=mh();return Yr.createRoot=e.createRoot,Yr.hydrateRoot=e.hydrateRoot,Yr}var Eh=Sh(),er=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(){}},sn,_t,On,bc,Rh=(bc=class extends er{constructor(){super();$(this,sn);$(this,_t);$(this,On);_(this,On,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){b(this,_t)||this.setEventListener(b(this,On))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,_t))==null||t.call(this),_(this,_t,void 0))}setEventListener(t){var n;_(this,On,t),(n=b(this,_t))==null||n.call(this),_(this,_t,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){b(this,sn)!==t&&(_(this,sn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof b(this,sn)=="boolean"?b(this,sn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},sn=new WeakMap,_t=new WeakMap,On=new WeakMap,bc),yo=new Rh,Ph={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},It,xo,wc,kh=(wc=class{constructor(){$(this,It,Ph);$(this,xo,!1)}setTimeoutProvider(e){_(this,It,e)}setTimeout(e,t){return b(this,It).setTimeout(e,t)}clearTimeout(e){b(this,It).clearTimeout(e)}setInterval(e,t){return b(this,It).setInterval(e,t)}clearInterval(e){b(this,It).clearInterval(e)}},It=new WeakMap,xo=new WeakMap,wc),rn=new kh;function Th(e){setTimeout(e,0)}var Ah=typeof window>"u"||"Deno"in globalThis;function Te(){}function Mh(e,t){return typeof e=="function"?e(t):e}function Aa(e){return typeof e=="number"&&e>=0&&e!==1/0}function Mc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Vt(e,t){return typeof e=="function"?e(t):e}function Fe(e,t){return typeof e=="function"?e(t):e}function gi(e,t){const{type:n="all",exact:s,fetchStatus:a,predicate:o,queryKey:c,stale:i}=e;if(c){if(s){if(t.queryHash!==bo(c,t.options))return!1}else if(!yr(t.queryKey,c))return!1}if(n!=="all"){const f=t.isActive();if(n==="active"&&!f||n==="inactive"&&f)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||a&&a!==t.state.fetchStatus||o&&!o(t))}function vi(e,t){const{exact:n,status:s,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(mn(t.options.mutationKey)!==mn(o))return!1}else if(!yr(t.options.mutationKey,o))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function bo(e,t){return((t==null?void 0:t.queryKeyHashFn)||mn)(e)}function mn(e){return JSON.stringify(e,(t,n)=>Ma(n)?Object.keys(n).sort().reduce((s,a)=>(s[a]=n[a],s),{}):n)}function yr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>yr(e[n],t[n])):!1}var _h=Object.prototype.hasOwnProperty;function _c(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=yi(e)&&yi(t);if(!s&&!(Ma(e)&&Ma(t)))return t;const o=(s?e:Object.keys(e)).length,c=s?t:Object.keys(t),i=c.length,f=s?new Array(i):{};let u=0;for(let d=0;d<i;d++){const h=s?d:c[d],m=e[h],x=t[h];if(m===x){f[h]=m,(s?d<o:_h.call(e,h))&&u++;continue}if(m===null||x===null||typeof m!="object"||typeof x!="object"){f[h]=x;continue}const g=_c(m,x,n+1);f[h]=g,g===m&&u++}return o===i&&u===o?e:f}function ms(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 yi(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ma(e){if(!bi(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!bi(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function bi(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ih(e){return new Promise(t=>{rn.setTimeout(t,e)})}function _a(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?_c(e,t):t}function Oh(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function Dh(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var wo=Symbol();function Ic(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===wo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function jo(e,t){return typeof e=="function"?e(...t):!!e}function zh(e,t,n){let s=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),s||(s=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var br=(()=>{let e=()=>Ah;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ia(){let e,t;const n=new Promise((a,o)=>{e=a,t=o});n.status="pending",n.catch(()=>{});function s(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},n.reject=a=>{s({status:"rejected",reason:a}),t(a)},n}var Lh=Th;function Fh(){let e=[],t=0,n=i=>{i()},s=i=>{i()},a=Lh;const o=i=>{t?e.push(i):a(()=>{n(i)})},c=()=>{const i=e;e=[],i.length&&a(()=>{s(()=>{i.forEach(f=>{n(f)})})})};return{batch:i=>{let f;t++;try{f=i()}finally{t--,t||c()}return f},batchCalls:i=>(...f)=>{o(()=>{i(...f)})},schedule:o,setNotifyFunction:i=>{n=i},setBatchNotifyFunction:i=>{s=i},setScheduler:i=>{a=i}}}var be=Fh(),Dn,Ot,zn,jc,$h=(jc=class extends er{constructor(){super();$(this,Dn,!0);$(this,Ot);$(this,zn);_(this,zn,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,Ot)||this.setEventListener(b(this,zn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,Ot))==null||t.call(this),_(this,Ot,void 0))}setEventListener(t){var n;_(this,zn,t),(n=b(this,Ot))==null||n.call(this),_(this,Ot,t(this.setOnline.bind(this)))}setOnline(t){b(this,Dn)!==t&&(_(this,Dn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return b(this,Dn)}},Dn=new WeakMap,Ot=new WeakMap,zn=new WeakMap,jc),ps=new $h;function Uh(e){return Math.min(1e3*2**e,3e4)}function Oc(e){return(e??"online")==="online"?ps.isOnline():!0}var Oa=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Dc(e){let t=!1,n=0,s;const a=Ia(),o=()=>a.status!=="pending",c=p=>{var v;if(!o()){const y=new Oa(p);m(y),(v=e.onCancel)==null||v.call(e,y)}},i=()=>{t=!0},f=()=>{t=!1},u=()=>yo.isFocused()&&(e.networkMode==="always"||ps.isOnline())&&e.canRun(),d=()=>Oc(e.networkMode)&&e.canRun(),h=p=>{o()||(s==null||s(),a.resolve(p))},m=p=>{o()||(s==null||s(),a.reject(p))},x=()=>new Promise(p=>{var v;s=y=>{(o()||u())&&p(y)},(v=e.onPause)==null||v.call(e)}).then(()=>{var p;s=void 0,o()||(p=e.onContinue)==null||p.call(e)}),g=()=>{if(o())return;let p;const v=n===0?e.initialPromise:void 0;try{p=v??e.fn()}catch(y){p=Promise.reject(y)}Promise.resolve(p).then(h).catch(y=>{var C;if(o())return;const w=e.retry??(br.isServer()?0:3),N=e.retryDelay??Uh,j=typeof N=="function"?N(n,y):N,S=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!S){m(y);return}n++,(C=e.onFail)==null||C.call(e,n,y),Ih(j).then(()=>u()?void 0:x()).then(()=>{t?m(y):g()})})};return{promise:a,status:()=>a.status,cancel:c,continue:()=>(s==null||s(),a),cancelRetry:i,continueRetry:f,canStart:d,start:()=>(d()?g():x().then(g),a)}}var an,Nc,zc=(Nc=class{constructor(){$(this,an)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Aa(this.gcTime)&&_(this,an,rn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(br.isServer()?1/0:300*1e3))}clearGcTimeout(){b(this,an)!==void 0&&(rn.clearTimeout(b(this,an)),_(this,an,void 0))}},an=new WeakMap,Nc),on,Ln,qe,cn,je,Pr,ln,Le,Lc,pt,Cc,Vh=(Cc=class extends zc{constructor(t){super();$(this,Le);$(this,on);$(this,Ln);$(this,qe);$(this,cn);$(this,je);$(this,Pr);$(this,ln);_(this,ln,!1),_(this,Pr,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,cn,t.client),_(this,qe,b(this,cn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,on,ji(this.options)),this.state=t.state??b(this,on),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=b(this,je))==null?void 0:t.promise}setOptions(t){if(this.options={...b(this,Pr),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=ji(this.options);n.data!==void 0&&(this.setState(wi(n.data,n.dataUpdatedAt)),_(this,on,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&b(this,qe).remove(this)}setData(t,n){const s=_a(this.state.data,t,this.options);return ee(this,Le,pt).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(t,n){ee(this,Le,pt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var s,a;const n=(s=b(this,je))==null?void 0:s.promise;return(a=b(this,je))==null||a.cancel(t),n?n.then(Te).catch(Te):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return b(this,on)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Fe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===wo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Vt(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:!Mc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,je))==null||n.continue()}onOnline(){var n;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,je))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),b(this,qe).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,je)&&(b(this,ln)||ee(this,Le,Lc).call(this)?b(this,je).cancel({revert:!0}):b(this,je).cancelRetry()),this.scheduleGc()),b(this,qe).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ee(this,Le,pt).call(this,{type:"invalidate"})}async fetch(t,n){var f,u,d,h,m,x,g,p,v,y,w,N;if(this.state.fetchStatus!=="idle"&&((f=b(this,je))==null?void 0:f.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(b(this,je))return b(this,je).continueRetry(),b(this,je).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(S=>S.options.queryFn);j&&this.setOptions(j.options)}const s=new AbortController,a=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(_(this,ln,!0),s.signal)})},o=()=>{const j=Ic(this.options,n),C=(()=>{const E={client:b(this,cn),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return _(this,ln,!1),this.options.persister?this.options.persister(j,C,this):j(C)},i=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:b(this,cn),state:this.state,fetchFn:o};return a(j),j})();(u=this.options.behavior)==null||u.onFetch(i,this),_(this,Ln,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=i.fetchOptions)==null?void 0:d.meta))&&ee(this,Le,pt).call(this,{type:"fetch",meta:(h=i.fetchOptions)==null?void 0:h.meta}),_(this,je,Dc({initialPromise:n==null?void 0:n.initialPromise,fn:i.fetchFn,onCancel:j=>{j instanceof Oa&&j.revert&&this.setState({...b(this,Ln),fetchStatus:"idle"}),s.abort()},onFail:(j,S)=>{ee(this,Le,pt).call(this,{type:"failed",failureCount:j,error:S})},onPause:()=>{ee(this,Le,pt).call(this,{type:"pause"})},onContinue:()=>{ee(this,Le,pt).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const j=await b(this,je).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(x=(m=b(this,qe).config).onSuccess)==null||x.call(m,j,this),(p=(g=b(this,qe).config).onSettled)==null||p.call(g,j,this.state.error,this),j}catch(j){if(j instanceof Oa){if(j.silent)return b(this,je).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw ee(this,Le,pt).call(this,{type:"error",error:j}),(y=(v=b(this,qe).config).onError)==null||y.call(v,j,this),(N=(w=b(this,qe).config).onSettled)==null||N.call(w,this.state.data,j,this),j}finally{this.scheduleGc()}}},on=new WeakMap,Ln=new WeakMap,qe=new WeakMap,cn=new WeakMap,je=new WeakMap,Pr=new WeakMap,ln=new WeakMap,Le=new WeakSet,Lc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},pt=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,...Fc(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...wi(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Ln,t.manual?a:void 0),a;case"error":const o=t.error;return{...s,error:o,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),b(this,qe).notify({query:this,type:"updated",action:t})})},Cc);function Fc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Oc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function wi(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ji(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 _e,oe,kr,ke,dn,Fn,xt,Dt,Tr,$n,Un,un,fn,zt,Vn,fe,xr,Da,za,La,Fa,$a,Ua,Va,Uc,Sc,$c=(Sc=class extends er{constructor(t,n){super();$(this,fe);$(this,_e);$(this,oe);$(this,kr);$(this,ke);$(this,dn);$(this,Fn);$(this,xt);$(this,Dt);$(this,Tr);$(this,$n);$(this,Un);$(this,un);$(this,fn);$(this,zt);$(this,Vn,new Set);this.options=n,_(this,_e,t),_(this,Dt,null),_(this,xt,Ia()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(b(this,oe).addObserver(this),Ni(b(this,oe),this.options)?ee(this,fe,xr).call(this):this.updateResult(),ee(this,fe,Fa).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ba(b(this,oe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ba(b(this,oe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ee(this,fe,$a).call(this),ee(this,fe,Ua).call(this),b(this,oe).removeObserver(this)}setOptions(t){const n=this.options,s=b(this,oe);if(this.options=b(this,_e).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Fe(this.options.enabled,b(this,oe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ee(this,fe,Va).call(this),b(this,oe).setOptions(this.options),n._defaulted&&!ms(this.options,n)&&b(this,_e).getQueryCache().notify({type:"observerOptionsUpdated",query:b(this,oe),observer:this});const a=this.hasListeners();a&&Ci(b(this,oe),s,this.options,n)&&ee(this,fe,xr).call(this),this.updateResult(),a&&(b(this,oe)!==s||Fe(this.options.enabled,b(this,oe))!==Fe(n.enabled,b(this,oe))||Vt(this.options.staleTime,b(this,oe))!==Vt(n.staleTime,b(this,oe)))&&ee(this,fe,Da).call(this);const o=ee(this,fe,za).call(this);a&&(b(this,oe)!==s||Fe(this.options.enabled,b(this,oe))!==Fe(n.enabled,b(this,oe))||o!==b(this,zt))&&ee(this,fe,La).call(this,o)}getOptimisticResult(t){const n=b(this,_e).getQueryCache().build(b(this,_e),t),s=this.createResult(n,t);return Kh(this,s)&&(_(this,ke,s),_(this,Fn,this.options),_(this,dn,b(this,oe).state)),s}getCurrentResult(){return b(this,ke)}trackResult(t,n){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&b(this,xt).status==="pending"&&b(this,xt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){b(this,Vn).add(t)}getCurrentQuery(){return b(this,oe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=b(this,_e).defaultQueryOptions(t),s=b(this,_e).getQueryCache().build(b(this,_e),n);return s.fetch().then(()=>this.createResult(s,n))}fetch(t){return ee(this,fe,xr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),b(this,ke)))}createResult(t,n){var z;const s=b(this,oe),a=this.options,o=b(this,ke),c=b(this,dn),i=b(this,Fn),u=t!==s?t.state:b(this,kr),{state:d}=t;let h={...d},m=!1,x;if(n._optimisticResults){const O=this.hasListeners(),U=!O&&Ni(t,n),I=O&&Ci(t,s,n,a);(U||I)&&(h={...h,...Fc(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:g,errorUpdatedAt:p,status:v}=h;x=h.data;let y=!1;if(n.placeholderData!==void 0&&x===void 0&&v==="pending"){let O;o!=null&&o.isPlaceholderData&&n.placeholderData===(i==null?void 0:i.placeholderData)?(O=o.data,y=!0):O=typeof n.placeholderData=="function"?n.placeholderData((z=b(this,Un))==null?void 0:z.state.data,b(this,Un)):n.placeholderData,O!==void 0&&(v="success",x=_a(o==null?void 0:o.data,O,n),m=!0)}if(n.select&&x!==void 0&&!y)if(o&&x===(c==null?void 0:c.data)&&n.select===b(this,Tr))x=b(this,$n);else try{_(this,Tr,n.select),x=n.select(x),x=_a(o==null?void 0:o.data,x,n),_(this,$n,x),_(this,Dt,null)}catch(O){_(this,Dt,O)}b(this,Dt)&&(g=b(this,Dt),x=b(this,$n),p=Date.now(),v="error");const w=h.fetchStatus==="fetching",N=v==="pending",j=v==="error",S=N&&w,C=x!==void 0,k={status:v,fetchStatus:h.fetchStatus,isPending:N,isSuccess:v==="success",isError:j,isInitialLoading:S,isLoading:S,data:x,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!N,isLoadingError:j&&!C,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&C,isStale:No(t,n),refetch:this.refetch,promise:b(this,xt),isEnabled:Fe(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=k.data!==void 0,U=k.status==="error"&&!O,I=Z=>{U?Z.reject(k.error):O&&Z.resolve(k.data)},Q=()=>{const Z=_(this,xt,k.promise=Ia());I(Z)},V=b(this,xt);switch(V.status){case"pending":t.queryHash===s.queryHash&&I(V);break;case"fulfilled":(U||k.data!==V.value)&&Q();break;case"rejected":(!U||k.error!==V.reason)&&Q();break}}return k}updateResult(){const t=b(this,ke),n=this.createResult(b(this,oe),this.options);if(_(this,dn,b(this,oe).state),_(this,Fn,this.options),b(this,dn).data!==void 0&&_(this,Un,b(this,oe)),ms(n,t))return;_(this,ke,n);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!b(this,Vn).size)return!0;const c=new Set(o??b(this,Vn));return this.options.throwOnError&&c.add("error"),Object.keys(b(this,ke)).some(i=>{const f=i;return b(this,ke)[f]!==t[f]&&c.has(f)})};ee(this,fe,Uc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ee(this,fe,Fa).call(this)}},_e=new WeakMap,oe=new WeakMap,kr=new WeakMap,ke=new WeakMap,dn=new WeakMap,Fn=new WeakMap,xt=new WeakMap,Dt=new WeakMap,Tr=new WeakMap,$n=new WeakMap,Un=new WeakMap,un=new WeakMap,fn=new WeakMap,zt=new WeakMap,Vn=new WeakMap,fe=new WeakSet,xr=function(t){ee(this,fe,Va).call(this);let n=b(this,oe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Te)),n},Da=function(){ee(this,fe,$a).call(this);const t=Vt(this.options.staleTime,b(this,oe));if(br.isServer()||b(this,ke).isStale||!Aa(t))return;const s=Mc(b(this,ke).dataUpdatedAt,t)+1;_(this,un,rn.setTimeout(()=>{b(this,ke).isStale||this.updateResult()},s))},za=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(b(this,oe)):this.options.refetchInterval)??!1},La=function(t){ee(this,fe,Ua).call(this),_(this,zt,t),!(br.isServer()||Fe(this.options.enabled,b(this,oe))===!1||!Aa(b(this,zt))||b(this,zt)===0)&&_(this,fn,rn.setInterval(()=>{(this.options.refetchIntervalInBackground||yo.isFocused())&&ee(this,fe,xr).call(this)},b(this,zt)))},Fa=function(){ee(this,fe,Da).call(this),ee(this,fe,La).call(this,ee(this,fe,za).call(this))},$a=function(){b(this,un)!==void 0&&(rn.clearTimeout(b(this,un)),_(this,un,void 0))},Ua=function(){b(this,fn)!==void 0&&(rn.clearInterval(b(this,fn)),_(this,fn,void 0))},Va=function(){const t=b(this,_e).getQueryCache().build(b(this,_e),this.options);if(t===b(this,oe))return;const n=b(this,oe);_(this,oe,t),_(this,kr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Uc=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(b(this,ke))}),b(this,_e).getQueryCache().notify({query:b(this,oe),type:"observerResultsUpdated"})})},Sc);function Bh(e,t){return Fe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Fe(t.retryOnMount,e)===!1)}function Ni(e,t){return Bh(e,t)||e.state.data!==void 0&&Ba(e,t,t.refetchOnMount)}function Ba(e,t,n){if(Fe(t.enabled,e)!==!1&&Vt(t.staleTime,e)!=="static"){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&No(e,t)}return!1}function Ci(e,t,n,s){return(e!==t||Fe(s.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&No(e,n)}function No(e,t){return Fe(t.enabled,e)!==!1&&e.isStaleByTime(Vt(t.staleTime,e))}function Kh(e,t){return!ms(e.getCurrentResult(),t)}function xs(e){return{onFetch:(t,n)=>{var d,h,m,x,g;const s=t.options,a=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,o=((x=t.state.data)==null?void 0:x.pages)||[],c=((g=t.state.data)==null?void 0:g.pageParams)||[];let i={pages:[],pageParams:[]},f=0;const u=async()=>{let p=!1;const v=N=>{zh(N,()=>t.signal,()=>p=!0)},y=Ic(t.options,t.fetchOptions),w=async(N,j,S)=>{if(p)return Promise.reject();if(j==null&&N.pages.length)return Promise.resolve(N);const E=(()=>{const U={client:t.client,queryKey:t.queryKey,pageParam:j,direction:S?"backward":"forward",meta:t.options.meta};return v(U),U})(),k=await y(E),{maxPages:z}=t.options,O=S?Dh:Oh;return{pages:O(N.pages,k,z),pageParams:O(N.pageParams,j,z)}};if(a&&o.length){const N=a==="backward",j=N?Vc:Ka,S={pages:o,pageParams:c},C=j(s,S);i=await w(S,C,N)}else{const N=e??o.length;do{const j=f===0?c[0]??s.initialPageParam:Ka(s,i);if(f>0&&j==null)break;i=await w(i,j),f++}while(f<N)}return i};t.options.persister?t.fetchFn=()=>{var p,v;return(v=(p=t.options).persister)==null?void 0:v.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Ka(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 Vc(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 qh(e,t){return t?Ka(e,t)!=null:!1}function Hh(e,t){return!t||!e.getPreviousPageParam?!1:Vc(e,t)!=null}var Wh=class extends $c{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:xs()})}getOptimisticResult(e){return e.behavior=xs(),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 g,p;const{state:n}=e,s=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:c,isRefetchError:i}=s,f=(p=(g=n.fetchMeta)==null?void 0:g.fetchMore)==null?void 0:p.direction,u=c&&f==="forward",d=a&&f==="forward",h=c&&f==="backward",m=a&&f==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:qh(t,n.data),hasPreviousPage:Hh(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:m,isRefetchError:i&&!u&&!h,isRefetching:o&&!d&&!m}}},Ar,rt,Se,hn,st,Tt,Ec,Gh=(Ec=class extends zc{constructor(t){super();$(this,st);$(this,Ar);$(this,rt);$(this,Se);$(this,hn);_(this,Ar,t.client),this.mutationId=t.mutationId,_(this,Se,t.mutationCache),_(this,rt,[]),this.state=t.state||Bc(),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,rt).includes(t)||(b(this,rt).push(t),this.clearGcTimeout(),b(this,Se).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,rt,b(this,rt).filter(n=>n!==t)),this.scheduleGc(),b(this,Se).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){b(this,rt).length||(this.state.status==="pending"?this.scheduleGc():b(this,Se).remove(this))}continue(){var t;return((t=b(this,hn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var c,i,f,u,d,h,m,x,g,p,v,y,w,N,j,S,C,E;const n=()=>{ee(this,st,Tt).call(this,{type:"continue"})},s={client:b(this,Ar),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,hn,Dc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(k,z)=>{ee(this,st,Tt).call(this,{type:"failed",failureCount:k,error:z})},onPause:()=>{ee(this,st,Tt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>b(this,Se).canRun(this)}));const a=this.state.status==="pending",o=!b(this,hn).canStart();try{if(a)n();else{ee(this,st,Tt).call(this,{type:"pending",variables:t,isPaused:o}),b(this,Se).config.onMutate&&await b(this,Se).config.onMutate(t,this,s);const z=await((i=(c=this.options).onMutate)==null?void 0:i.call(c,t,s));z!==this.state.context&&ee(this,st,Tt).call(this,{type:"pending",context:z,variables:t,isPaused:o})}const k=await b(this,hn).start();return await((u=(f=b(this,Se).config).onSuccess)==null?void 0:u.call(f,k,t,this.state.context,this,s)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,k,t,this.state.context,s)),await((x=(m=b(this,Se).config).onSettled)==null?void 0:x.call(m,k,null,this.state.variables,this.state.context,this,s)),await((p=(g=this.options).onSettled)==null?void 0:p.call(g,k,null,t,this.state.context,s)),ee(this,st,Tt).call(this,{type:"success",data:k}),k}catch(k){try{await((y=(v=b(this,Se).config).onError)==null?void 0:y.call(v,k,t,this.state.context,this,s))}catch(z){Promise.reject(z)}try{await((N=(w=this.options).onError)==null?void 0:N.call(w,k,t,this.state.context,s))}catch(z){Promise.reject(z)}try{await((S=(j=b(this,Se).config).onSettled)==null?void 0:S.call(j,void 0,k,this.state.variables,this.state.context,this,s))}catch(z){Promise.reject(z)}try{await((E=(C=this.options).onSettled)==null?void 0:E.call(C,void 0,k,t,this.state.context,s))}catch(z){Promise.reject(z)}throw ee(this,st,Tt).call(this,{type:"error",error:k}),k}finally{b(this,Se).runNext(this)}}},Ar=new WeakMap,rt=new WeakMap,Se=new WeakMap,hn=new WeakMap,st=new WeakSet,Tt=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),be.batch(()=>{b(this,rt).forEach(s=>{s.onMutationUpdate(t)}),b(this,Se).notify({mutation:this,type:"updated",action:t})})},Ec);function Bc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var gt,Xe,Mr,Rc,Qh=(Rc=class extends er{constructor(t={}){super();$(this,gt);$(this,Xe);$(this,Mr);this.config=t,_(this,gt,new Set),_(this,Xe,new Map),_(this,Mr,0)}build(t,n,s){const a=new Gh({client:t,mutationCache:this,mutationId:++Qr(this,Mr)._,options:t.defaultMutationOptions(n),state:s});return this.add(a),a}add(t){b(this,gt).add(t);const n=Xr(t);if(typeof n=="string"){const s=b(this,Xe).get(n);s?s.push(t):b(this,Xe).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(b(this,gt).delete(t)){const n=Xr(t);if(typeof n=="string"){const s=b(this,Xe).get(n);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&b(this,Xe).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Xr(t);if(typeof n=="string"){const s=b(this,Xe).get(n),a=s==null?void 0:s.find(o=>o.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const n=Xr(t);if(typeof n=="string"){const a=(s=b(this,Xe).get(n))==null?void 0:s.find(o=>o!==t&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{b(this,gt).forEach(t=>{this.notify({type:"removed",mutation:t})}),b(this,gt).clear(),b(this,Xe).clear()})}getAll(){return Array.from(b(this,gt))}find(t){const n={exact:!0,...t};return this.getAll().find(s=>vi(n,s))}findAll(t={}){return this.getAll().filter(n=>vi(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(Te))))}},gt=new WeakMap,Xe=new WeakMap,Mr=new WeakMap,Rc);function Xr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var vt,Lt,Ie,yt,wt,is,qa,Pc,Yh=(Pc=class extends er{constructor(n,s){super();$(this,wt);$(this,vt);$(this,Lt);$(this,Ie);$(this,yt);_(this,vt,n),this.setOptions(s),this.bindMethods(),ee(this,wt,is).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const s=this.options;this.options=b(this,vt).defaultMutationOptions(n),ms(this.options,s)||b(this,vt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:b(this,Ie),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&mn(s.mutationKey)!==mn(this.options.mutationKey)?this.reset():((a=b(this,Ie))==null?void 0:a.state.status)==="pending"&&b(this,Ie).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=b(this,Ie))==null||n.removeObserver(this)}onMutationUpdate(n){ee(this,wt,is).call(this),ee(this,wt,qa).call(this,n)}getCurrentResult(){return b(this,Lt)}reset(){var n;(n=b(this,Ie))==null||n.removeObserver(this),_(this,Ie,void 0),ee(this,wt,is).call(this),ee(this,wt,qa).call(this)}mutate(n,s){var a;return _(this,yt,s),(a=b(this,Ie))==null||a.removeObserver(this),_(this,Ie,b(this,vt).getMutationCache().build(b(this,vt),this.options)),b(this,Ie).addObserver(this),b(this,Ie).execute(n)}},vt=new WeakMap,Lt=new WeakMap,Ie=new WeakMap,yt=new WeakMap,wt=new WeakSet,is=function(){var s;const n=((s=b(this,Ie))==null?void 0:s.state)??Bc();_(this,Lt,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},qa=function(n){be.batch(()=>{var s,a,o,c,i,f,u,d;if(b(this,yt)&&this.hasListeners()){const h=b(this,Lt).variables,m=b(this,Lt).context,x={client:b(this,vt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(s=b(this,yt)).onSuccess)==null||a.call(s,n.data,h,m,x)}catch(g){Promise.reject(g)}try{(c=(o=b(this,yt)).onSettled)==null||c.call(o,n.data,null,h,m,x)}catch(g){Promise.reject(g)}}else if((n==null?void 0:n.type)==="error"){try{(f=(i=b(this,yt)).onError)==null||f.call(i,n.error,h,m,x)}catch(g){Promise.reject(g)}try{(d=(u=b(this,yt)).onSettled)==null||d.call(u,void 0,n.error,h,m,x)}catch(g){Promise.reject(g)}}}this.listeners.forEach(h=>{h(b(this,Lt))})})},Pc),at,kc,Xh=(kc=class extends er{constructor(t={}){super();$(this,at);this.config=t,_(this,at,new Map)}build(t,n,s){const a=n.queryKey,o=n.queryHash??bo(a,n);let c=this.get(o);return c||(c=new Vh({client:t,queryKey:a,queryHash:o,options:t.defaultQueryOptions(n),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(c)),c}add(t){b(this,at).has(t.queryHash)||(b(this,at).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=b(this,at).get(t.queryHash);n&&(t.destroy(),n===t&&b(this,at).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return b(this,at).get(t)}getAll(){return[...b(this,at).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(s=>gi(n,s))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(s=>gi(t,s)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},at=new WeakMap,kc),ve,Ft,$t,Bn,Kn,Ut,qn,Hn,Tc,Zh=(Tc=class{constructor(e={}){$(this,ve);$(this,Ft);$(this,$t);$(this,Bn);$(this,Kn);$(this,Ut);$(this,qn);$(this,Hn);_(this,ve,e.queryCache||new Xh),_(this,Ft,e.mutationCache||new Qh),_(this,$t,e.defaultOptions||{}),_(this,Bn,new Map),_(this,Kn,new Map),_(this,Ut,0)}mount(){Qr(this,Ut)._++,b(this,Ut)===1&&(_(this,qn,yo.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ve).onFocus())})),_(this,Hn,ps.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ve).onOnline())})))}unmount(){var e,t;Qr(this,Ut)._--,b(this,Ut)===0&&((e=b(this,qn))==null||e.call(this),_(this,qn,void 0),(t=b(this,Hn))==null||t.call(this),_(this,Hn,void 0))}isFetching(e){return b(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return b(this,Ft).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=b(this,ve).build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Vt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return b(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),a=b(this,ve).get(s.queryHash),o=a==null?void 0:a.state.data,c=Mh(t,o);if(c!==void 0)return b(this,ve).build(this,s).setData(c,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>b(this,ve).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,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=b(this,ve);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=b(this,ve);return be.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=be.batch(()=>b(this,ve).findAll(e).map(a=>a.cancel(n)));return Promise.all(s).then(Te).catch(Te)}invalidateQueries(e,t={}){return be.batch(()=>(b(this,ve).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=be.batch(()=>b(this,ve).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,n);return n.throwOnError||(o=o.catch(Te)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(s).then(Te)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=b(this,ve).build(this,t);return n.isStaleByTime(Vt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Te).catch(Te)}fetchInfiniteQuery(e){return e.behavior=xs(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Te).catch(Te)}ensureInfiniteQueryData(e){return e.behavior=xs(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ps.isOnline()?b(this,Ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return b(this,ve)}getMutationCache(){return b(this,Ft)}getDefaultOptions(){return b(this,$t)}setDefaultOptions(e){_(this,$t,e)}setQueryDefaults(e,t){b(this,Bn).set(mn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...b(this,Bn).values()],n={};return t.forEach(s=>{yr(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){b(this,Kn).set(mn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...b(this,Kn).values()],n={};return t.forEach(s=>{yr(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...b(this,$t).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=bo(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===wo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...b(this,$t).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){b(this,ve).clear(),b(this,Ft).clear()}},ve=new WeakMap,Ft=new WeakMap,$t=new WeakMap,Bn=new WeakMap,Kn=new WeakMap,Ut=new WeakMap,qn=new WeakMap,Hn=new WeakMap,Tc),Kc=l.createContext(void 0),ye=e=>{const t=l.useContext(Kc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Jh=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(Kc.Provider,{value:e,children:t})),qc=l.createContext(!1),em=()=>l.useContext(qc);qc.Provider;function tm(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var nm=l.createContext(tm()),rm=()=>l.useContext(nm),sm=(e,t,n)=>{const s=n!=null&&n.state.error&&typeof e.throwOnError=="function"?jo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},am=e=>{l.useEffect(()=>{e.clearReset()},[e])},om=({result:e,errorResetBoundary:t,throwOnError:n,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||jo(n,[e.error,s])),im=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>n(s(...a)):n(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},cm=(e,t)=>e.isLoading&&e.isFetching&&!t,lm=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Si=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Hc(e,t,n){var m,x,g,p;const s=em(),a=rm(),o=ye(),c=o.defaultQueryOptions(e);(x=(m=o.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||x.call(m,c);const i=o.getQueryCache().get(c.queryHash);c._optimisticResults=s?"isRestoring":"optimistic",im(c),sm(c,a,i),am(a);const f=!o.getQueryCache().get(c.queryHash),[u]=l.useState(()=>new t(o,c)),d=u.getOptimisticResult(c),h=!s&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(v=>{const y=h?u.subscribe(be.batchCalls(v)):Te;return u.updateResult(),y},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(c)},[c,u]),lm(c,d))throw Si(c,u,a);if(om({result:d,errorResetBoundary:a,throwOnError:c.throwOnError,query:i,suspense:c.suspense}))throw d.error;if((p=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||p.call(g,c,d),c.experimental_prefetchInRender&&!br.isServer()&&cm(d,s)){const v=f?Si(c,u,a):i==null?void 0:i.promise;v==null||v.catch(Te).finally(()=>{u.updateResult()})}return c.notifyOnChangeProps?d:u.trackResult(d)}function Ce(e,t){return Hc(e,$c)}function we(e,t){const n=ye(),[s]=l.useState(()=>new Yh(n,e));l.useEffect(()=>{s.setOptions(e)},[s,e]);const a=l.useSyncExternalStore(l.useCallback(c=>s.subscribe(be.batchCalls(c)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),o=l.useCallback((c,i)=>{s.mutate(c,i).catch(Te)},[s]);if(a.error&&jo(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function Co(e,t){return Hc(e,Wh)}const gs=new Zh({defaultOptions:{queries:{staleTime:3e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!1}}});var Ei={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:["processing","shipped","delivered","refunded"]},dm=["processing","shipped","delivered"];function um(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.toStatus==="partially_refunded"&&n.fromStatus!==null&&n.fromStatus!=="partially_refunded")return n.fromStatus}return null}function fm(e,t){if(e!=="partially_refunded"||t===null)return Ei[e];const n=Ei[t];return["refunded",...dm.filter(s=>n.includes(s))]}function hm(e){return e.capturedMinor<=0?"unpaid":e.refundedMinor<=0?"paid":e.refundedMinor<e.capturedMinor?"partially_refunded":"refunded"}var mm="product.created.v1",pm="product.updated.v1",xm="product.deleted.v1",gm="product.published.v1",vm="product.unpublished.v1",ym="product.viewed.v1",bm="product.restocked.v1",wm="product.variant_price_changed.v1",jm="category.created.v1",Nm="category.updated.v1",Cm="category.deleted.v1",Sm="order.placed.v1",Em="order.paid.v1",Rm="order.fulfilled.v1",Pm="order.shipped.v1",km="order.delivered.v1",Tm="order.cancelled.v1",Am="order.refunded.v1",Mm="order.partially_refunded.v1",_m="order.status_changed.v1",Im="order.confirmation_resend_requested.v1",Om="order.deleted.v1",Dm="inventory.changed.v1",zm="inventory.reserved.v1",Lm="inventory.released.v1",Fm="inventory.low_stock.v1",$m="inventory.out_of_stock.v1",Um="customer.created.v1",Vm="customer.updated.v1",Bm="customer.deleted.v1",Km="visitor.merged.v1",qm="cart.created.v1",Hm="cart.item_added.v1",Wm="cart.item_removed.v1",Gm="cart.updated.v1",Qm="cart.abandoned.v1",Ym="cart.converted.v1",Xm="payment.intent_created.v1",Zm="payment.captured.v1",Jm="payment.failed.v1",ep="payment.refunded.v1",tp="alert.requested.v1",np="alert.repeated.v1",rp="alert.confirmed.v1",sp="alert.unsubscribed.v1",ap="alert.sent.v1",op="alert.confirmation_sent.v1",ip="review.submitted.v1",cp="proposal.created.v1",lp="proposal.approved.v1",dp="proposal.rejected.v1",up="proposal.applied.v1",fp="proposal.failed.v1",hp="adapter.error.v1",mp="settings.changed.v1",pp=[mm,pm,xm,gm,vm,ym,bm,wm,jm,Nm,Cm,Sm,Em,Rm,Pm,km,Tm,Am,Mm,_m,Im,Om,Dm,zm,Lm,Fm,$m,Um,Vm,Bm,Km,qm,Hm,Wm,Gm,Qm,Ym,Xm,Zm,Jm,ep,tp,np,rp,sp,ap,op,ip,cp,lp,dp,up,fp,hp,mp],xp="idempotency-key",gp=["product.update","inventory.adjust","order.refund","order.cancel"];class Re extends Error{constructor(t,n,s,a){super(n),this.code=t,this.status=s,this.context=a,this.name="ApiError"}}const vp="x-csrf-token",yp=new Set(["POST","PUT","PATCH","DELETE"]);let cs=null;function bp(){return cs??(cs=fetch("/api/csrf").then(async e=>{var n;const t=await e.json();if(!e.ok||!((n=t.data)!=null&&n.token))throw new Re("csrf.unavailable",`GET /api/csrf answered ${e.status}`,e.status);return t.data.token}).catch(e=>{throw cs=null,e})),cs}async function wp(e){var n;return e.status!==403?!1:((n=(await e.clone().json().catch(()=>({}))).error)==null?void 0:n.code)==="csrf.invalid"}async function So(e,t={}){const n=(t.method??"GET").toUpperCase();if(!yp.has(n))return fetch(e,t);const s=async()=>{const o=new Headers(t.headers);return o.set(vp,await bp()),fetch(e,{...t,headers:o})},a=await s();return await wp(a)?(cs=null,s()):a}function jp(e,t){if(!t)return e;const n=new URLSearchParams;for(const[a,o]of Object.entries(t))o!=null&&o!==""&&n.set(a,String(o));const s=n.toString();return s?`${e}?${s}`:e}async function Np(e){const t=Gc();return t!==e?t!==null:Rp()}function Ha(){return crypto.randomUUID()}async function At(e,t,n,s={}){const{query:a,retried:o=!1}=s,c=Gc(),i={};c&&(i.Authorization=`Bearer ${c}`),s.idempotencyKey!==void 0&&(i[xp]=s.idempotencyKey);const f=jp(t,a),u={method:e,headers:i};n!==void 0&&(i["Content-Type"]="application/json",u.body=JSON.stringify(n));const d=await So(f,u);if(d.status===401){if(!o&&c!==null&&!t.startsWith("/api/auth/")&&await Np(c))return At(e,t,n,{...s,retried:!0});const x=(await d.json().catch(()=>({}))).error;throw new Re((x==null?void 0:x.code)??"UNAUTHORIZED",(x==null?void 0:x.message)??"Unauthorized",401)}if(s.text&&d.ok)return await d.text();const h=await d.json();if(!d.ok){const m=h.error;throw new Re((m==null?void 0:m.code)??"UNKNOWN_ERROR",(m==null?void 0:m.message)??`HTTP ${d.status}`,d.status,m==null?void 0:m.context)}return s.envelope?h:"data"in h?h.data:h}function Zr(e,t){const n=(e==null?void 0:e.idempotencyKey)??(t.startsWith("/api/admin/")?Ha():void 0);return n===void 0?{}:{idempotencyKey:n}}const W={get(e,t){return At("GET",e,void 0,t===void 0?{}:{query:t})},getPage(e,t){return At("GET",e,void 0,{envelope:!0,...t&&{query:t}})},getText(e,t){return At("GET",e,void 0,{text:!0,...t&&{query:t}})},post(e,t,n){return At("POST",e,t,Zr(n,e))},patch(e,t,n){return At("PATCH",e,t,Zr(n,e))},put(e,t,n){return At("PUT",e,t,Zr(n,e))},delete(e,t){return At("DELETE",e,void 0,Zr(t,e))}};let As=null,ua=null;const Wa=new Set;function Wc(e){As=e}function Gc(){return As}function Qc(){As=null}function vs(){return As!==null}function Cp(e){return Wa.add(e),()=>{Wa.delete(e)}}async function Yc(e){var t;return await((t=e.body)==null?void 0:t.cancel()),!1}async function Sp(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:Yc(s)}catch{return!1}}async function Ep(){var t;let e;try{const n=await So("/api/auth/refresh",{method:"POST"});if(!n.ok)return Yc(n);e=(t=(await n.json()).data)==null?void 0:t.accessToken}catch{return!1}return!e||!await Sp(e)?!1:(Wc(e),!0)}function Xc(e){return ua??(ua=Ep().then(t=>{if(ua=null,!t&&(Qc(),e))for(const n of[...Wa])n();return t})),ua}function Rp(){return Xc(!0)}function Pp(){return Xc(!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 kp=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Zc=(...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 Tp={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 Ap=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:o,iconNode:c,...i},f)=>l.createElement("svg",{ref:f,...Tp,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Zc("lucide",a),...i},[...c.map(([u,d])=>l.createElement(u,d)),...Array.isArray(o)?o:[o]]));/**
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 q=(e,t)=>{const n=l.forwardRef(({className:s,...a},o)=>l.createElement(Ap,{ref:o,iconNode:t,className:Zc(`lucide-${kp(e)}`,s),...a}));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 Mp=q("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 Eo=q("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 _p=q("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 Ip=q("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
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 Jc=q("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"}]]);/**
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 Op=q("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"}]]);/**
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 Dp=q("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/**
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 St=q("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
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 el=q("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
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 tl=q("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
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 zp=q("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
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 nl=q("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"}]]);/**
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 Ri=q("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
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 Lp=q("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"}]]);/**
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 Fp=q("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
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 Pi=q("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
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 $p=q("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"}]]);/**
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 Up=q("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"}]]);/**
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 Vp=q("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"}]]);/**
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 Bp=q("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"}]]);/**
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 rl=q("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"}]]);/**
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 Kp=q("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
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 Wn=q("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"}]]);/**
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 qp=q("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"}]]);/**
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 Ga=q("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
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 Hp=q("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
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 Wp=q("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"}]]);/**
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 Gp=q("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"}]]);/**
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 _r=q("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
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 Qp=q("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"}]]);/**
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 sl=q("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"}]]);/**
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 Yp=q("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"}]]);/**
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 Xp=q("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"}]]);/**
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 Zp=q("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
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 qt=q("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"}]]);/**
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 Jp=q("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"}]]);/**
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 wr=q("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
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 ex=q("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"}]]);/**
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 tr=q("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
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 al=q("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"}]]);/**
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 tx=q("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"}]]);/**
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 Gn=q("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"}]]);/**
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 Qa=q("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"}]]);/**
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 nx=q("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"}]]);/**
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 ol=q("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"}]]);/**
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 Ya=q("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"}]]);/**
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 ys=q("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"}]]);/**
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 il=q("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"}]]);/**
270
+ * @license lucide-react v0.462.0 - ISC
271
+ *
272
+ * This source code is licensed under the ISC license.
273
+ * See the LICENSE file in the root directory of this source tree.
274
+ */const Ro=q("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"}]]);/**
275
+ * @license lucide-react v0.462.0 - ISC
276
+ *
277
+ * This source code is licensed under the ISC license.
278
+ * See the LICENSE file in the root directory of this source tree.
279
+ */const Yt=q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Po(){return Ce({queryKey:["me"],queryFn:()=>W.get("/api/admin/me"),staleTime:5*6e4})}function cl(){const e=Ct(),t=l.useCallback(async(s,a)=>{var u;const o=await So("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s,password:a})}),c=await o.json();if(!o.ok||!c.data)throw new Error(((u=c.error)==null?void 0:u.message)??"Login failed");const{accessToken:i,customer:f}=c.data;if(!f.roles.includes("admin"))throw new Error("Not authorized: admin role required");Wc(i),await gs.invalidateQueries({queryKey:["me"]}),e("/")},[e]),n=l.useCallback(async()=>{await W.post("/api/auth/logout").catch(()=>{}),Qc(),gs.clear(),e("/login")},[e]);return{isAuthenticated:vs(),login:t,logout:n}}function Xt(){const[e,t]=l.useState(Ha),n=l.useCallback(()=>t(Ha()),[]);return[e,n]}function ll(e={}){return Ce({queryKey:["orders","list",e],queryFn:()=>W.get("/api/admin/orders",e)})}function dl(e){return Ce({queryKey:["orders","detail",e],queryFn:()=>W.get(`/api/admin/orders/${e}`),enabled:!!e})}function rx(e){return Ce({queryKey:["orders","notes",e],queryFn:()=>W.get(`/api/admin/orders/${e}/notes`),enabled:!!e})}function Ms(e){return e.invalidateQueries({queryKey:["orders","detail"]})}function sx(){const e=ye();return we({mutationFn:async({orderId:t,action:n,body:s})=>W.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 ax(){const e=ye();return we({mutationFn:({orderId:t,reason:n})=>W.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"]})},onError:()=>Ms(e)})}function ul(){const e=ye(),[t,n]=Xt();return we({mutationFn:({orderId:s,note:a})=>W.post(`/api/admin/orders/${s}/mark-paid`,a?{note:a}:{},{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","detail",s.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})},onError:()=>Ms(e),onSettled:n})}function ox(){const e=ye(),[t,n]=Xt();return we({mutationFn:s=>W.post(`/api/admin/orders/${s}/mark-delivered`,void 0,{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","list"]})},onError:()=>Ms(e),onSettled:n})}function ix(){const e=ye(),[t,n]=Xt();return we({mutationFn:({orderId:s,trackingNumber:a,carrier:o})=>W.post(`/api/admin/orders/${s}/ship`,{trackingNumber:a,carrier:o},{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","list"]})},onError:()=>Ms(e),onSettled:n})}function cx(){const e=ye();return we({mutationFn:({orderId:t,amountMinor:n,reason:s,requestId:a})=>W.post(`/api/admin/orders/${t}/refund`,s?{amountMinor:n,reason:s,requestId:a}:{amountMinor:n,requestId:a}),onSuccess:async t=>{await Promise.all([e.invalidateQueries({queryKey:["orders","detail",t.order.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})])}})}function lx(){const[e,t]=Xt();return we({mutationFn:({orderId:n})=>W.post(`/api/admin/orders/${n}/resend-confirmation`,void 0,{idempotencyKey:e}),onSettled:t})}function dx(){const e=ye();return we({mutationFn:({orderId:t,body:n})=>W.post(`/api/admin/orders/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["orders","notes",n.orderId]})}})}const ux=50;function fx(e){return Co({queryKey:["proposals","list",e],initialPageParam:void 0,queryFn:({pageParam:t})=>W.get("/api/admin/proposals",{status:e,limit:ux,cursor:t}),getNextPageParam:t=>t.nextCursor??void 0})}function hx(e,t){return Ce({queryKey:["proposals","one",e],queryFn:()=>W.get(`/api/admin/proposals/${encodeURIComponent(e)}`),enabled:t})}function mx(){return Ce({queryKey:["proposals","count"],queryFn:async()=>(await W.get("/api/admin/proposals",{status:"pending",limit:1})).pending})}function fl(){const e=ye(),[t,n]=Xt();return we({mutationFn:s=>W.post(`/api/admin/proposals/${encodeURIComponent(s)}/approve`,void 0,{idempotencyKey:t}),onSettled:()=>{n(),e.invalidateQueries({queryKey:["proposals"]})}})}function hl(){const e=ye(),[t,n]=Xt();return we({mutationFn:({id:s,reason:a})=>W.post(`/api/admin/proposals/${encodeURIComponent(s)}/reject`,a===""?{}:{reason:a},{idempotencyKey:t}),onSettled:()=>{n(),e.invalidateQueries({queryKey:["proposals"]})}})}function P(...e){return["admin",...e].join("-")}function ml(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=ml(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function pl(){for(var e,t,n=0,s="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=ml(e))&&(s&&(s+=" "),s+=t);return s}const ko="-",px=e=>{const t=gx(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:c=>{const i=c.split(ko);return i[0]===""&&i.length!==1&&i.shift(),xl(i,t)||xx(c)},getConflictingClassGroupIds:(c,i)=>{const f=n[c]||[];return i&&s[c]?[...f,...s[c]]:f}}},xl=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const n=e[0],s=t.nextPart.get(n),a=s?xl(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;const o=e.join(ko);return(c=t.validators.find(({validator:i})=>i(o)))==null?void 0:c.classGroupId},ki=/^\[(.+)\]$/,xx=e=>{if(ki.test(e)){const t=ki.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},gx=e=>{const{theme:t,prefix:n}=e,s={nextPart:new Map,validators:[]};return yx(Object.entries(e.classGroups),n).forEach(([o,c])=>{Xa(c,s,o,t)}),s},Xa=(e,t,n,s)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?t:Ti(t,a);o.classGroupId=n;return}if(typeof a=="function"){if(vx(a)){Xa(a(s),t,n,s);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([o,c])=>{Xa(c,Ti(t,o),n,s)})})},Ti=(e,t)=>{let n=e;return t.split(ko).forEach(s=>{n.nextPart.has(s)||n.nextPart.set(s,{nextPart:new Map,validators:[]}),n=n.nextPart.get(s)}),n},vx=e=>e.isThemeGetter,yx=(e,t)=>t?e.map(([n,s])=>{const a=s.map(o=>typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([c,i])=>[t+c,i])):o);return[n,a]}):e,bx=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const a=(o,c)=>{n.set(o,c),t++,t>e&&(t=0,s=n,n=new Map)};return{get(o){let c=n.get(o);if(c!==void 0)return c;if((c=s.get(o))!==void 0)return a(o,c),c},set(o,c){n.has(o)?n.set(o,c):a(o,c)}}},gl="!",wx=e=>{const{separator:t,experimentalParseClassName:n}=e,s=t.length===1,a=t[0],o=t.length,c=i=>{const f=[];let u=0,d=0,h;for(let v=0;v<i.length;v++){let y=i[v];if(u===0){if(y===a&&(s||i.slice(v,v+o)===t)){f.push(i.slice(d,v)),d=v+o;continue}if(y==="/"){h=v;continue}}y==="["?u++:y==="]"&&u--}const m=f.length===0?i:i.substring(d),x=m.startsWith(gl),g=x?m.substring(1):m,p=h&&h>d?h-d:void 0;return{modifiers:f,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:p}};return n?i=>n({className:i,parseClassName:c}):c},jx=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},Nx=e=>({cache:bx(e.cacheSize),parseClassName:wx(e),...px(e)}),Cx=/\s+/,Sx=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a}=t,o=[],c=e.trim().split(Cx);let i="";for(let f=c.length-1;f>=0;f-=1){const u=c[f],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:x}=n(u);let g=!!x,p=s(g?m.substring(0,x):m);if(!p){if(!g){i=u+(i.length>0?" "+i:i);continue}if(p=s(m),!p){i=u+(i.length>0?" "+i:i);continue}g=!1}const v=jx(d).join(":"),y=h?v+gl:v,w=y+p;if(o.includes(w))continue;o.push(w);const N=a(p,g);for(let j=0;j<N.length;++j){const S=N[j];o.push(y+S)}i=u+(i.length>0?" "+i:i)}return i};function Ex(){let e=0,t,n,s="";for(;e<arguments.length;)(t=arguments[e++])&&(n=vl(t))&&(s&&(s+=" "),s+=n);return s}const vl=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=vl(e[s]))&&(n&&(n+=" "),n+=t);return n};function Rx(e,...t){let n,s,a,o=c;function c(f){const u=t.reduce((d,h)=>h(d),e());return n=Nx(u),s=n.cache.get,a=n.cache.set,o=i,i(f)}function i(f){const u=s(f);if(u)return u;const d=Sx(f,n);return a(f,d),d}return function(){return o(Ex.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},yl=/^\[(?:([a-z-]+):)?(.+)\]$/i,Px=/^\d+\/\d+$/,kx=new Set(["px","full","screen"]),Tx=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ax=/\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$/,Mx=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_x=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ix=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,mt=e=>Mn(e)||kx.has(e)||Px.test(e),Pt=e=>nr(e,"length",Vx),Mn=e=>!!e&&!Number.isNaN(Number(e)),fa=e=>nr(e,"number",Mn),fr=e=>!!e&&Number.isInteger(Number(e)),Ox=e=>e.endsWith("%")&&Mn(e.slice(0,-1)),te=e=>yl.test(e),kt=e=>Tx.test(e),Dx=new Set(["length","size","percentage"]),zx=e=>nr(e,Dx,bl),Lx=e=>nr(e,"position",bl),Fx=new Set(["image","url"]),$x=e=>nr(e,Fx,Kx),Ux=e=>nr(e,"",Bx),hr=()=>!0,nr=(e,t,n)=>{const s=yl.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):n(s[2]):!1},Vx=e=>Ax.test(e)&&!Mx.test(e),bl=()=>!1,Bx=e=>_x.test(e),Kx=e=>Ix.test(e),qx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),s=ge("brightness"),a=ge("borderColor"),o=ge("borderRadius"),c=ge("borderSpacing"),i=ge("borderWidth"),f=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),x=ge("gradientColorStops"),g=ge("gradientColorStopPositions"),p=ge("inset"),v=ge("margin"),y=ge("opacity"),w=ge("padding"),N=ge("saturate"),j=ge("scale"),S=ge("sepia"),C=ge("skew"),E=ge("space"),k=ge("translate"),z=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto",te,t],I=()=>[te,t],Q=()=>["",mt,Pt],V=()=>["auto",Mn,te],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],A=()=>["","0",te],ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],le=()=>[Mn,te];return{cacheSize:500,separator:":",theme:{colors:[hr],spacing:[mt,Pt],blur:["none","",kt,te],brightness:le(),borderColor:[e],borderRadius:["none","","full",kt,te],borderSpacing:I(),borderWidth:Q(),contrast:le(),grayscale:A(),hueRotate:le(),invert:A(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Ox,Pt],inset:U(),margin:U(),opacity:le(),padding:I(),saturate:le(),scale:le(),sepia:A(),skew:le(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",te]}],container:["container"],columns:[{columns:[kt]}],"break-after":[{"break-after":ce()}],"break-before":[{"break-before":ce()}],"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:[...Z(),te]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],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",fr,te]}],basis:[{basis:U()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",te]}],grow:[{grow:A()}],shrink:[{shrink:A()}],order:[{order:["first","last","none",fr,te]}],"grid-cols":[{"grid-cols":[hr]}],"col-start-end":[{col:["auto",{span:["full",fr,te]},te]}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":[hr]}],"row-start-end":[{row:["auto",{span:[fr,te]},te]}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",te]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"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:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",te,t]}],"min-w":[{"min-w":[te,t,"min","max","fit"]}],"max-w":[{"max-w":[te,t,"none","full","min","max","fit","prose",{screen:[kt]},kt]}],h:[{h:[te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",kt,Pt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",fa]}],"font-family":[{font:[hr]}],"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",te]}],"line-clamp":[{"line-clamp":["none",Mn,fa]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",mt,te]}],"list-image":[{"list-image":["none",te]}],"list-style-type":[{list:["none","disc","decimal",te]}],"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:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",mt,Pt]}],"underline-offset":[{"underline-offset":["auto",mt,te]}],"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:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",te]}],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",te]}],"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:[...Z(),Lx]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",zx]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},$x]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:B()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[mt,te]}],"outline-w":[{outline:[mt,Pt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[mt,Pt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",kt,Ux]}],"shadow-color":[{shadow:[hr]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[s]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",kt,te]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[N]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",te]}],duration:[{duration:le()}],ease:[{ease:["linear","in","out","in-out",te]}],delay:[{delay:le()}],animate:[{animate:["none","spin","ping","pulse","bounce",te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[j]}],"scale-x":[{"scale-x":[j]}],"scale-y":[{"scale-y":[j]}],rotate:[{rotate:[fr,te]}],"translate-x":[{"translate-x":[k]}],"translate-y":[{"translate-y":[k]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",te]}],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",te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[mt,Pt,fa]}],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"]}}},Hx=Rx(qx);function T(...e){return Hx(pl(e))}const Wx=[{to:"/",label:"Dashboard",icon:Gp,end:!0},{to:"/orders",label:"Orders",icon:Gn,end:!1},{to:"/products",label:"Products",icon:qt,end:!1},{to:"/inventory",label:"Inventory",icon:Jc,end:!1},{to:"/customers",label:"Customers",icon:Ro,end:!1},{to:"/activity",label:"Activity",icon:Wn,end:!1},{to:"/inbox",label:"Inbox",icon:Ga,end:!1},{to:"/settings",label:"Settings",icon:tx,end:!1}];function Gx(){const{data:e}=ll({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 Qx(){const{data:e}=mx();return e===void 0||e===0?null:r.jsx("span",{className:"ml-auto flex h-4 min-w-4 items-center justify-center rounded-full bg-amber-500/20 px-1 text-[10px] font-semibold text-amber-400","data-testid":P("inbox","count"),children:e})}function Yx({open:e,onClose:t}){const{data:n}=Po(),{logout:s}=cl(),a=()=>{s()};return r.jsxs("aside",{id:"admin-sidebar","data-testid":P("sidebar"),"data-state":e?"open":"closed",className:T("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:Wx.map(o=>r.jsx("li",{children:r.jsx(ph,{to:o.to,end:o.end,"data-testid":P("nav",o.label.toLowerCase()),onClick:t,className:({isActive:c})=>T("flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium transition-all duration-100",c?"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:c})=>r.jsxs(r.Fragment,{children:[r.jsx(o.icon,{className:T("h-4 w-4 shrink-0",c?"text-blue-400":"text-zinc-500")}),r.jsx("span",{children:o.label}),o.label==="Orders"&&r.jsx(Gx,{}),o.label==="Inbox"&&r.jsx(Qx,{})]})})},o.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(_r,{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:a,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300 transition-colors",title:"Sign out",children:r.jsx(Qp,{className:"h-3.5 w-3.5"})})]})})]})}function Xx(){const t=xh().filter(n=>{const s=n.handle;return(s==null?void 0:s.breadcrumb)!=null}).map(n=>{var o;const s=n.handle;return{label:(o=s.breadcrumb)==null?void 0:o.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 a=s===t.length-1;return r.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&r.jsx(tl,{className:"h-3.5 w-3.5 text-zinc-400"}),a?r.jsx("span",{className:"font-medium text-zinc-900",children:n.label}):r.jsx(Ve,{to:n.pathname,className:T("text-zinc-500 hover:text-zinc-700 transition-colors","font-normal"),children:n.label})]},n.pathname)})})}const Ai=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Mi=pl,_s=(e,t)=>n=>{var s;if((t==null?void 0:t.variants)==null)return Mi(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:o}=t,c=Object.keys(a).map(u=>{const d=n==null?void 0:n[u],h=o==null?void 0:o[u];if(d===null)return null;const m=Ai(d)||Ai(h);return a[u][m]}),i=n&&Object.entries(n).reduce((u,d)=>{let[h,m]=d;return m===void 0||(u[h]=m),u},{}),f=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((u,d)=>{let{class:h,className:m,...x}=d;return Object.entries(x).every(g=>{let[p,v]=g;return Array.isArray(v)?v.includes({...o,...i}[p]):{...o,...i}[p]===v})?[...u,h,m]:u},[]);return Mi(e,c,f,n==null?void 0:n.class,n==null?void 0:n.className)},Zx=_s("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"}}),se=l.forwardRef(({className:e,variant:t,size:n,...s},a)=>r.jsx("button",{className:T(Zx({variant:t,size:n,className:e})),ref:a,...s}));se.displayName="Button";function D(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function _i(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function lt(...e){return t=>{let n=!1;const s=e.map(a=>{const o=_i(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a<s.length;a++){const o=s[a];typeof o=="function"?o():_i(e[a],null)}}}}function de(...e){return l.useCallback(lt(...e),e)}function Jx(e,t){const n=l.createContext(t),s=o=>{const{children:c,...i}=o,f=l.useMemo(()=>i,Object.values(i));return r.jsx(n.Provider,{value:f,children:c})};s.displayName=e+"Provider";function a(o){const c=l.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[s,a]}function ut(e,t=[]){let n=[];function s(o,c){const i=l.createContext(c),f=n.length;n=[...n,c];const u=h=>{var y;const{scope:m,children:x,...g}=h,p=((y=m==null?void 0:m[e])==null?void 0:y[f])||i,v=l.useMemo(()=>g,Object.values(g));return r.jsx(p.Provider,{value:v,children:x})};u.displayName=o+"Provider";function d(h,m){var p;const x=((p=m==null?void 0:m[e])==null?void 0:p[f])||i,g=l.useContext(x);if(g)return g;if(c!==void 0)return c;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[u,d]}const a=()=>{const o=n.map(c=>l.createContext(c));return function(i){const f=(i==null?void 0:i[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...i,[e]:f}}),[i,f])}};return a.scopeName=e,[s,eg(a,...t)]}function eg(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const c=s.reduce((i,{useScope:f,scopeName:u})=>{const h=f(o)[`__scope${u}`];return{...i,...h}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function pn(e){const t=tg(e),n=l.forwardRef((s,a)=>{const{children:o,...c}=s,i=l.Children.toArray(o),f=i.find(rg);if(f){const u=f.props.children,d=i.map(h=>h===f?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:h);return r.jsx(t,{...c,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,d):null})}return r.jsx(t,{...c,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function tg(e){const t=l.forwardRef((n,s)=>{const{children:a,...o}=n;if(l.isValidElement(a)){const c=ag(a),i=sg(o,a.props);return a.type!==l.Fragment&&(i.ref=s?lt(s,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ng=Symbol("radix.slottable");function rg(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ng}function sg(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...i)=>{const f=o(...i);return a(...i),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function ag(e){var s,a;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=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var og=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],G=og.reduce((e,t)=>{const n=pn(`Primitive.${t}`),s=l.forwardRef((a,o)=>{const{asChild:c,...i}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(f,{...i,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function wl(e,t){e&&Ts.flushSync(()=>e.dispatchEvent(t))}function dt(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 ig(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e);l.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var cg="DismissableLayer",Za="dismissableLayer.update",lg="dismissableLayer.pointerDownOutside",dg="dismissableLayer.focusOutside",Ii,jl=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ir=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:i,...f}=e,u=l.useContext(jl),[d,h]=l.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=l.useState({}),g=de(t,E=>h(E)),p=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=p.indexOf(v),w=d?p.indexOf(d):-1,N=u.layersWithOutsidePointerEventsDisabled.size>0,j=w>=y,S=hg(E=>{const k=E.target,z=[...u.branches].some(O=>O.contains(k));!j||z||(a==null||a(E),c==null||c(E),E.defaultPrevented||i==null||i())},m),C=mg(E=>{const k=E.target;[...u.branches].some(O=>O.contains(k))||(o==null||o(E),c==null||c(E),E.defaultPrevented||i==null||i())},m);return ig(E=>{w===u.layers.size-1&&(s==null||s(E),!E.defaultPrevented&&i&&(E.preventDefault(),i()))},m),l.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Ii=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Oi(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ii)}},[d,m,n,u]),l.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Oi())},[d,u]),l.useEffect(()=>{const E=()=>x({});return document.addEventListener(Za,E),()=>document.removeEventListener(Za,E)},[]),r.jsx(G.div,{...f,ref:g,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:D(e.onFocusCapture,C.onFocusCapture),onBlurCapture:D(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:D(e.onPointerDownCapture,S.onPointerDownCapture)})});Ir.displayName=cg;var ug="DismissableLayerBranch",fg=l.forwardRef((e,t)=>{const n=l.useContext(jl),s=l.useRef(null),a=de(t,s);return l.useEffect(()=>{const o=s.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),r.jsx(G.div,{...e,ref:a})});fg.displayName=ug;function hg(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),s=l.useRef(!1),a=l.useRef(()=>{});return l.useEffect(()=>{const o=i=>{if(i.target&&!s.current){let f=function(){Nl(lg,n,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=f,t.addEventListener("click",a.current,{once:!0})):f()}else t.removeEventListener("click",a.current);s.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",o),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function mg(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),s=l.useRef(!1);return l.useEffect(()=>{const a=o=>{o.target&&!s.current&&Nl(dg,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Oi(){const e=new CustomEvent(Za);document.dispatchEvent(e)}function Nl(e,t,n,{discrete:s}){const a=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),s?wl(a,o):a.dispatchEvent(o)}var ha=0;function Is(){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()),ha++,()=>{ha===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ha--}},[])}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 ma="focusScope.autoFocusOnMount",pa="focusScope.autoFocusOnUnmount",zi={bubbles:!1,cancelable:!0},pg="FocusScope",Or=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...c}=e,[i,f]=l.useState(null),u=dt(a),d=dt(o),h=l.useRef(null),m=de(t,p=>f(p)),x=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(s){let p=function(N){if(x.paused||!i)return;const j=N.target;i.contains(j)?h.current=j:Mt(h.current,{select:!0})},v=function(N){if(x.paused||!i)return;const j=N.relatedTarget;j!==null&&(i.contains(j)||Mt(h.current,{select:!0}))},y=function(N){if(document.activeElement===document.body)for(const S of N)S.removedNodes.length>0&&Mt(i)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const w=new MutationObserver(y);return i&&w.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),w.disconnect()}}},[s,i,x.paused]),l.useEffect(()=>{if(i){Fi.add(x);const p=document.activeElement;if(!i.contains(p)){const y=new CustomEvent(ma,zi);i.addEventListener(ma,u),i.dispatchEvent(y),y.defaultPrevented||(xg(wg(Cl(i)),{select:!0}),document.activeElement===p&&Mt(i))}return()=>{i.removeEventListener(ma,u),setTimeout(()=>{const y=new CustomEvent(pa,zi);i.addEventListener(pa,d),i.dispatchEvent(y),y.defaultPrevented||Mt(p??document.body,{select:!0}),i.removeEventListener(pa,d),Fi.remove(x)},0)}}},[i,u,d,x]);const g=l.useCallback(p=>{if(!n&&!s||x.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,y=document.activeElement;if(v&&y){const w=p.currentTarget,[N,j]=gg(w);N&&j?!p.shiftKey&&y===j?(p.preventDefault(),n&&Mt(N,{select:!0})):p.shiftKey&&y===N&&(p.preventDefault(),n&&Mt(j,{select:!0})):y===w&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(G.div,{tabIndex:-1,...c,ref:m,onKeyDown:g})});Or.displayName=pg;function xg(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Mt(s,{select:t}),document.activeElement!==n)return}function gg(e){const t=Cl(e),n=Li(t,e),s=Li(t.reverse(),e);return[n,s]}function Cl(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Li(e,t){for(const n of e)if(!vg(n,{upTo:t}))return n}function vg(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 yg(e){return e instanceof HTMLInputElement&&"select"in e}function Mt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&yg(e)&&t&&e.select()}}var Fi=bg();function bg(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=$i(e,t),e.unshift(t)},remove(t){var n;e=$i(e,t),(n=e[0])==null||n.resume()}}}function $i(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function wg(e){return e.filter(t=>t.tagName!=="A")}var Pe=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},jg=go[" useId ".trim().toString()]||(()=>{}),Ng=0;function Ne(e){const[t,n]=l.useState(jg());return Pe(()=>{n(s=>s??String(Ng++))},[e]),t?`radix-${t}`:""}const Cg=["top","right","bottom","left"],Ht=Math.min,$e=Math.max,bs=Math.round,Jr=Math.floor,ct=e=>({x:e,y:e}),Sg={left:"right",right:"left",bottom:"top",top:"bottom"};function Ja(e,t,n){return $e(e,Ht(t,n))}function jt(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function rr(e){return e.split("-")[1]}function To(e){return e==="x"?"y":"x"}function Ao(e){return e==="y"?"height":"width"}function it(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Mo(e){return To(it(e))}function Eg(e,t,n){n===void 0&&(n=!1);const s=rr(e),a=Mo(e),o=Ao(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=ws(c)),[c,ws(c)]}function Rg(e){const t=ws(e);return[eo(e),t,eo(t)]}function eo(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ui=["left","right"],Vi=["right","left"],Pg=["top","bottom"],kg=["bottom","top"];function Tg(e,t,n){switch(e){case"top":case"bottom":return n?t?Vi:Ui:t?Ui:Vi;case"left":case"right":return t?Pg:kg;default:return[]}}function Ag(e,t,n,s){const a=rr(e);let o=Tg(Nt(e),n==="start",s);return a&&(o=o.map(c=>c+"-"+a),t&&(o=o.concat(o.map(eo)))),o}function ws(e){const t=Nt(e);return Sg[t]+e.slice(t.length)}function Mg(e){return{top:0,right:0,bottom:0,left:0,...e}}function Sl(e){return typeof e!="number"?Mg(e):{top:e,right:e,bottom:e,left:e}}function js(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Bi(e,t,n){let{reference:s,floating:a}=e;const o=it(t),c=Mo(t),i=Ao(c),f=Nt(t),u=o==="y",d=s.x+s.width/2-a.width/2,h=s.y+s.height/2-a.height/2,m=s[i]/2-a[i]/2;let x;switch(f){case"top":x={x:d,y:s.y-a.height};break;case"bottom":x={x:d,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:h};break;case"left":x={x:s.x-a.width,y:h};break;default:x={x:s.x,y:s.y}}switch(rr(t)){case"start":x[c]-=m*(n&&u?-1:1);break;case"end":x[c]+=m*(n&&u?-1:1);break}return x}async function _g(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:o,rects:c,elements:i,strategy:f}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:x=0}=jt(t,e),g=Sl(x),v=i[m?h==="floating"?"reference":"floating":h],y=js(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(i.floating)),boundary:u,rootBoundary:d,strategy:f})),w=h==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(i.floating)),j=await(o.isElement==null?void 0:o.isElement(N))?await(o.getScale==null?void 0:o.getScale(N))||{x:1,y:1}:{x:1,y:1},S=js(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:w,offsetParent:N,strategy:f}):w);return{top:(y.top-S.top+g.top)/j.y,bottom:(S.bottom-y.bottom+g.bottom)/j.y,left:(y.left-S.left+g.left)/j.x,right:(S.right-y.right+g.right)/j.x}}const Ig=50,Og=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:o=[],platform:c}=n,i=c.detectOverflow?c:{...c,detectOverflow:_g},f=await(c.isRTL==null?void 0:c.isRTL(t));let u=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:h}=Bi(u,s,f),m=s,x=0;const g={};for(let p=0;p<o.length;p++){const v=o[p];if(!v)continue;const{name:y,fn:w}=v,{x:N,y:j,data:S,reset:C}=await w({x:d,y:h,initialPlacement:s,placement:m,strategy:a,middlewareData:g,rects:u,platform:i,elements:{reference:e,floating:t}});d=N??d,h=j??h,g[y]={...g[y],...S},C&&x<Ig&&(x++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(u=C.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):C.rects),{x:d,y:h}=Bi(u,m,f)),p=-1)}return{x:d,y:h,placement:m,strategy:a,middlewareData:g}},Dg=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:o,platform:c,elements:i,middlewareData:f}=t,{element:u,padding:d=0}=jt(e,t)||{};if(u==null)return{};const h=Sl(d),m={x:n,y:s},x=Mo(a),g=Ao(x),p=await c.getDimensions(u),v=x==="y",y=v?"top":"left",w=v?"bottom":"right",N=v?"clientHeight":"clientWidth",j=o.reference[g]+o.reference[x]-m[x]-o.floating[g],S=m[x]-o.reference[x],C=await(c.getOffsetParent==null?void 0:c.getOffsetParent(u));let E=C?C[N]:0;(!E||!await(c.isElement==null?void 0:c.isElement(C)))&&(E=i.floating[N]||o.floating[g]);const k=j/2-S/2,z=E/2-p[g]/2-1,O=Ht(h[y],z),U=Ht(h[w],z),I=O,Q=E-p[g]-U,V=E/2-p[g]/2+k,Z=Ja(I,V,Q),B=!f.arrow&&rr(a)!=null&&V!==Z&&o.reference[g]/2-(V<I?O:U)-p[g]/2<0,ae=B?V<I?V-I:V-Q:0;return{[x]:m[x]+ae,data:{[x]:Z,centerOffset:V-Z-ae,...B&&{alignmentOffset:ae}},reset:B}}}),zg=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:o,rects:c,initialPlacement:i,platform:f,elements:u}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...v}=jt(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(a),w=it(i),N=Nt(i)===i,j=await(f.isRTL==null?void 0:f.isRTL(u.floating)),S=m||(N||!p?[ws(i)]:Rg(i)),C=g!=="none";!m&&C&&S.push(...Ag(i,p,g,j));const E=[i,...S],k=await f.detectOverflow(t,v),z=[];let O=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&z.push(k[y]),h){const V=Eg(a,c,j);z.push(k[V[0]],k[V[1]])}if(O=[...O,{placement:a,overflows:z}],!z.every(V=>V<=0)){var U,I;const V=(((U=o.flip)==null?void 0:U.index)||0)+1,Z=E[V];if(Z&&(!(h==="alignment"?w!==it(Z):!1)||O.every(F=>it(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:V,overflows:O},reset:{placement:Z}};let B=(I=O.filter(ae=>ae.overflows[0]<=0).sort((ae,F)=>ae.overflows[1]-F.overflows[1])[0])==null?void 0:I.placement;if(!B)switch(x){case"bestFit":{var Q;const ae=(Q=O.filter(F=>{if(C){const A=it(F.placement);return A===w||A==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(A=>A>0).reduce((A,ce)=>A+ce,0)]).sort((F,A)=>F[1]-A[1])[0])==null?void 0:Q[0];ae&&(B=ae);break}case"initialPlacement":B=i;break}if(a!==B)return{reset:{placement:B}}}return{}}}};function Ki(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qi(e){return Cg.some(t=>e[t]>=0)}const Lg=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...o}=jt(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...o,elementContext:"reference"}),i=Ki(c,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:qi(i)}}}case"escaped":{const c=await s.detectOverflow(t,{...o,altBoundary:!0}),i=Ki(c,n.floating);return{data:{escapedOffsets:i,escaped:qi(i)}}}default:return{}}}}},El=new Set(["left","top"]);async function Fg(e,t){const{placement:n,platform:s,elements:a}=e,o=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=Nt(n),i=rr(n),f=it(n)==="y",u=El.has(c)?-1:1,d=o&&f?-1:1,h=jt(t,e);let{mainAxis:m,crossAxis:x,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return i&&typeof g=="number"&&(x=i==="end"?g*-1:g),f?{x:x*d,y:m*u}:{x:m*u,y:x*d}}const $g=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:o,placement:c,middlewareData:i}=t,f=await Fg(t,e);return c===((n=i.offset)==null?void 0:n.placement)&&(s=i.arrow)!=null&&s.alignmentOffset?{}:{x:a+f.x,y:o+f.y,data:{...f,placement:c}}}}},Ug=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:o}=t,{mainAxis:c=!0,crossAxis:i=!1,limiter:f={fn:y=>{let{x:w,y:N}=y;return{x:w,y:N}}},...u}=jt(e,t),d={x:n,y:s},h=await o.detectOverflow(t,u),m=it(Nt(a)),x=To(m);let g=d[x],p=d[m];if(c){const y=x==="y"?"top":"left",w=x==="y"?"bottom":"right",N=g+h[y],j=g-h[w];g=Ja(N,g,j)}if(i){const y=m==="y"?"top":"left",w=m==="y"?"bottom":"right",N=p+h[y],j=p-h[w];p=Ja(N,p,j)}const v=f.fn({...t,[x]:g,[m]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[x]:c,[m]:i}}}}}},Vg=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:o,middlewareData:c}=t,{offset:i=0,mainAxis:f=!0,crossAxis:u=!0}=jt(e,t),d={x:n,y:s},h=it(a),m=To(h);let x=d[m],g=d[h];const p=jt(i,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(f){const N=m==="y"?"height":"width",j=o.reference[m]-o.floating[N]+v.mainAxis,S=o.reference[m]+o.reference[N]-v.mainAxis;x<j?x=j:x>S&&(x=S)}if(u){var y,w;const N=m==="y"?"width":"height",j=El.has(Nt(a)),S=o.reference[h]-o.floating[N]+(j&&((y=c.offset)==null?void 0:y[h])||0)+(j?0:v.crossAxis),C=o.reference[h]+o.reference[N]+(j?0:((w=c.offset)==null?void 0:w[h])||0)-(j?v.crossAxis:0);g<S?g=S:g>C&&(g=C)}return{[m]:x,[h]:g}}}},Bg=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:o,platform:c,elements:i}=t,{apply:f=()=>{},...u}=jt(e,t),d=await c.detectOverflow(t,u),h=Nt(a),m=rr(a),x=it(a)==="y",{width:g,height:p}=o.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=m===(await(c.isRTL==null?void 0:c.isRTL(i.floating))?"start":"end")?"left":"right"):(y=h,v=m==="end"?"top":"bottom");const w=p-d.top-d.bottom,N=g-d.left-d.right,j=Ht(p-d[v],w),S=Ht(g-d[y],N),C=!t.middlewareData.shift;let E=j,k=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(E=w),C&&!m){const O=$e(d.left,0),U=$e(d.right,0),I=$e(d.top,0),Q=$e(d.bottom,0);x?k=g-2*(O!==0||U!==0?O+U:$e(d.left,d.right)):E=p-2*(I!==0||Q!==0?I+Q:$e(d.top,d.bottom))}await f({...t,availableWidth:k,availableHeight:E});const z=await c.getDimensions(i.floating);return g!==z.width||p!==z.height?{reset:{rects:!0}}:{}}}};function Os(){return typeof window<"u"}function sr(e){return Rl(e)?(e.nodeName||"").toLowerCase():"#document"}function Be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ft(e){var t;return(t=(Rl(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Rl(e){return Os()?e instanceof Node||e instanceof Be(e).Node:!1}function Je(e){return Os()?e instanceof Element||e instanceof Be(e).Element:!1}function Et(e){return Os()?e instanceof HTMLElement||e instanceof Be(e).HTMLElement:!1}function Hi(e){return!Os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Be(e).ShadowRoot}function Dr(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=et(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function Kg(e){return/^(table|td|th)$/.test(sr(e))}function Ds(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const qg=/transform|translate|scale|rotate|perspective|filter/,Hg=/paint|layout|strict|content/,tn=e=>!!e&&e!=="none";let xa;function _o(e){const t=Je(e)?et(e):e;return tn(t.transform)||tn(t.translate)||tn(t.scale)||tn(t.rotate)||tn(t.perspective)||!Io()&&(tn(t.backdropFilter)||tn(t.filter))||qg.test(t.willChange||"")||Hg.test(t.contain||"")}function Wg(e){let t=Wt(e);for(;Et(t)&&!Qn(t);){if(_o(t))return t;if(Ds(t))return null;t=Wt(t)}return null}function Io(){return xa==null&&(xa=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),xa}function Qn(e){return/^(html|body|#document)$/.test(sr(e))}function et(e){return Be(e).getComputedStyle(e)}function zs(e){return Je(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wt(e){if(sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Hi(e)&&e.host||ft(e);return Hi(t)?t.host:t}function Pl(e){const t=Wt(e);return Qn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Et(t)&&Dr(t)?t:Pl(t)}function jr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=Pl(e),o=a===((s=e.ownerDocument)==null?void 0:s.body),c=Be(a);if(o){const i=to(c);return t.concat(c,c.visualViewport||[],Dr(a)?a:[],i&&n?jr(i):[])}else return t.concat(a,jr(a,[],n))}function to(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kl(e){const t=et(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Et(e),o=a?e.offsetWidth:n,c=a?e.offsetHeight:s,i=bs(n)!==o||bs(s)!==c;return i&&(n=o,s=c),{width:n,height:s,$:i}}function Oo(e){return Je(e)?e:e.contextElement}function _n(e){const t=Oo(e);if(!Et(t))return ct(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:o}=kl(t);let c=(o?bs(n.width):n.width)/s,i=(o?bs(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!i||!Number.isFinite(i))&&(i=1),{x:c,y:i}}const Gg=ct(0);function Tl(e){const t=Be(e);return!Io()||!t.visualViewport?Gg:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qg(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Be(e)?!1:t}function xn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=Oo(e);let c=ct(1);t&&(s?Je(s)&&(c=_n(s)):c=_n(e));const i=Qg(o,n,s)?Tl(o):ct(0);let f=(a.left+i.x)/c.x,u=(a.top+i.y)/c.y,d=a.width/c.x,h=a.height/c.y;if(o){const m=Be(o),x=s&&Je(s)?Be(s):s;let g=m,p=to(g);for(;p&&s&&x!==g;){const v=_n(p),y=p.getBoundingClientRect(),w=et(p),N=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*v.x,j=y.top+(p.clientTop+parseFloat(w.paddingTop))*v.y;f*=v.x,u*=v.y,d*=v.x,h*=v.y,f+=N,u+=j,g=Be(p),p=to(g)}}return js({width:d,height:h,x:f,y:u})}function Ls(e,t){const n=zs(e).scrollLeft;return t?t.left+n:xn(ft(e)).left+n}function Al(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Ls(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function Yg(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const o=a==="fixed",c=ft(s),i=t?Ds(t.floating):!1;if(s===c||i&&o)return n;let f={scrollLeft:0,scrollTop:0},u=ct(1);const d=ct(0),h=Et(s);if((h||!h&&!o)&&((sr(s)!=="body"||Dr(c))&&(f=zs(s)),h)){const x=xn(s);u=_n(s),d.x=x.x+s.clientLeft,d.y=x.y+s.clientTop}const m=c&&!h&&!o?Al(c,f):ct(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-f.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-f.scrollTop*u.y+d.y+m.y}}function Xg(e){return Array.from(e.getClientRects())}function Zg(e){const t=ft(e),n=zs(e),s=e.ownerDocument.body,a=$e(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=$e(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Ls(e);const i=-n.scrollTop;return et(s).direction==="rtl"&&(c+=$e(t.clientWidth,s.clientWidth)-a),{width:a,height:o,x:c,y:i}}const Wi=25;function Jg(e,t){const n=Be(e),s=ft(e),a=n.visualViewport;let o=s.clientWidth,c=s.clientHeight,i=0,f=0;if(a){o=a.width,c=a.height;const d=Io();(!d||d&&t==="fixed")&&(i=a.offsetLeft,f=a.offsetTop)}const u=Ls(s);if(u<=0){const d=s.ownerDocument,h=d.body,m=getComputedStyle(h),x=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(s.clientWidth-h.clientWidth-x);g<=Wi&&(o-=g)}else u<=Wi&&(o+=u);return{width:o,height:c,x:i,y:f}}function ev(e,t){const n=xn(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,o=Et(e)?_n(e):ct(1),c=e.clientWidth*o.x,i=e.clientHeight*o.y,f=a*o.x,u=s*o.y;return{width:c,height:i,x:f,y:u}}function Gi(e,t,n){let s;if(t==="viewport")s=Jg(e,n);else if(t==="document")s=Zg(ft(e));else if(Je(t))s=ev(t,n);else{const a=Tl(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return js(s)}function Ml(e,t){const n=Wt(e);return n===t||!Je(n)||Qn(n)?!1:et(n).position==="fixed"||Ml(n,t)}function tv(e,t){const n=t.get(e);if(n)return n;let s=jr(e,[],!1).filter(i=>Je(i)&&sr(i)!=="body"),a=null;const o=et(e).position==="fixed";let c=o?Wt(e):e;for(;Je(c)&&!Qn(c);){const i=et(c),f=_o(c);!f&&i.position==="fixed"&&(a=null),(o?!f&&!a:!f&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Dr(c)&&!f&&Ml(e,c))?s=s.filter(d=>d!==c):a=i,c=Wt(c)}return t.set(e,s),s}function nv(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?Ds(t)?[]:tv(t,this._c):[].concat(n),s],i=Gi(t,c[0],a);let f=i.top,u=i.right,d=i.bottom,h=i.left;for(let m=1;m<c.length;m++){const x=Gi(t,c[m],a);f=$e(x.top,f),u=Ht(x.right,u),d=Ht(x.bottom,d),h=$e(x.left,h)}return{width:u-h,height:d-f,x:h,y:f}}function rv(e){const{width:t,height:n}=kl(e);return{width:t,height:n}}function sv(e,t,n){const s=Et(t),a=ft(t),o=n==="fixed",c=xn(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const f=ct(0);function u(){f.x=Ls(a)}if(s||!s&&!o)if((sr(t)!=="body"||Dr(a))&&(i=zs(t)),s){const x=xn(t,!0,o,t);f.x=x.x+t.clientLeft,f.y=x.y+t.clientTop}else a&&u();o&&!s&&a&&u();const d=a&&!s&&!o?Al(a,i):ct(0),h=c.left+i.scrollLeft-f.x-d.x,m=c.top+i.scrollTop-f.y-d.y;return{x:h,y:m,width:c.width,height:c.height}}function ga(e){return et(e).position==="static"}function Qi(e,t){if(!Et(e)||et(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ft(e)===n&&(n=n.ownerDocument.body),n}function _l(e,t){const n=Be(e);if(Ds(e))return n;if(!Et(e)){let a=Wt(e);for(;a&&!Qn(a);){if(Je(a)&&!ga(a))return a;a=Wt(a)}return n}let s=Qi(e,t);for(;s&&Kg(s)&&ga(s);)s=Qi(s,t);return s&&Qn(s)&&ga(s)&&!_o(s)?n:s||Wg(e)||n}const av=async function(e){const t=this.getOffsetParent||_l,n=this.getDimensions,s=await n(e.floating);return{reference:sv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function ov(e){return et(e).direction==="rtl"}const iv={convertOffsetParentRelativeRectToViewportRelativeRect:Yg,getDocumentElement:ft,getClippingRect:nv,getOffsetParent:_l,getElementRects:av,getClientRects:Xg,getDimensions:rv,getScale:_n,isElement:Je,isRTL:ov};function Il(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cv(e,t){let n=null,s;const a=ft(e);function o(){var i;clearTimeout(s),(i=n)==null||i.disconnect(),n=null}function c(i,f){i===void 0&&(i=!1),f===void 0&&(f=1),o();const u=e.getBoundingClientRect(),{left:d,top:h,width:m,height:x}=u;if(i||t(),!m||!x)return;const g=Jr(h),p=Jr(a.clientWidth-(d+m)),v=Jr(a.clientHeight-(h+x)),y=Jr(d),N={rootMargin:-g+"px "+-p+"px "+-v+"px "+-y+"px",threshold:$e(0,Ht(1,f))||1};let j=!0;function S(C){const E=C[0].intersectionRatio;if(E!==f){if(!j)return c();E?c(!1,E):s=setTimeout(()=>{c(!1,1e-7)},1e3)}E===1&&!Il(u,e.getBoundingClientRect())&&c(),j=!1}try{n=new IntersectionObserver(S,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(S,N)}n.observe(e)}return c(!0),o}function lv(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:f=!1}=s,u=Oo(e),d=a||o?[...u?jr(u):[],...t?jr(t):[]]:[];d.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const h=u&&i?cv(u,n):null;let m=-1,x=null;c&&(x=new ResizeObserver(y=>{let[w]=y;w&&w.target===u&&x&&t&&(x.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),u&&!f&&x.observe(u),t&&x.observe(t));let g,p=f?xn(e):null;f&&v();function v(){const y=xn(e);p&&!Il(p,y)&&n(),p=y,g=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(w=>{a&&w.removeEventListener("scroll",n),o&&w.removeEventListener("resize",n)}),h==null||h(),(y=x)==null||y.disconnect(),x=null,f&&cancelAnimationFrame(g)}}const dv=$g,uv=Ug,fv=zg,hv=Bg,mv=Lg,Yi=Dg,pv=Vg,xv=(e,t,n)=>{const s=new Map,a={platform:iv,...n},o={...a.platform,_c:s};return Og(e,t,{...a,platform:o})};var gv=typeof document<"u",vv=function(){},ls=gv?l.useLayoutEffect:vv;function Ns(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,a;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(!Ns(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const o=a[s];if(!(o==="_owner"&&e.$$typeof)&&!Ns(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Ol(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Xi(e,t){const n=Ol(e);return Math.round(t*n)/n}function va(e){const t=l.useRef(e);return ls(()=>{t.current=e}),t}function yv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:o,floating:c}={},transform:i=!0,whileElementsMounted:f,open:u}=e,[d,h]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,x]=l.useState(s);Ns(m,s)||x(s);const[g,p]=l.useState(null),[v,y]=l.useState(null),w=l.useCallback(F=>{F!==C.current&&(C.current=F,p(F))},[]),N=l.useCallback(F=>{F!==E.current&&(E.current=F,y(F))},[]),j=o||g,S=c||v,C=l.useRef(null),E=l.useRef(null),k=l.useRef(d),z=f!=null,O=va(f),U=va(a),I=va(u),Q=l.useCallback(()=>{if(!C.current||!E.current)return;const F={placement:t,strategy:n,middleware:m};U.current&&(F.platform=U.current),xv(C.current,E.current,F).then(A=>{const ce={...A,isPositioned:I.current!==!1};V.current&&!Ns(k.current,ce)&&(k.current=ce,Ts.flushSync(()=>{h(ce)}))})},[m,t,n,U,I]);ls(()=>{u===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[u]);const V=l.useRef(!1);ls(()=>(V.current=!0,()=>{V.current=!1}),[]),ls(()=>{if(j&&(C.current=j),S&&(E.current=S),j&&S){if(O.current)return O.current(j,S,Q);Q()}},[j,S,Q,O,z]);const Z=l.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:N}),[w,N]),B=l.useMemo(()=>({reference:j,floating:S}),[j,S]),ae=l.useMemo(()=>{const F={position:n,left:0,top:0};if(!B.floating)return F;const A=Xi(B.floating,d.x),ce=Xi(B.floating,d.y);return i?{...F,transform:"translate("+A+"px, "+ce+"px)",...Ol(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:ce}},[n,i,B.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:Q,refs:Z,elements:B,floatingStyles:ae}),[d,Q,Z,B,ae])}const bv=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Yi({element:s.current,padding:a}).fn(n):{}:s?Yi({element:s,padding:a}).fn(n):{}}}},wv=(e,t)=>{const n=dv(e);return{name:n.name,fn:n.fn,options:[e,t]}},jv=(e,t)=>{const n=uv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nv=(e,t)=>({fn:pv(e).fn,options:[e,t]}),Cv=(e,t)=>{const n=fv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sv=(e,t)=>{const n=hv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ev=(e,t)=>{const n=mv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rv=(e,t)=>{const n=bv(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Pv="Arrow",Dl=l.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...o}=e;return r.jsx(G.svg,{...o,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});Dl.displayName=Pv;var kv=Dl;function zl(e){const[t,n]=l.useState(void 0);return Pe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let c,i;if("borderBoxSize"in o){const f=o.borderBoxSize,u=Array.isArray(f)?f[0]:f;c=u.inlineSize,i=u.blockSize}else c=e.offsetWidth,i=e.offsetHeight;n({width:c,height:i})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Do="Popper",[Ll,ar]=ut(Do),[Tv,Fl]=Ll(Do),$l=e=>{const{__scopePopper:t,children:n}=e,[s,a]=l.useState(null);return r.jsx(Tv,{scope:t,anchor:s,onAnchorChange:a,children:n})};$l.displayName=Do;var Ul="PopperAnchor",Vl=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,o=Fl(Ul,n),c=l.useRef(null),i=de(t,c),f=l.useRef(null);return l.useEffect(()=>{const u=f.current;f.current=(s==null?void 0:s.current)||c.current,u!==f.current&&o.onAnchorChange(f.current)}),s?null:r.jsx(G.div,{...a,ref:i})});Vl.displayName=Ul;var zo="PopperContent",[Av,Mv]=Ll(zo),Bl=l.forwardRef((e,t)=>{var M,Y,X,ie,he,me;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:o="center",alignOffset:c=0,arrowPadding:i=0,avoidCollisions:f=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:x="optimized",onPlaced:g,...p}=e,v=Fl(zo,n),[y,w]=l.useState(null),N=de(t,ze=>w(ze)),[j,S]=l.useState(null),C=zl(j),E=(C==null?void 0:C.width)??0,k=(C==null?void 0:C.height)??0,z=s+(o!=="center"?"-"+o:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},U=Array.isArray(u)?u:[u],I=U.length>0,Q={padding:O,boundary:U.filter(Iv),altBoundary:I},{refs:V,floatingStyles:Z,placement:B,isPositioned:ae,middlewareData:F}=yv({strategy:"fixed",placement:z,whileElementsMounted:(...ze)=>lv(...ze,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[wv({mainAxis:a+k,alignmentAxis:c}),f&&jv({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Nv():void 0,...Q}),f&&Cv({...Q}),Sv({...Q,apply:({elements:ze,rects:nt,availableWidth:cr,availableHeight:lr})=>{const{width:dr,height:fh}=nt.reference,Gr=ze.floating.style;Gr.setProperty("--radix-popper-available-width",`${cr}px`),Gr.setProperty("--radix-popper-available-height",`${lr}px`),Gr.setProperty("--radix-popper-anchor-width",`${dr}px`),Gr.setProperty("--radix-popper-anchor-height",`${fh}px`)}}),j&&Rv({element:j,padding:i}),Ov({arrowWidth:E,arrowHeight:k}),m&&Ev({strategy:"referenceHidden",...Q})]}),[A,ce]=Hl(B),le=dt(g);Pe(()=>{ae&&(le==null||le())},[ae,le]);const R=(M=F.arrow)==null?void 0:M.x,K=(Y=F.arrow)==null?void 0:Y.y,H=((X=F.arrow)==null?void 0:X.centerOffset)!==0,[L,J]=l.useState();return Pe(()=>{y&&J(window.getComputedStyle(y).zIndex)},[y]),r.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:ae?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(ie=F.transformOrigin)==null?void 0:ie.x,(he=F.transformOrigin)==null?void 0:he.y].join(" "),...((me=F.hide)==null?void 0:me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(Av,{scope:n,placedSide:A,onArrowChange:S,arrowX:R,arrowY:K,shouldHideArrow:H,children:r.jsx(G.div,{"data-side":A,"data-align":ce,...p,ref:N,style:{...p.style,animation:ae?void 0:"none"}})})})});Bl.displayName=zo;var Kl="PopperArrow",_v={top:"bottom",right:"left",bottom:"top",left:"right"},ql=l.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,o=Mv(Kl,s),c=_v[o.placedSide];return r.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:r.jsx(kv,{...a,ref:n,style:{...a.style,display:"block"}})})});ql.displayName=Kl;function Iv(e){return e!==null}var Ov=e=>({name:"transformOrigin",options:e,fn(t){var v,y,w;const{placement:n,rects:s,middlewareData:a}=t,c=((v=a.arrow)==null?void 0:v.centerOffset)!==0,i=c?0:e.arrowWidth,f=c?0:e.arrowHeight,[u,d]=Hl(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=a.arrow)==null?void 0:y.x)??0)+i/2,x=(((w=a.arrow)==null?void 0:w.y)??0)+f/2;let g="",p="";return u==="bottom"?(g=c?h:`${m}px`,p=`${-f}px`):u==="top"?(g=c?h:`${m}px`,p=`${s.floating.height+f}px`):u==="right"?(g=`${-f}px`,p=c?h:`${x}px`):u==="left"&&(g=`${s.floating.width+f}px`,p=c?h:`${x}px`),{data:{x:g,y:p}}}});function Hl(e){const[t,n="center"]=e.split("-");return[t,n]}var Lo=$l,Fs=Vl,Fo=Bl,$o=ql,Dv="Portal",zr=l.forwardRef((e,t)=>{var i;const{container:n,...s}=e,[a,o]=l.useState(!1);Pe(()=>o(!0),[]);const c=n||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return c?gh.createPortal(r.jsx(G.div,{...s,ref:t}),c):null});zr.displayName=Dv;function zv(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var Qe=e=>{const{present:t,children:n}=e,s=Lv(t),a=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),o=de(s.ref,Fv(a));return typeof n=="function"||s.isPresent?l.cloneElement(a,{ref:o}):null};Qe.displayName="Presence";function Lv(e){const[t,n]=l.useState(),s=l.useRef(null),a=l.useRef(e),o=l.useRef("none"),c=e?"mounted":"unmounted",[i,f]=zv(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=es(s.current);o.current=i==="mounted"?u:"none"},[i]),Pe(()=>{const u=s.current,d=a.current;if(d!==e){const m=o.current,x=es(u);e?f("MOUNT"):x==="none"||(u==null?void 0:u.display)==="none"?f("UNMOUNT"):f(d&&m!==x?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),Pe(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,h=x=>{const p=es(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&p&&(f("ANIMATION_END"),!a.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=x=>{x.target===t&&(o.current=es(s.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function es(e){return(e==null?void 0:e.animationName)||"none"}function Fv(e){var s,a;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=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var $v=go[" useInsertionEffect ".trim().toString()]||Pe;function Gt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[a,o,c]=Uv({defaultProp:t,onChange:n}),i=e!==void 0,f=i?e:a;{const d=l.useRef(e!==void 0);l.useEffect(()=>{const h=d.current;h!==i&&console.warn(`${s} is changing from ${h?"controlled":"uncontrolled"} to ${i?"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.`),d.current=i},[i,s])}const u=l.useCallback(d=>{var h;if(i){const m=Vv(d)?d(e):d;m!==e&&((h=c.current)==null||h.call(c,m))}else o(d)},[i,e,o,c]);return[f,u]}function Uv({defaultProp:e,onChange:t}){const[n,s]=l.useState(e),a=l.useRef(n),o=l.useRef(t);return $v(()=>{o.current=t},[t]),l.useEffect(()=>{var c;a.current!==n&&((c=o.current)==null||c.call(o,n),a.current=n)},[n,a]),[n,s,o]}function Vv(e){return typeof e=="function"}var Bv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},En=new WeakMap,ts=new WeakMap,ns={},ya=0,Wl=function(e){return e&&(e.host||Wl(e.parentNode))},Kv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Wl(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})},qv=function(e,t,n,s){var a=Kv(t,Array.isArray(e)?e:[e]);ns[n]||(ns[n]=new WeakMap);var o=ns[n],c=[],i=new Set,f=new Set(a),u=function(h){!h||i.has(h)||(i.add(h),u(h.parentNode))};a.forEach(u);var d=function(h){!h||f.has(h)||Array.prototype.forEach.call(h.children,function(m){if(i.has(m))d(m);else try{var x=m.getAttribute(s),g=x!==null&&x!=="false",p=(En.get(m)||0)+1,v=(o.get(m)||0)+1;En.set(m,p),o.set(m,v),c.push(m),p===1&&g&&ts.set(m,!0),v===1&&m.setAttribute(n,"true"),g||m.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),i.clear(),ya++,function(){c.forEach(function(h){var m=En.get(h)-1,x=o.get(h)-1;En.set(h,m),o.set(h,x),m||(ts.has(h)||h.removeAttribute(s),ts.delete(h)),x||h.removeAttribute(n)}),ya--,ya||(En=new WeakMap,En=new WeakMap,ts=new WeakMap,ns={})}},$s=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),a=Bv(e);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),qv(s,a,n,"aria-hidden")):function(){return null}},ot=function(){return ot=Object.assign||function(t){for(var n,s=1,a=arguments.length;s<a;s++){n=arguments[s];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},ot.apply(this,arguments)};function Gl(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 a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(n[s[a]]=e[s[a]]);return n}function Hv(e,t,n){if(n||arguments.length===2)for(var s=0,a=t.length,o;s<a;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}var ds="right-scroll-bar-position",us="width-before-scroll-bar",Wv="with-scroll-bars-hidden",Gv="--removed-body-scroll-bar-size";function ba(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Qv(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var a=n.value;a!==s&&(n.value=s,n.callback(s,a))}}}})[0];return n.callback=t,n.facade}var Yv=typeof window<"u"?l.useLayoutEffect:l.useEffect,Zi=new WeakMap;function Xv(e,t){var n=Qv(null,function(s){return e.forEach(function(a){return ba(a,s)})});return Yv(function(){var s=Zi.get(n);if(s){var a=new Set(s),o=new Set(e),c=n.current;a.forEach(function(i){o.has(i)||ba(i,null)}),o.forEach(function(i){a.has(i)||ba(i,c)})}Zi.set(n,e)},[e]),n}function Zv(e){return e}function Jv(e,t){t===void 0&&(t=Zv);var n=[],s=!1,a={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(o){var c=t(o,s);return n.push(c),function(){n=n.filter(function(i){return i!==c})}},assignSyncMedium:function(o){for(s=!0;n.length;){var c=n;n=[],c.forEach(o)}n={push:function(i){return o(i)},filter:function(){return n}}},assignMedium:function(o){s=!0;var c=[];if(n.length){var i=n;n=[],i.forEach(o),c=n}var f=function(){var d=c;c=[],d.forEach(o)},u=function(){return Promise.resolve().then(f)};u(),n={push:function(d){c.push(d),u()},filter:function(d){return c=c.filter(d),n}}}};return a}function e0(e){e===void 0&&(e={});var t=Jv(null);return t.options=ot({async:!0,ssr:!1},e),t}var Ql=function(e){var t=e.sideCar,n=Gl(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,ot({},n))};Ql.isSideCarExport=!0;function t0(e,t){return e.useMedium(t),Ql}var Yl=e0(),wa=function(){},Us=l.forwardRef(function(e,t){var n=l.useRef(null),s=l.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),a=s[0],o=s[1],c=e.forwardProps,i=e.children,f=e.className,u=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,x=e.noRelative,g=e.noIsolation,p=e.inert,v=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,N=e.gapMode,j=Gl(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,C=Xv([n,t]),E=ot(ot({},j),a);return l.createElement(l.Fragment,null,d&&l.createElement(S,{sideCar:Yl,removeScrollBar:u,shards:h,noRelative:x,noIsolation:g,inert:p,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:N}),c?l.cloneElement(l.Children.only(i),ot(ot({},E),{ref:C})):l.createElement(w,ot({},E,{className:f,ref:C}),i))});Us.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Us.classNames={fullWidth:us,zeroRight:ds};var n0=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function r0(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=n0();return t&&e.setAttribute("nonce",t),e}function s0(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function a0(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var o0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=r0())&&(s0(t,n),a0(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},i0=function(){var e=o0();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Xl=function(){var e=i0(),t=function(n){var s=n.styles,a=n.dynamic;return e(s,a),null};return t},c0={left:0,top:0,right:0,gap:0},ja=function(e){return parseInt(e||"",10)||0},l0=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[ja(n),ja(s),ja(a)]},d0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return c0;var t=l0(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])}},u0=Xl(),In="data-scroll-locked",f0=function(e,t,n,s){var a=e.left,o=e.top,c=e.right,i=e.gap;return n===void 0&&(n="margin"),`
280
+ .`.concat(Wv,` {
281
+ overflow: hidden `).concat(s,`;
282
+ padding-right: `).concat(i,"px ").concat(s,`;
283
+ }
284
+ body[`).concat(In,`] {
285
+ overflow: hidden `).concat(s,`;
286
+ overscroll-behavior: contain;
287
+ `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
288
+ padding-left: `.concat(a,`px;
289
+ padding-top: `).concat(o,`px;
290
+ padding-right: `).concat(c,`px;
291
+ margin-left:0;
292
+ margin-top:0;
293
+ margin-right: `).concat(i,"px ").concat(s,`;
294
+ `),n==="padding"&&"padding-right: ".concat(i,"px ").concat(s,";")].filter(Boolean).join(""),`
295
+ }
296
+
297
+ .`).concat(ds,` {
298
+ right: `).concat(i,"px ").concat(s,`;
299
+ }
300
+
301
+ .`).concat(us,` {
302
+ margin-right: `).concat(i,"px ").concat(s,`;
303
+ }
304
+
305
+ .`).concat(ds," .").concat(ds,` {
306
+ right: 0 `).concat(s,`;
307
+ }
308
+
309
+ .`).concat(us," .").concat(us,` {
310
+ margin-right: 0 `).concat(s,`;
311
+ }
312
+
313
+ body[`).concat(In,`] {
314
+ `).concat(Gv,": ").concat(i,`px;
315
+ }
316
+ `)},Ji=function(){var e=parseInt(document.body.getAttribute(In)||"0",10);return isFinite(e)?e:0},h0=function(){l.useEffect(function(){return document.body.setAttribute(In,(Ji()+1).toString()),function(){var e=Ji()-1;e<=0?document.body.removeAttribute(In):document.body.setAttribute(In,e.toString())}},[])},m0=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,a=s===void 0?"margin":s;h0();var o=l.useMemo(function(){return d0(a)},[a]);return l.createElement(u0,{styles:f0(o,!t,a,n?"":"!important")})},no=!1;if(typeof window<"u")try{var rs=Object.defineProperty({},"passive",{get:function(){return no=!0,!0}});window.addEventListener("test",rs,rs),window.removeEventListener("test",rs,rs)}catch{no=!1}var Rn=no?{passive:!1}:!1,p0=function(e){return e.tagName==="TEXTAREA"},Zl=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!p0(e)&&n[t]==="visible")},x0=function(e){return Zl(e,"overflowY")},g0=function(e){return Zl(e,"overflowX")},ec=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Jl(e,s);if(a){var o=ed(e,s),c=o[1],i=o[2];if(c>i)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},v0=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},y0=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Jl=function(e,t){return e==="v"?x0(t):g0(t)},ed=function(e,t){return e==="v"?v0(t):y0(t)},b0=function(e,t){return e==="h"&&t==="rtl"?-1:1},w0=function(e,t,n,s,a){var o=b0(e,window.getComputedStyle(t).direction),c=o*s,i=n.target,f=t.contains(i),u=!1,d=c>0,h=0,m=0;do{if(!i)break;var x=ed(e,i),g=x[0],p=x[1],v=x[2],y=p-v-o*g;(g||y)&&Jl(e,i)&&(h+=y,m+=g);var w=i.parentNode;i=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!f&&i!==document.body||f&&(t.contains(i)||t===i));return(d&&Math.abs(h)<1||!d&&Math.abs(m)<1)&&(u=!0),u},ss=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tc=function(e){return[e.deltaX,e.deltaY]},nc=function(e){return e&&"current"in e?e.current:e},j0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},N0=function(e){return`
317
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
318
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
319
+ `)},C0=0,Pn=[];function S0(e){var t=l.useRef([]),n=l.useRef([0,0]),s=l.useRef(),a=l.useState(C0++)[0],o=l.useState(Xl)[0],c=l.useRef(e);l.useEffect(function(){c.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var p=Hv([e.lockRef.current],(e.shards||[]).map(nc),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var i=l.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!c.current.allowPinchZoom;var y=ss(p),w=n.current,N="deltaX"in p?p.deltaX:w[0]-y[0],j="deltaY"in p?p.deltaY:w[1]-y[1],S,C=p.target,E=Math.abs(N)>Math.abs(j)?"h":"v";if("touches"in p&&E==="h"&&C.type==="range")return!1;var k=window.getSelection(),z=k&&k.anchorNode,O=z?z===C||z.contains(C):!1;if(O)return!1;var U=ec(E,C);if(!U)return!0;if(U?S=E:(S=E==="v"?"h":"v",U=ec(E,C)),!U)return!1;if(!s.current&&"changedTouches"in p&&(N||j)&&(s.current=S),!S)return!0;var I=s.current||S;return w0(I,v,p,I==="h"?N:j)},[]),f=l.useCallback(function(p){var v=p;if(!(!Pn.length||Pn[Pn.length-1]!==o)){var y="deltaY"in v?tc(v):ss(v),w=t.current.filter(function(S){return S.name===v.type&&(S.target===v.target||v.target===S.shadowParent)&&j0(S.delta,y)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var N=(c.current.shards||[]).map(nc).filter(Boolean).filter(function(S){return S.contains(v.target)}),j=N.length>0?i(v,N[0]):!c.current.noIsolation;j&&v.cancelable&&v.preventDefault()}}},[]),u=l.useCallback(function(p,v,y,w){var N={name:p,delta:v,target:y,should:w,shadowParent:E0(y)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(j){return j!==N})},1)},[]),d=l.useCallback(function(p){n.current=ss(p),s.current=void 0},[]),h=l.useCallback(function(p){u(p.type,tc(p),p.target,i(p,e.lockRef.current))},[]),m=l.useCallback(function(p){u(p.type,ss(p),p.target,i(p,e.lockRef.current))},[]);l.useEffect(function(){return Pn.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",f,Rn),document.addEventListener("touchmove",f,Rn),document.addEventListener("touchstart",d,Rn),function(){Pn=Pn.filter(function(p){return p!==o}),document.removeEventListener("wheel",f,Rn),document.removeEventListener("touchmove",f,Rn),document.removeEventListener("touchstart",d,Rn)}},[]);var x=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(o,{styles:N0(a)}):null,x?l.createElement(m0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function E0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const R0=t0(Yl,S0);var Lr=l.forwardRef(function(e,t){return l.createElement(Us,ot({},e,{ref:t,sideCar:R0}))});Lr.classNames=Us.classNames;var Vs="Popover",[td]=ut(Vs,[ar]),Fr=ar(),[P0,Zt]=td(Vs),nd=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:c=!1}=e,i=Fr(t),f=l.useRef(null),[u,d]=l.useState(!1),[h,m]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:Vs});return r.jsx(Lo,{...i,children:r.jsx(P0,{scope:t,contentId:Ne(),triggerRef:f,open:h,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(x=>!x),[m]),hasCustomAnchor:u,onCustomAnchorAdd:l.useCallback(()=>d(!0),[]),onCustomAnchorRemove:l.useCallback(()=>d(!1),[]),modal:c,children:n})})};nd.displayName=Vs;var rd="PopoverAnchor",k0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(rd,n),o=Fr(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=a;return l.useEffect(()=>(c(),()=>i()),[c,i]),r.jsx(Fs,{...o,...s,ref:t})});k0.displayName=rd;var sd="PopoverTrigger",ad=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(sd,n),o=Fr(n),c=de(t,a.triggerRef),i=r.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":dd(a.open),...s,ref:c,onClick:D(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:r.jsx(Fs,{asChild:!0,...o,children:i})});ad.displayName=sd;var Uo="PopoverPortal",[T0,A0]=td(Uo,{forceMount:void 0}),od=e=>{const{__scopePopover:t,forceMount:n,children:s,container:a}=e,o=Zt(Uo,t);return r.jsx(T0,{scope:t,forceMount:n,children:r.jsx(Qe,{present:n||o.open,children:r.jsx(zr,{asChild:!0,container:a,children:s})})})};od.displayName=Uo;var Yn="PopoverContent",id=l.forwardRef((e,t)=>{const n=A0(Yn,e.__scopePopover),{forceMount:s=n.forceMount,...a}=e,o=Zt(Yn,e.__scopePopover);return r.jsx(Qe,{present:s||o.open,children:o.modal?r.jsx(_0,{...a,ref:t}):r.jsx(I0,{...a,ref:t})})});id.displayName=Yn;var M0=pn("PopoverContent.RemoveScroll"),_0=l.forwardRef((e,t)=>{const n=Zt(Yn,e.__scopePopover),s=l.useRef(null),a=de(t,s),o=l.useRef(!1);return l.useEffect(()=>{const c=s.current;if(c)return $s(c)},[]),r.jsx(Lr,{as:M0,allowPinchZoom:!0,children:r.jsx(cd,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:D(e.onCloseAutoFocus,c=>{var i;c.preventDefault(),o.current||(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:D(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,u=i.button===2||f;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:D(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),I0=l.forwardRef((e,t)=>{const n=Zt(Yn,e.__scopePopover),s=l.useRef(!1),a=l.useRef(!1);return r.jsx(cd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,o),o.defaultPrevented||(s.current||(i=n.triggerRef.current)==null||i.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,u;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=o.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),cd=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:u,onInteractOutside:d,...h}=e,m=Zt(Yn,n),x=Fr(n);return Is(),r.jsx(Or,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(Ir,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:d,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:r.jsx(Fo,{"data-state":dd(m.open),role:"dialog",id:m.contentId,...x,...h,ref:t,style:{...h.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)"}})})})}),ld="PopoverClose",O0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(ld,n);return r.jsx(G.button,{type:"button",...s,ref:t,onClick:D(e.onClick,()=>a.onOpenChange(!1))})});O0.displayName=ld;var D0="PopoverArrow",z0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Fr(n);return r.jsx($o,{...a,...s,ref:t})});z0.displayName=D0;function dd(e){return e?"open":"closed"}var L0=nd,F0=ad,$0=od,ud=id;const U0=L0,V0=F0,fd=l.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},a)=>r.jsx($0,{children:r.jsx(ud,{ref:a,align:t,sideOffset:n,className:T("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})}));fd.displayName=ud.displayName;const rc=e=>{let t;const n=new Set,s=(u,d)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const m=t;t=d??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(x=>x(t,m))}},a=()=>t,i={setState:s,getState:a,getInitialState:()=>f,subscribe:u=>(n.add(u),()=>n.delete(u))},f=t=e(s,a,i);return i},B0=(e=>e?rc(e):rc),K0=e=>e;function q0(e,t=K0){const n=Ze.useSyncExternalStore(e.subscribe,Ze.useCallback(()=>t(e.getState()),[e,t]),Ze.useCallback(()=>t(e.getInitialState()),[e,t]));return Ze.useDebugValue(n),n}const sc=e=>{const t=B0(e),n=s=>q0(t,s);return Object.assign(n,t),n},Bs=(e=>e?sc(e):sc),hd=Bs(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 Oe(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 H0(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function ht(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),a=Math.floor(s/1e3),o=Math.floor(a/60),c=Math.floor(o/60),i=Math.floor(c/24);return a<30?"just now":a<60?`${a}s ago`:o<60?`${o}m ago`:c<24?`${c}h ago`:i===1?"yesterday":i<7?`${i} days ago`:i<30?`${Math.floor(i/7)}w ago`:H0(e)}function W0({type:e}){return e==="error"?r.jsx(nl,{className:"h-4 w-4 text-red-500"}):e==="warning"?r.jsx(ys,{className:"h-4 w-4 text-amber-500"}):r.jsx(Hp,{className:"h-4 w-4 text-blue-500"})}function G0(){const{notifications:e,unreadCount:t,markAllRead:n}=hd(),s=e.slice(0,10);return r.jsxs(U0,{children:[r.jsx(V0,{asChild:!0,children:r.jsxs(se,{variant:"ghost",size:"icon","aria-label":"Notifications",className:"relative text-zinc-500 hover:text-zinc-700",children:[r.jsx(_p,{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(fd,{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(St,{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(a=>r.jsxs("div",{className:T("flex gap-3 border-b border-zinc-50 px-4 py-3 last:border-0",!a.read&&"bg-blue-50/30"),children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx(W0,{type:a.type})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-zinc-900",children:a.title}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500 line-clamp-2",children:a.message}),r.jsx("p",{className:"mt-1 text-[10px] text-zinc-400",children:ht(a.at)})]}),!a.read&&r.jsx("div",{className:"mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"})]},a.id))})]})]})}var ac=1,Q0=.9,Y0=.8,X0=.17,Na=.1,Ca=.999,Z0=.9999,J0=.99,ey=/[\\\/_+.#"@\[\(\{&]/,ty=/[\\\/_+.#"@\[\(\{&]/g,ny=/[\s-]/,md=/[\s-]/g;function ro(e,t,n,s,a,o,c){if(o===t.length)return a===e.length?ac:J0;var i=`${a},${o}`;if(c[i]!==void 0)return c[i];for(var f=s.charAt(o),u=n.indexOf(f,a),d=0,h,m,x,g;u>=0;)h=ro(e,t,n,s,u+1,o+1,c),h>d&&(u===a?h*=ac:ey.test(e.charAt(u-1))?(h*=Y0,x=e.slice(a,u-1).match(ty),x&&a>0&&(h*=Math.pow(Ca,x.length))):ny.test(e.charAt(u-1))?(h*=Q0,g=e.slice(a,u-1).match(md),g&&a>0&&(h*=Math.pow(Ca,g.length))):(h*=X0,a>0&&(h*=Math.pow(Ca,u-a))),e.charAt(u)!==t.charAt(o)&&(h*=Z0)),(h<Na&&n.charAt(u-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(u-1)!==s.charAt(o))&&(m=ro(e,t,n,s,u+1,o+2,c),m*Na>h&&(h=m*Na)),h>d&&(d=h),u=n.indexOf(f,u+1);return c[i]=d,d}function oc(e){return e.toLowerCase().replace(md," ")}function ry(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ro(e,t,oc(e),oc(t),0,0,{})}var Ks="Dialog",[pd]=ut(Ks),[sy,tt]=pd(Ks),xd=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:c=!0}=e,i=l.useRef(null),f=l.useRef(null),[u,d]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:Ks});return r.jsx(sy,{scope:t,triggerRef:i,contentRef:f,contentId:Ne(),titleId:Ne(),descriptionId:Ne(),open:u,onOpenChange:d,onOpenToggle:l.useCallback(()=>d(h=>!h),[d]),modal:c,children:n})};xd.displayName=Ks;var gd="DialogTrigger",ay=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(gd,n),o=de(t,a.triggerRef);return r.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Ko(a.open),...s,ref:o,onClick:D(e.onClick,a.onOpenToggle)})});ay.displayName=gd;var Vo="DialogPortal",[oy,vd]=pd(Vo,{forceMount:void 0}),yd=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:a}=e,o=tt(Vo,t);return r.jsx(oy,{scope:t,forceMount:n,children:l.Children.map(s,c=>r.jsx(Qe,{present:n||o.open,children:r.jsx(zr,{asChild:!0,container:a,children:c})}))})};yd.displayName=Vo;var Cs="DialogOverlay",bd=l.forwardRef((e,t)=>{const n=vd(Cs,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=tt(Cs,e.__scopeDialog);return o.modal?r.jsx(Qe,{present:s||o.open,children:r.jsx(cy,{...a,ref:t})}):null});bd.displayName=Cs;var iy=pn("DialogOverlay.RemoveScroll"),cy=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Cs,n);return r.jsx(Lr,{as:iy,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(G.div,{"data-state":Ko(a.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),gn="DialogContent",wd=l.forwardRef((e,t)=>{const n=vd(gn,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=tt(gn,e.__scopeDialog);return r.jsx(Qe,{present:s||o.open,children:o.modal?r.jsx(ly,{...a,ref:t}):r.jsx(dy,{...a,ref:t})})});wd.displayName=gn;var ly=l.forwardRef((e,t)=>{const n=tt(gn,e.__scopeDialog),s=l.useRef(null),a=de(t,n.contentRef,s);return l.useEffect(()=>{const o=s.current;if(o)return $s(o)},[]),r.jsx(jd,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:D(e.onCloseAutoFocus,o=>{var c;o.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:D(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&o.preventDefault()}),onFocusOutside:D(e.onFocusOutside,o=>o.preventDefault())})}),dy=l.forwardRef((e,t)=>{const n=tt(gn,e.__scopeDialog),s=l.useRef(!1),a=l.useRef(!1);return r.jsx(jd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,o),o.defaultPrevented||(s.current||(i=n.triggerRef.current)==null||i.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,u;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=o.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),jd=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,...c}=e,i=tt(gn,n),f=l.useRef(null),u=de(t,f);return Is(),r.jsxs(r.Fragment,{children:[r.jsx(Or,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(Ir,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Ko(i.open),...c,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(uy,{titleId:i.titleId}),r.jsx(hy,{contentRef:f,descriptionId:i.descriptionId})]})]})}),Bo="DialogTitle",Nd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Bo,n);return r.jsx(G.h2,{id:a.titleId,...s,ref:t})});Nd.displayName=Bo;var Cd="DialogDescription",Sd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Cd,n);return r.jsx(G.p,{id:a.descriptionId,...s,ref:t})});Sd.displayName=Cd;var Ed="DialogClose",Rd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Ed,n);return r.jsx(G.button,{type:"button",...s,ref:t,onClick:D(e.onClick,()=>a.onOpenChange(!1))})});Rd.displayName=Ed;function Ko(e){return e?"open":"closed"}var Pd="DialogTitleWarning",[D1,kd]=Jx(Pd,{contentName:gn,titleName:Bo,docsSlug:"dialog"}),uy=({titleId:e})=>{const t=kd(Pd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
320
+
321
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
322
+
323
+ 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},fy="DialogDescriptionWarning",hy=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${kd(fy).contentName}}.`;return l.useEffect(()=>{var o;const a=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},qo=xd,Ho=yd,qs=bd,Hs=wd,Wo=Nd,Go=Sd,Td=Rd,my=Symbol.for("react.lazy"),Ss=go[" use ".trim().toString()];function py(e){return typeof e=="object"&&e!==null&&"then"in e}function Ad(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===my&&"_payload"in e&&py(e._payload)}function xy(e){const t=gy(e),n=l.forwardRef((s,a)=>{let{children:o,...c}=s;Ad(o)&&typeof Ss=="function"&&(o=Ss(o._payload));const i=l.Children.toArray(o),f=i.find(yy);if(f){const u=f.props.children,d=i.map(h=>h===f?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:h);return r.jsx(t,{...c,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,d):null})}return r.jsx(t,{...c,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function gy(e){const t=l.forwardRef((n,s)=>{let{children:a,...o}=n;if(Ad(a)&&typeof Ss=="function"&&(a=Ss(a._payload)),l.isValidElement(a)){const c=wy(a),i=by(o,a.props);return a.type!==l.Fragment&&(i.ref=s?lt(s,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vy=Symbol("radix.slottable");function yy(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vy}function by(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...i)=>{const f=o(...i);return a(...i),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function wy(e){var s,a;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=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var jy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rt=jy.reduce((e,t)=>{const n=xy(`Primitive.${t}`),s=l.forwardRef((a,o)=>{const{asChild:c,...i}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(f,{...i,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),mr='[cmdk-group=""]',Sa='[cmdk-group-items=""]',Ny='[cmdk-group-heading=""]',Md='[cmdk-item=""]',ic=`${Md}:not([aria-disabled="true"])`,so="cmdk-item-select",Tn="data-value",Cy=(e,t,n)=>ry(e,t,n),_d=l.createContext(void 0),$r=()=>l.useContext(_d),Id=l.createContext(void 0),Qo=()=>l.useContext(Id),Od=l.createContext(void 0),Dd=l.forwardRef((e,t)=>{let n=An(()=>{var R,K;return{search:"",value:(K=(R=e.value)!=null?R:e.defaultValue)!=null?K:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=An(()=>new Set),a=An(()=>new Map),o=An(()=>new Map),c=An(()=>new Set),i=zd(e),{label:f,children:u,value:d,onValueChange:h,filter:m,shouldFilter:x,loop:g,disablePointerSelection:p=!1,vimBindings:v=!0,...y}=e,w=Ne(),N=Ne(),j=Ne(),S=l.useRef(null),C=Oy();vn(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),vn(()=>{C(6,Q)},[]);let E=l.useMemo(()=>({subscribe:R=>(c.current.add(R),()=>c.current.delete(R)),snapshot:()=>n.current,setState:(R,K,H)=>{var L,J,M,Y;if(!Object.is(n.current[R],K)){if(n.current[R]=K,R==="search")I(),O(),C(1,U);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(j);X?X.focus():(L=document.getElementById(w))==null||L.focus()}if(C(7,()=>{var X;n.current.selectedItemId=(X=V())==null?void 0:X.id,E.emit()}),H||C(5,Q),((J=i.current)==null?void 0:J.value)!==void 0){let X=K??"";(Y=(M=i.current).onValueChange)==null||Y.call(M,X);return}}E.emit()}},emit:()=>{c.current.forEach(R=>R())}}),[]),k=l.useMemo(()=>({value:(R,K,H)=>{var L;K!==((L=o.current.get(R))==null?void 0:L.value)&&(o.current.set(R,{value:K,keywords:H}),n.current.filtered.items.set(R,z(K,H)),C(2,()=>{O(),E.emit()}))},item:(R,K)=>(s.current.add(R),K&&(a.current.has(K)?a.current.get(K).add(R):a.current.set(K,new Set([R]))),C(3,()=>{I(),O(),n.current.value||U(),E.emit()}),()=>{o.current.delete(R),s.current.delete(R),n.current.filtered.items.delete(R);let H=V();C(4,()=>{I(),(H==null?void 0:H.getAttribute("id"))===R&&U(),E.emit()})}),group:R=>(a.current.has(R)||a.current.set(R,new Set),()=>{o.current.delete(R),a.current.delete(R)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:w,inputId:j,labelId:N,listInnerRef:S}),[]);function z(R,K){var H,L;let J=(L=(H=i.current)==null?void 0:H.filter)!=null?L:Cy;return R?J(R,n.current.search,K):0}function O(){if(!n.current.search||i.current.shouldFilter===!1)return;let R=n.current.filtered.items,K=[];n.current.filtered.groups.forEach(L=>{let J=a.current.get(L),M=0;J.forEach(Y=>{let X=R.get(Y);M=Math.max(X,M)}),K.push([L,M])});let H=S.current;Z().sort((L,J)=>{var M,Y;let X=L.getAttribute("id"),ie=J.getAttribute("id");return((M=R.get(ie))!=null?M:0)-((Y=R.get(X))!=null?Y:0)}).forEach(L=>{let J=L.closest(Sa);J?J.appendChild(L.parentElement===J?L:L.closest(`${Sa} > *`)):H.appendChild(L.parentElement===H?L:L.closest(`${Sa} > *`))}),K.sort((L,J)=>J[1]-L[1]).forEach(L=>{var J;let M=(J=S.current)==null?void 0:J.querySelector(`${mr}[${Tn}="${encodeURIComponent(L[0])}"]`);M==null||M.parentElement.appendChild(M)})}function U(){let R=Z().find(H=>H.getAttribute("aria-disabled")!=="true"),K=R==null?void 0:R.getAttribute(Tn);E.setState("value",K||void 0)}function I(){var R,K,H,L;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let J=0;for(let M of s.current){let Y=(K=(R=o.current.get(M))==null?void 0:R.value)!=null?K:"",X=(L=(H=o.current.get(M))==null?void 0:H.keywords)!=null?L:[],ie=z(Y,X);n.current.filtered.items.set(M,ie),ie>0&&J++}for(let[M,Y]of a.current)for(let X of Y)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(M);break}n.current.filtered.count=J}function Q(){var R,K,H;let L=V();L&&(((R=L.parentElement)==null?void 0:R.firstChild)===L&&((H=(K=L.closest(mr))==null?void 0:K.querySelector(Ny))==null||H.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function V(){var R;return(R=S.current)==null?void 0:R.querySelector(`${Md}[aria-selected="true"]`)}function Z(){var R;return Array.from(((R=S.current)==null?void 0:R.querySelectorAll(ic))||[])}function B(R){let K=Z()[R];K&&E.setState("value",K.getAttribute(Tn))}function ae(R){var K;let H=V(),L=Z(),J=L.findIndex(Y=>Y===H),M=L[J+R];(K=i.current)!=null&&K.loop&&(M=J+R<0?L[L.length-1]:J+R===L.length?L[0]:L[J+R]),M&&E.setState("value",M.getAttribute(Tn))}function F(R){let K=V(),H=K==null?void 0:K.closest(mr),L;for(;H&&!L;)H=R>0?_y(H,mr):Iy(H,mr),L=H==null?void 0:H.querySelector(ic);L?E.setState("value",L.getAttribute(Tn)):ae(R)}let A=()=>B(Z().length-1),ce=R=>{R.preventDefault(),R.metaKey?A():R.altKey?F(1):ae(1)},le=R=>{R.preventDefault(),R.metaKey?B(0):R.altKey?F(-1):ae(-1)};return l.createElement(Rt.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var K;(K=y.onKeyDown)==null||K.call(y,R);let H=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||H))switch(R.key){case"n":case"j":{v&&R.ctrlKey&&ce(R);break}case"ArrowDown":{ce(R);break}case"p":case"k":{v&&R.ctrlKey&&le(R);break}case"ArrowUp":{le(R);break}case"Home":{R.preventDefault(),B(0);break}case"End":{R.preventDefault(),A();break}case"Enter":{R.preventDefault();let L=V();if(L){let J=new Event(so);L.dispatchEvent(J)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:zy},f),Ws(e,R=>l.createElement(Id.Provider,{value:E},l.createElement(_d.Provider,{value:k},R))))}),Sy=l.forwardRef((e,t)=>{var n,s;let a=Ne(),o=l.useRef(null),c=l.useContext(Od),i=$r(),f=zd(e),u=(s=(n=f.current)==null?void 0:n.forceMount)!=null?s:c==null?void 0:c.forceMount;vn(()=>{if(!u)return i.item(a,c==null?void 0:c.id)},[u]);let d=Ld(a,o,[e.value,e.children,o],e.keywords),h=Qo(),m=Qt(C=>C.value&&C.value===d.current),x=Qt(C=>u||i.filter()===!1?!0:C.search?C.filtered.items.get(a)>0:!0);l.useEffect(()=>{let C=o.current;if(!(!C||e.disabled))return C.addEventListener(so,g),()=>C.removeEventListener(so,g)},[x,e.onSelect,e.disabled]);function g(){var C,E;p(),(E=(C=f.current).onSelect)==null||E.call(C,d.current)}function p(){h.setState("value",d.current,!0)}if(!x)return null;let{disabled:v,value:y,onSelect:w,forceMount:N,keywords:j,...S}=e;return l.createElement(Rt.div,{ref:lt(o,t),...S,id:a,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!m,"data-disabled":!!v,"data-selected":!!m,onPointerMove:v||i.getDisablePointerSelection()?void 0:p,onClick:v?void 0:g},e.children)}),Ey=l.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,c=Ne(),i=l.useRef(null),f=l.useRef(null),u=Ne(),d=$r(),h=Qt(x=>a||d.filter()===!1?!0:x.search?x.filtered.groups.has(c):!0);vn(()=>d.group(c),[]),Ld(c,i,[e.value,e.heading,f]);let m=l.useMemo(()=>({id:c,forceMount:a}),[a]);return l.createElement(Rt.div,{ref:lt(i,t),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Ws(e,x=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},l.createElement(Od.Provider,{value:m},x))))}),Ry=l.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=l.useRef(null),o=Qt(c=>!c.search);return!n&&!o?null:l.createElement(Rt.div,{ref:lt(a,t),...s,"cmdk-separator":"",role:"separator"})}),Py=l.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=Qo(),c=Qt(u=>u.search),i=Qt(u=>u.selectedItemId),f=$r();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(Rt.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":i,id:f.inputId,type:"text",value:a?e.value:c,onChange:u=>{a||o.setState("search",u.target.value),n==null||n(u.target.value)}})}),ky=l.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=l.useRef(null),c=l.useRef(null),i=Qt(u=>u.selectedItemId),f=$r();return l.useEffect(()=>{if(c.current&&o.current){let u=c.current,d=o.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let x=u.offsetHeight;d.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(h),m.unobserve(u)}}},[]),l.createElement(Rt.div,{ref:lt(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":s,id:f.listId},Ws(e,u=>l.createElement("div",{ref:lt(c,f.listInnerRef),"cmdk-list-sizer":""},u)))}),Ty=l.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:c,...i}=e;return l.createElement(qo,{open:n,onOpenChange:s},l.createElement(Ho,{container:c},l.createElement(qs,{"cmdk-overlay":"",className:a}),l.createElement(Hs,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(Dd,{ref:t,...i}))))}),Ay=l.forwardRef((e,t)=>Qt(n=>n.filtered.count===0)?l.createElement(Rt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),My=l.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return l.createElement(Rt.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Ws(e,c=>l.createElement("div",{"aria-hidden":!0},c)))}),De=Object.assign(Dd,{List:ky,Item:Sy,Input:Py,Group:Ey,Separator:Ry,Dialog:Ty,Empty:Ay,Loading:My});function _y(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Iy(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function zd(e){let t=l.useRef(e);return vn(()=>{t.current=e}),t}var vn=typeof window>"u"?l.useEffect:l.useLayoutEffect;function An(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Qt(e){let t=Qo(),n=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,n,n)}function Ld(e,t,n,s=[]){let a=l.useRef(),o=$r();return vn(()=>{var c;let i=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():a.current}})(),f=s.map(u=>u.trim());o.value(e,i,f),(c=t.current)==null||c.setAttribute(Tn,i),a.current=i}),a}var Oy=()=>{let[e,t]=l.useState(),n=An(()=>new Map);return vn(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function Dy(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ws({asChild:e,children:t},n){return e&&l.isValidElement(t)?l.cloneElement(Dy(t),{ref:t.ref},n(t.props.children)):n(t)}var zy={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Gs=qo,Ly=Ho,Fd=l.forwardRef(({className:e,...t},n)=>r.jsx(qs,{ref:n,className:T("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}));Fd.displayName=qs.displayName;const Ur=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ly,{children:[r.jsx(Fd,{}),r.jsxs(Hs,{ref:s,className:T("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(Td,{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(Yt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ur.displayName=Hs.displayName;const Qs=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col space-y-1.5 text-left",e),...t});Qs.displayName="DialogHeader";const Ys=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ys.displayName="DialogFooter";const Vr=l.forwardRef(({className:e,...t},n)=>r.jsx(Wo,{ref:n,className:T("text-lg font-semibold leading-none tracking-tight",e),...t}));Vr.displayName=Wo.displayName;const Fy=l.forwardRef(({className:e,...t},n)=>r.jsx(Go,{ref:n,className:T("text-sm text-zinc-500",e),...t}));Fy.displayName=Go.displayName;const $d=l.forwardRef(({className:e,...t},n)=>r.jsx(De,{ref:n,className:T("flex h-full w-full flex-col overflow-hidden rounded-md bg-white text-zinc-900",e),...t}));$d.displayName=De.displayName;const Ud=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(tr,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(De.Input,{ref:n,className:T("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})]}));Ud.displayName=De.Input.displayName;const Vd=l.forwardRef(({className:e,...t},n)=>r.jsx(De.List,{ref:n,className:T("max-h-[400px] overflow-y-auto overflow-x-hidden",e),...t}));Vd.displayName=De.List.displayName;const Bd=l.forwardRef((e,t)=>r.jsx(De.Empty,{ref:t,className:"py-6 text-center text-sm text-zinc-500",...e}));Bd.displayName=De.Empty.displayName;const fs=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Group,{ref:n,className:T("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}));fs.displayName=De.Group.displayName;const ao=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Separator,{ref:n,className:T("-mx-1 h-px bg-zinc-100",e),...t}));ao.displayName=De.Separator.displayName;const hs=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Item,{ref:n,className:T("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}));hs.displayName=De.Item.displayName;function Yo(e){const t=e+"CollectionProvider",[n,s]=ut(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=p=>{const{scope:v,children:y}=p,w=Ze.useRef(null),N=Ze.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:N,collectionRef:w,children:y})};c.displayName=t;const i=e+"CollectionSlot",f=pn(i),u=Ze.forwardRef((p,v)=>{const{scope:y,children:w}=p,N=o(i,y),j=de(v,N.collectionRef);return r.jsx(f,{ref:j,children:w})});u.displayName=i;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=pn(d),x=Ze.forwardRef((p,v)=>{const{scope:y,children:w,...N}=p,j=Ze.useRef(null),S=de(v,j),C=o(d,y);return Ze.useEffect(()=>(C.itemMap.set(j,{ref:j,...N}),()=>void C.itemMap.delete(j))),r.jsx(m,{[h]:"",ref:S,children:w})});x.displayName=d;function g(p){const v=o(e+"CollectionConsumer",p);return Ze.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const N=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((C,E)=>N.indexOf(C.ref.current)-N.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:u,ItemSlot:x},g,s]}var $y=l.createContext(void 0);function Xs(e){const t=l.useContext($y);return e||t||"ltr"}var Ea="rovingFocusGroup.onEntryFocus",Uy={bubbles:!1,cancelable:!0},Br="RovingFocusGroup",[oo,Kd,Vy]=Yo(Br),[By,Zs]=ut(Br,[Vy]),[Ky,qy]=By(Br),qd=l.forwardRef((e,t)=>r.jsx(oo.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(oo.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Hy,{...e,ref:t})})}));qd.displayName=Br;var Hy=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:o,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:f,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=e,m=l.useRef(null),x=de(t,m),g=Xs(o),[p,v]=Gt({prop:c,defaultProp:i??null,onChange:f,caller:Br}),[y,w]=l.useState(!1),N=dt(u),j=Kd(n),S=l.useRef(!1),[C,E]=l.useState(0);return l.useEffect(()=>{const k=m.current;if(k)return k.addEventListener(Ea,N),()=>k.removeEventListener(Ea,N)},[N]),r.jsx(Ky,{scope:n,orientation:s,dir:g,loop:a,currentTabStopId:p,onItemFocus:l.useCallback(k=>v(k),[v]),onItemShiftTab:l.useCallback(()=>w(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(k=>k+1),[]),onFocusableItemRemove:l.useCallback(()=>E(k=>k-1),[]),children:r.jsx(G.div,{tabIndex:y||C===0?-1:0,"data-orientation":s,...h,ref:x,style:{outline:"none",...e.style},onMouseDown:D(e.onMouseDown,()=>{S.current=!0}),onFocus:D(e.onFocus,k=>{const z=!S.current;if(k.target===k.currentTarget&&z&&!y){const O=new CustomEvent(Ea,Uy);if(k.currentTarget.dispatchEvent(O),!O.defaultPrevented){const U=j().filter(B=>B.focusable),I=U.find(B=>B.active),Q=U.find(B=>B.id===p),Z=[I,Q,...U].filter(Boolean).map(B=>B.ref.current);Gd(Z,d)}}S.current=!1}),onBlur:D(e.onBlur,()=>w(!1))})})}),Hd="RovingFocusGroupItem",Wd=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:o,children:c,...i}=e,f=Ne(),u=o||f,d=qy(Hd,n),h=d.currentTabStopId===u,m=Kd(n),{onFocusableItemAdd:x,onFocusableItemRemove:g,currentTabStopId:p}=d;return l.useEffect(()=>{if(s)return x(),()=>g()},[s,x,g]),r.jsx(oo.ItemSlot,{scope:n,id:u,focusable:s,active:a,children:r.jsx(G.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...i,ref:t,onMouseDown:D(e.onMouseDown,v=>{s?d.onItemFocus(u):v.preventDefault()}),onFocus:D(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:D(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=Qy(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.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(v.currentTarget);N=d.loop?Yy(N,j+1):N.slice(j+1)}setTimeout(()=>Gd(N))}}),children:typeof c=="function"?c({isCurrentTabStop:h,hasTabStop:p!=null}):c})})});Wd.displayName=Hd;var Wy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Gy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Qy(e,t,n){const s=Gy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Wy[s]}function Gd(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Yy(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Qd=qd,Yd=Wd,Js="Tabs",[Xy]=ut(Js,[Zs]),Xd=Zs(),[Zy,Xo]=Xy(Js),Zd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:o,orientation:c="horizontal",dir:i,activationMode:f="automatic",...u}=e,d=Xs(i),[h,m]=Gt({prop:s,onChange:a,defaultProp:o??"",caller:Js});return r.jsx(Zy,{scope:n,baseId:Ne(),value:h,onValueChange:m,orientation:c,dir:d,activationMode:f,children:r.jsx(G.div,{dir:d,"data-orientation":c,...u,ref:t})})});Zd.displayName=Js;var Jd="TabsList",eu=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,o=Xo(Jd,n),c=Xd(n);return r.jsx(Qd,{asChild:!0,...c,orientation:o.orientation,dir:o.dir,loop:s,children:r.jsx(G.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});eu.displayName=Jd;var tu="TabsTrigger",nu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...o}=e,c=Xo(tu,n),i=Xd(n),f=au(c.baseId,s),u=ou(c.baseId,s),d=s===c.value;return r.jsx(Yd,{asChild:!0,...i,focusable:!a,active:d,children:r.jsx(G.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:f,...o,ref:t,onMouseDown:D(e.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?c.onValueChange(s):h.preventDefault()}),onKeyDown:D(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&c.onValueChange(s)}),onFocus:D(e.onFocus,()=>{const h=c.activationMode!=="manual";!d&&!a&&h&&c.onValueChange(s)})})})});nu.displayName=tu;var ru="TabsContent",su=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:o,...c}=e,i=Xo(ru,n),f=au(i.baseId,s),u=ou(i.baseId,s),d=s===i.value,h=l.useRef(d);return l.useEffect(()=>{const m=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(Qe,{present:a||d,children:({present:m})=>r.jsx(G.div,{"data-state":d?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":f,hidden:!m,id:u,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:m&&o})})});su.displayName=ru;function au(e,t){return`${e}-trigger-${t}`}function ou(e,t){return`${e}-content-${t}`}var Jy=Zd,iu=eu,cu=nu,lu=su;const Kr=Jy,or=l.forwardRef(({className:e,...t},n)=>r.jsx(iu,{ref:n,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-zinc-100 p-1 text-zinc-500",e),...t}));or.displayName=iu.displayName;const Ae=l.forwardRef(({className:e,...t},n)=>r.jsx(cu,{ref:n,className:T("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}));Ae.displayName=cu.displayName;const Ue=l.forwardRef(({className:e,...t},n)=>r.jsx(lu,{ref:n,className:T("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}));Ue.displayName=lu.displayName;const eb=/^\/[A-Za-z0-9/_.-]*$/,as=8e3;function tb(e,t){var a;const n=[];for(const o of e)if(n.push({role:"user",content:o.question.slice(0,as)}),o.answer.trim()!==""){const c=o.revealed.filter(i=>i.end<=as);n.push({role:"assistant",content:o.answer.slice(0,as),...c.length>0&&{revealed:c}})}n.push({role:"user",content:t.slice(0,as)});const s=n.slice(-40);for(;((a=s[0])==null?void 0:a.role)!=="user";)s.shift();return s}const nb=(e,t)=>e.kind==="order"?t.kind==="order"&&e.orderNumber===t.orderNumber:t.kind==="customer"&&e.id===t.id;function pr(e){try{return JSON.parse(e.data)}catch{return}}let kn=null,rb=1;const Zo=Bs((e,t)=>{const n=(o,c)=>e(i=>({exchanges:i.exchanges.map(f=>f.id===o?{...f,...c(f)}:f)})),s=(o,c)=>{kn==null||kn.close(),kn=null,n(o,()=>c),e({busy:!1})},a=(o,c)=>{const i=new EventSource(`/api/admin/assistant/turns/${encodeURIComponent(c.turnId)}/stream?ticket=${encodeURIComponent(c.ticket)}`);kn=i;const f=()=>kn===i;i.addEventListener("text",u=>{const d=pr(u);f()&&d!==void 0&&n(o,h=>({answer:h.answer+d.delta,revealed:[...h.revealed,...(d.revealed??[]).map(m=>({...m,start:m.start+h.answer.length,end:m.end+h.answer.length}))]}))}),i.addEventListener("tool",u=>{const d=pr(u);f()&&d!==void 0&&n(o,h=>({steps:[...h.steps,d]}))}),i.addEventListener("proposal",u=>{const d=pr(u);f()&&d!==void 0&&n(o,h=>({proposals:[...h.proposals,d]}))}),i.addEventListener("record",u=>{const d=pr(u);f()&&d!==void 0&&n(o,h=>h.records.some(m=>nb(m,d))?{}:{records:[...h.records,d]})}),i.addEventListener("done",()=>{f()&&s(o,{state:"done"})}),i.addEventListener("error",u=>{if(!f())return;const d="data"in u?pr(u):void 0;s(o,{state:"error",error:d??{code:"assistant.disconnected",message:"The answer was cut off"}})})};return{exchanges:[],busy:!1,ask(o,c){const i=o.trim();if(i===""||t().busy)return;const f=rb++,u=tb(t().exchanges.filter(h=>!h.unavailable),i);e(h=>({busy:!0,exchanges:[...h.exchanges,{id:f,question:i,answer:"",revealed:[],state:"streaming",steps:[],proposals:[],records:[]}]}));const d=c.slice(0,200);W.post("/api/admin/assistant/turns",{messages:u,...eb.test(d)&&{page:d}}).then(h=>{var m;((m=t().exchanges.find(x=>x.id===f))==null?void 0:m.state)==="streaming"&&a(f,h)}).catch(h=>{const m=h instanceof Re?h.code:"assistant.failed";s(f,{state:"error",...m==="assistant.unavailable"&&{unavailable:!0},error:{code:m,message:h instanceof Re?h.message:"The question could not be sent"}})})},stop(){const o=t().exchanges.find(c=>c.state==="streaming");o!==void 0&&s(o.id,{state:"stopped"})},updateProposal(o){e(c=>({exchanges:c.exchanges.map(i=>({...i,proposals:i.proposals.map(f=>f.id===o.id?o:f)}))}))}}}),qr=Bs(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(t=>({isOpen:!t.isOpen}))}));function ue(e,t){return new Intl.NumberFormat("en-GB",{style:"currency",currency:t,minimumFractionDigits:2}).format(e/100)}function sb(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 ab(e,t){const n=e/100,s=ob(t);return n>=1e6?`${s}${(n/1e6).toFixed(1)}M`:n>=1e3?`${s}${(n/1e3).toFixed(1)}k`:ue(e,t)}function ob(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}}const cc=120;function lc(e,t,n){if(e===null)return"none";if(t==="money"&&typeof e=="number")return ue(e,n);const s=String(e);return s.length>cc?`${s.slice(0,cc)}…`:s}function ib(e,t){const{label:n,kind:s,current:a,proposed:o}=e;return s==="collection"?`${n}: ${a??0} → ${o??0} items${e.changed===!0?", changed":""}`:`${n}: ${lc(a,s,t)} → ${lc(o,s,t)}`}const cb=e=>String(e.args[e.command==="inventory.adjust"?"variantId":"id"]??"");function du({proposal:e,scope:t}){const n=e.status==="pending"&&gp.includes(e.command),{data:s}=hx(e.id,n),a=n?s==null?void 0:s.preview:void 0;if(a===void 0)return null;const{target:o,changes:c,currency:i}=a;return r.jsxs("div",{className:"space-y-1 text-xs",children:[r.jsx("p",{className:"font-medium break-words text-zinc-900","data-testid":P(t,"target",e.id),children:o===null?`Not found: ${cb(e)}`:o.label}),c.length>0&&r.jsx("ul",{className:"space-y-0.5 break-words text-zinc-700",children:c.map((f,u)=>r.jsx("li",{"data-testid":P(t,"change",e.id),children:ib(f,i)},u))})]})}const dc={pending:{label:"Pending approval",style:"bg-amber-50 text-amber-700"},approved:{label:"Approved",style:"bg-blue-50 text-blue-700"},applied:{label:"Applied",style:"bg-green-50 text-green-700"},rejected:{label:"Rejected",style:"bg-zinc-100 text-zinc-600"},failed:{label:"Failed",style:"bg-red-50 text-red-700"}};function lb({proposal:e}){const t=fl(),n=hl(),s=Zo(m=>m.updateProposal),a=l.useRef(!1),[o,c]=l.useState(!1),[i,f]=l.useState(null),{id:u,status:d}=e,h=async m=>{if(!a.current){a.current=!0,c(!0),f(null);try{s(await m())}catch(x){f(x instanceof Re?x.message:"The proposal could not be decided.")}finally{a.current=!1,c(!1)}}};return r.jsxs("article",{className:"space-y-2 rounded-md border border-zinc-200 bg-white p-3","data-testid":P("assistant","proposal",u),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsx("p",{className:"font-mono text-xs font-semibold break-all text-zinc-900",children:e.command}),r.jsx("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",dc[d].style),"data-testid":P("assistant","proposal","status",u),children:dc[d].label})]}),r.jsx(du,{proposal:e,scope:"assistant"}),r.jsx("pre",{className:"max-h-32 overflow-auto rounded bg-zinc-50 p-2 font-mono text-[11px] whitespace-pre-wrap break-all text-zinc-700",children:JSON.stringify(e.args,null,1)}),d==="pending"&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(se,{size:"sm",className:"gap-1.5",disabled:o,onClick:()=>void h(()=>t.mutateAsync(u)),"data-testid":P("assistant","approve",u),children:[o?r.jsx(_r,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(St,{className:"h-3.5 w-3.5"}),"Approve"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"gap-1.5",disabled:o,onClick:()=>void h(()=>n.mutateAsync({id:u,reason:""})),"data-testid":P("assistant","reject",u),children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Reject"]}),i!==null&&r.jsx("p",{className:"text-xs text-red-600",children:i})]})]})}function db(e={}){return Ce({queryKey:["customers","list",e],queryFn:async()=>(await W.get("/api/admin/customers",e)).customers})}function uu(e){return Ce({queryKey:["customers","detail",e],queryFn:()=>W.get(`/api/admin/customers/${e}`),enabled:!!e})}function ub(e){return Ce({queryKey:["customers","orders",e],queryFn:()=>W.get(`/api/admin/customers/${e}/orders`),enabled:!!e})}function fb(){const e=ye();return we({mutationFn:({customerId:t,body:n})=>W.post(`/api/admin/customers/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["customers","detail",n.customerId]})}})}const fu=e=>e instanceof Re&&e.status===404;function Es({testId:e,children:t}){return r.jsx("article",{className:"space-y-1 rounded-md border border-zinc-200 bg-white p-3 text-sm [overflow-wrap:anywhere] text-zinc-700","data-testid":e,children:t})}function hu({loading:e,notFound:t}){return r.jsx("p",{className:"text-xs text-zinc-500",children:e?"Loading…":t})}function hb({orderNumber:e}){const t=qr(i=>i.close),{data:n,isLoading:s,error:a}=dl(e),o=P("assistant","record","order",e);if(n===void 0){const i=fu(a)?`Order ${e} was not found`:"This record could not be loaded";return r.jsx(Es,{testId:o,children:r.jsx(hu,{loading:s,notFound:i})})}const c=n.shippingAddress;return r.jsxs(Es,{testId:o,children:[r.jsxs("p",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[r.jsx(Ve,{to:`/orders/${encodeURIComponent(n.orderNumber)}`,className:"font-mono text-xs font-semibold text-blue-600 hover:underline",onClick:t,children:n.orderNumber}),r.jsx("span",{className:"text-xs text-zinc-500",children:n.status}),r.jsx("span",{className:"font-mono text-xs",children:ue(n.totalMinor,n.currency)})]}),r.jsx("p",{className:"font-medium text-zinc-900",children:[c.firstName,c.lastName].filter(Boolean).join(" ")}),r.jsx("p",{children:n.email}),c.phone&&r.jsx("p",{children:c.phone}),r.jsx("p",{children:[c.addressLine1,c.addressLine2,c.city,c.postalCode,c.country].filter(Boolean).join(", ")})]})}function mb({id:e}){const t=qr(u=>u.close),{data:n,isLoading:s,error:a}=uu(e),o=P("assistant","record","customer",e);if(n===void 0){const u=fu(a)?"This customer was not found":"This record could not be loaded";return r.jsx(Es,{testId:o,children:r.jsx(hu,{loading:s,notFound:u})})}const{customer:c,stats:i}=n,f=[c.firstName,c.lastName].filter(Boolean).join(" ")||c.email;return r.jsxs(Es,{testId:o,children:[r.jsx(Ve,{to:`/customers/${encodeURIComponent(c.id)}`,className:"font-medium text-blue-600 hover:underline",onClick:t,children:f}),r.jsx("p",{children:c.email}),c.phone&&r.jsx("p",{children:c.phone}),r.jsxs("p",{className:"text-xs text-zinc-500",children:[i.orderCount," ",i.orderCount===1?"order":"orders",","," ",ue(i.lifetimeRevenueMinor,"GBP")," lifetime"]})]})}function pb({record:e}){return e.kind==="order"?r.jsx(hb,{orderNumber:e.orderNumber}):r.jsx(mb,{id:e.id})}function xb({exchange:e}){const t=qr(a=>a.close),{state:n,error:s}=e;return r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"ml-auto w-fit max-w-[85%] rounded-lg bg-blue-600 px-3 py-2 text-sm whitespace-pre-wrap text-white","data-testid":P("assistant","message"),"data-role":"user",children:e.question}),r.jsxs("div",{className:"space-y-2","data-testid":P("assistant","message"),"data-role":"assistant",children:[e.steps.map((a,o)=>r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-zinc-500","data-testid":P("assistant","step"),"data-tool":a.name,"data-ok":String(a.ok),children:[a.ok?r.jsx(St,{className:"h-3 w-3 text-green-600"}):r.jsx(Yt,{className:"h-3 w-3 text-red-500"}),r.jsx("span",{className:"font-mono",children:a.title}),a.code!==void 0&&r.jsx("span",{className:"text-red-500",children:a.code})]},o)),e.records.map(a=>r.jsx(pb,{record:a},a.kind==="order"?`order:${a.orderNumber}`:`customer:${a.id}`)),e.proposals.map(a=>r.jsx(lb,{proposal:a},a.id)),e.unavailable===!0?r.jsxs("p",{className:"rounded-md bg-amber-50 p-3 text-sm text-amber-800","data-testid":P("assistant","unavailable"),children:["The assistant needs an AI provider that can call tools."," ",r.jsx(Ve,{to:"/settings",className:"font-medium underline",onClick:t,children:"Set one up in Settings"}),"."]}):r.jsxs("p",{className:"text-sm whitespace-pre-wrap text-zinc-800","data-testid":P("assistant","answer"),"data-state":n,children:[e.answer,n==="stopped"&&r.jsx("span",{className:"ml-1 text-xs text-zinc-400 italic",children:"(Stopped)"})]}),n==="streaming"&&e.answer===""&&r.jsx("p",{className:"text-xs text-zinc-400",children:"Thinking…"}),s!==void 0&&e.unavailable!==!0&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-red-600","data-testid":P("assistant","error"),"data-code":s.code,children:[r.jsx(nl,{className:"h-3.5 w-3.5"}),s.message]})]})]})}function gb({draft:e,onDraftChange:t}){const{exchanges:n,busy:s,ask:a}=Zo(),{pathname:o}=vh(),c=l.useRef(null),i=l.useRef(null),f=n.at(-1);l.useEffect(()=>{var d;(d=i.current)==null||d.scrollIntoView({block:"end"})},[n.length,f==null?void 0:f.answer,f==null?void 0:f.steps.length,f==null?void 0:f.proposals.length,f==null?void 0:f.records.length]),l.useEffect(()=>{var d;s||(d=c.current)==null||d.focus()},[s]);const u=d=>{d.key!=="Enter"||d.nativeEvent.isComposing||(d.preventDefault(),!(s||e.trim()==="")&&(a(e,o),t("")))};return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"max-h-[400px] min-h-24 space-y-4 overflow-y-auto px-4 py-3",children:[n.length===0&&r.jsxs("p",{className:"flex items-center gap-2 py-6 text-sm text-zinc-500",children:[r.jsx(Qa,{className:"h-4 w-4"}),"Ask about your store: orders, products, stock. A change it suggests waits for your approval."]}),n.map(d=>r.jsx(xb,{exchange:d},d.id)),r.jsx("div",{ref:i})]}),r.jsxs("div",{className:"flex items-center border-t border-zinc-200 px-3",children:[r.jsx(Qa,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx("input",{ref:c,className:"flex h-12 w-full bg-transparent py-3 text-sm outline-none placeholder:text-zinc-400 disabled:cursor-not-allowed disabled:opacity-50",placeholder:s?"Answering…":"Ask about your store, then press Enter",value:e,maxLength:8e3,disabled:s,onChange:d=>t(d.target.value),onKeyDown:u,"data-testid":P("assistant","input")})]})]})}function vb(e){return Ce({queryKey:["search",e],queryFn:()=>W.get("/api/admin/search",{q:e}),enabled:e.length>=2,staleTime:1e4})}function yb(e,t){const[n,s]=l.useState(e);return l.useEffect(()=>{const a=setTimeout(()=>s(e),t);return()=>clearTimeout(a)},[e,t]),n}function bb(){const{isOpen:e,close:t}=qr(),n=Zo(g=>g.stop),s=Ct(),[a,o]=l.useState("search"),[c,i]=l.useState(""),[f,u]=l.useState(""),d=yb(c,300);l.useEffect(()=>{e||(n(),o("search"))},[e,n]);const h=g=>{if(!g.startsWith("?"))return i(g);i(""),u(g.slice(1)),o("ask")},{data:m}=vb(d),x=l.useCallback(g=>{t(),g()},[t]);return r.jsx(Gs,{open:e,onOpenChange:g=>!g&&t(),children:r.jsxs(Ur,{className:"max-w-2xl gap-0 overflow-hidden p-0 shadow-2xl","aria-describedby":void 0,children:[r.jsx(Vr,{className:"sr-only",children:"Search or ask"}),r.jsxs(Kr,{value:a,onValueChange:g=>o(g),children:[r.jsxs(or,{className:"mx-3 mt-3",children:[r.jsx(Ae,{value:"search","data-testid":P("search","tab","search"),children:"Search"}),r.jsx(Ae,{value:"ask","data-testid":P("search","tab","ask"),children:"Ask"})]}),r.jsx(Ue,{value:"search",className:"mt-0",children:r.jsxs($d,{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:[r.jsx(Ud,{placeholder:"Search orders, products, customers... (? to ask)",value:c,onValueChange:h,"data-testid":P("search","input")}),r.jsxs(Vd,{"data-testid":P("search"),children:[r.jsx(Bd,{children:d.length<2?r.jsx("span",{className:"text-zinc-400",children:"Type at least 2 characters to search"}):r.jsxs("span",{children:['No results for "',d,'"']})}),(m==null?void 0:m.orders)&&m.orders.length>0&&r.jsx(fs,{heading:"Orders",children:m.orders.slice(0,5).map(g=>r.jsxs(hs,{value:`order-${g.orderNumber}`,onSelect:()=>x(()=>s(`/orders/${g.orderNumber}`)),children:[r.jsx(Gn,{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:["#",g.orderNumber]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:g.email})]})]},g.id))}),(m==null?void 0:m.products)&&m.products.length>0&&r.jsxs(r.Fragment,{children:[m.orders&&m.orders.length>0&&r.jsx(ao,{}),r.jsx(fs,{heading:"Products",children:m.products.slice(0,5).map(g=>r.jsxs(hs,{value:`product-${g.id}`,onSelect:()=>x(()=>s(`/products/${g.slug}`)),children:[r.jsx(qt,{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:g.name}),r.jsx("span",{className:"text-xs text-zinc-500 capitalize",children:g.status})]})]},g.id))})]}),(m==null?void 0:m.customers)&&m.customers.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(ao,{}),r.jsx(fs,{heading:"Customers",children:m.customers.slice(0,5).map(g=>r.jsxs(hs,{value:`customer-${g.id}`,onSelect:()=>x(()=>s(`/customers/${g.id}`)),children:[r.jsx(Ro,{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:[g.firstName," ",g.lastName]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:g.email})]})]},g.id))})]})]})]})}),r.jsx(Ue,{value:"ask",className:"mt-0",children:r.jsx(gb,{draft:f,onDraftChange:u})})]})]})})}function wb(){const{open:e}=qr();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":P("search","trigger"),children:[r.jsx(tr,{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 Jo=["orders","list"],nn=e=>e===void 0;function mu(e,t){return nn(e.status)||e.status===t.status}function jb(e,t){return mu(e,t)&&nn(e.q)&&nn(e.dateFrom)&&nn(e.dateTo)&&nn(e.customer)&&(nn(e.offset)||e.offset===0)&&(nn(e.sort)||e.sort==="createdAt:desc")}function Nb(e,t){for(const n of e.getQueryCache().findAll({queryKey:Jo})){const s=n.queryKey[2]??{};if(!mu(s,t))continue;const a={queryKey:n.queryKey,exact:!0},o=n.state.fetchStatus==="fetching"?e.cancelQueries(a):void 0,c=e.getQueryData(n.queryKey),i=c!==void 0&&jb(s,t);if(i){const f=[t,...c.filter(u=>u.id!==t.id)];e.setQueryData(n.queryKey,f.slice(0,s.limit??f.length))}o?o.then(()=>e.invalidateQueries(a)):i||e.invalidateQueries(a)}}const Cb=[Jo,["orders","detail"],["dashboard"],["inventory","list"],["proposals"]];async function Sb(e){await Promise.all(Cb.map(async t=>{await e.cancelQueries({queryKey:t}),e.invalidateQueries({queryKey:t})}))}function Eb(e){const t=hd.getState().pushNotification;function n(s){switch(s.type){case"order.placed.v1":{const{order:a}=s.payload;Nb(e,a),e.invalidateQueries({queryKey:["dashboard"]}),t({type:"info",title:"New Order",message:`Order #${a.orderNumber} placed by ${a.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:Jo}),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:a,currentQty:o,threshold:c}=s.payload;t({type:"warning",title:"Low Stock Alert",message:`Variant ${a} is running low: ${o} left (threshold ${c})`}),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:a,reason:o}=s.payload;t({type:"error",title:"Payment Failed",message:`Payment failed for order ${a}: ${o}`});break}case"proposal.created.v1":{e.invalidateQueries({queryKey:["proposals"]}),t({type:"info",title:"Inbox",message:`Agent proposal: ${s.payload.command}`});break}case"proposal.approved.v1":case"proposal.rejected.v1":case"proposal.applied.v1":case"proposal.failed.v1":{e.invalidateQueries({queryKey:["proposals"]});break}case"adapter.error.v1":{const{adapterType:a,adapterName:o,error:c}=s.payload;t({type:"error",title:"Adapter Error",message:`${a} adapter ${o}: ${c.message}`});break}}}return function(a,o){n({type:a,payload:o})}}const Nr=Bs(e=>({events:[],connected:!1,setConnected:t=>e({connected:t}),pushEvent:(t,n)=>{const s={id:crypto.randomUUID(),type:t,label:n,at:new Date().toISOString()};e(a=>({events:[s,...a.events].slice(0,20)}))}}));function Rb(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 uc(){const e=Nr(t=>t.connected);return r.jsxs("span",{className:"flex items-center gap-1.5 shrink-0","data-testid":P("topbar","live"),"data-state":e?"live":"offline",children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[e&&r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:T("relative inline-flex h-2 w-2 rounded-full",e?"bg-green-500":"bg-zinc-300")})]}),r.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400",children:e?"Live":"Offline"})]})}function Pb(){const e=Nr(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.jsx(uc,{}),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.jsx(uc,{}),r.jsx("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:n.map(s=>r.jsx("span",{className:T("flex shrink-0 items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium whitespace-nowrap",Rb(s.type)),children:s.label},s.id))})]})}function kb({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":P("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(Yp,{className:"h-5 w-5"})}),r.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:r.jsx(Xx,{})}),r.jsx("div",{className:"mx-8 hidden flex-1 items-center justify-center overflow-hidden md:flex",children:r.jsx(Pb,{})}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(wb,{}),r.jsx(G0,{})]})]}),r.jsx(bb,{})]})}const fc=[1e3,2e3,5e3,1e4,3e4];function Tb(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"payload"in t)return t.payload}catch{}}function Ab(e,t={}){let n=null,s=0,a=null,o=!1;async function c(){return(await W.post("/api/admin/events/ticket")).ticket}function i(){if(o)return;const u=fc[Math.min(s,fc.length-1)]??3e4;s++,a=setTimeout(()=>{f()},u)}async function f(){var u;if(!o)try{const d=await c();if(o)return;n=new EventSource(`/api/admin/events?ticket=${encodeURIComponent(d)}`),n.onopen=()=>{s=0},n.addEventListener("connected",()=>{var h;(h=t.onConnected)==null||h.call(t)});for(const h of pp)n.addEventListener(h,m=>{const x=Tb(m.data);x!==void 0&&e(h,x)});n.onerror=()=>{var h;n==null||n.close(),n=null,!o&&((h=t.onDisconnected)==null||h.call(t),i())}}catch{if(o)return;(u=t.onDisconnected)==null||u.call(t),i()}}return{connect(){o=!1,f()},disconnect(){o=!0,a!==null&&(clearTimeout(a),a=null),n==null||n.close(),n=null}}}function Mb(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"order.confirmation_resend_requested.v1":return"Confirmation resend queued";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 _b({children:e}){const t=ye(),n=l.useRef(null),s=Nr(o=>o.pushEvent),a=Nr(o=>o.setConnected);return l.useEffect(()=>{if(!vs())return;const o=Eb(t),c=Ab((i,f)=>{o(i,f),s(i,Mb({type:i,payload:f}))},{onConnected:()=>{a(!0),Sb(t)},onDisconnected:()=>a(!1)});return n.current=c,c.connect(),()=>{c.disconnect(),n.current=null,a(!1)}},[t,s,a]),r.jsx(r.Fragment,{children:e})}function Ib(){const[e,t]=l.useState(!1);return r.jsx(_b,{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(Yx,{open:e,onClose:()=>t(!1)}),r.jsx(kb,{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(yh,{})})})]})})}const pe=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:T("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}));pe.displayName="Input";var Ob="Label",pu=l.forwardRef((e,t)=>r.jsx(Rt.label,{...e,ref:t,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));pu.displayName=Ob;var xu=pu;const Db=_s("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ee=l.forwardRef(({className:e,...t},n)=>r.jsx(xu,{ref:n,className:T(Db(),e),...t}));Ee.displayName=xu.displayName;function zb({size:e="md",className:t}){return r.jsx("div",{className:T("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 Lb(){const{login:e}=cl(),[t,n]=l.useState(""),[s,a]=l.useState(""),[o,c]=l.useState(null),[i,f]=l.useState(!1),u=async d=>{d.preventDefault(),c(null),f(!0);try{await e(t,s)}catch(h){c(h instanceof Error?h.message:"Login failed")}finally{f(!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:d=>void u(d),"data-testid":P("login","form"),className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-zinc-300 text-xs",children:"Email"}),r.jsx(pe,{type:"email",value:t,onChange:d=>n(d.target.value),placeholder:"admin@yourstore.com",autoComplete:"email",required:!0,disabled:i,"data-testid":P("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(Ee,{className:"text-zinc-300 text-xs",children:"Password"}),r.jsx(pe,{type:"password",value:s,onChange:d=>a(d.target.value),placeholder:"••••••••",autoComplete:"current-password",required:!0,disabled:i,"data-testid":P("login","password"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),o&&r.jsx("div",{role:"alert","data-testid":P("login","error"),className:"rounded-md border border-red-800/50 bg-red-900/20 px-3 py-2 text-sm text-red-400",children:o}),r.jsx(se,{type:"submit",className:"w-full",disabled:i||!t||!s,"data-testid":P("login","submit"),children:i?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(zb,{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 xe({className:e,...t}){return r.jsx("div",{className:T("animate-pulse rounded-md bg-zinc-200",e),...t})}const Fb={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"},$b={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Part. Refunded"};function Xn({status:e,size:t="md",className:n,"data-testid":s}){return r.jsx("span",{"data-testid":s,className:T("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",Fb[e],n),children:$b[e]})}function Ge({icon:e,title:t,description:n,action:s,className:a}){return r.jsxs("div",{className:T("flex flex-col items-center justify-center py-16 px-4 text-center",a),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 Ub(){return Ce({queryKey:["dashboard"],queryFn:()=>W.get("/api/admin/dashboard"),refetchInterval:6e4})}function Vb(){const e=Nr(t=>t.connected);return r.jsxs("span",{className:T("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider",e?"bg-green-50 border-green-200 text-green-600":"bg-zinc-50 border-zinc-200 text-zinc-500"),"data-testid":P("dashboard","live"),"data-state":e?"live":"offline",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e&&r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:T("relative inline-flex h-1.5 w-1.5 rounded-full",e?"bg-green-500":"bg-zinc-300")})]}),e?"Live":"Offline"]})}function Ra({icon:e,label:t,value:n,subtext:s,loading:a,color:o="blue"}){const c={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:T("flex h-9 w-9 items-center justify-center rounded-lg",c[o]),children:e}),r.jsx(Ya,{className:"h-4 w-4 text-zinc-300"})]}),a?r.jsxs(r.Fragment,{children:[r.jsx(xe,{className:"h-7 w-24 mb-1"}),r.jsx(xe,{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 Bb({search:e,lookup:t,checkout:n}){return[...e?["search"]:[],...t?["lookup"]:[],...n==="none"?[]:[`checkout ${n}`]]}function Kb({agents:e,loading:t}){return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5","data-testid":P("dashboard","agents"),children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-50 text-amber-600",children:r.jsx(Ip,{className:"h-4.5 w-4.5"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Agents"}),r.jsx("p",{className:"text-xs text-zinc-500",children:"Orders shopping agents brought, last 30 days"})]})]}),t||e===void 0?r.jsx(xe,{className:"h-16 w-full"}):r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900","data-testid":P("dashboard","agents","orders"),children:e.orders.count}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"Agent orders"}),r.jsx("p",{className:"mt-2 font-mono text-sm text-zinc-900","data-testid":P("dashboard","agents","revenue"),"data-minor":e.orders.revenueMinor,children:ue(e.orders.revenueMinor,e.currency)}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"Revenue"})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"By agent"}),e.bySource.length===0?r.jsx("p",{className:"text-xs text-zinc-500",children:"No agent orders yet"}):r.jsx("ul",{className:"space-y-1 text-xs",children:e.bySource.map(n=>r.jsxs("li",{className:"flex justify-between gap-2","data-testid":P("dashboard","agents","source"),"data-source":n.source,"data-count":n.count,"data-minor":n.revenueMinor,children:[r.jsx("span",{className:"truncate text-zinc-700",children:n.source.slice(6)}),r.jsxs("span",{className:"shrink-0 font-mono text-zinc-500",children:[n.count," · ",ue(n.revenueMinor,e.currency)]})]},n.source))})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Surfaces"}),r.jsxs("ul",{className:"space-y-1 text-xs text-zinc-700",children:[e.surfaces.map(n=>r.jsxs("li",{"data-testid":P("dashboard","agents","surface",n.name),children:[r.jsx("span",{className:"font-medium uppercase",children:n.name}),":"," ",Bb(n.capabilities).join(", ")]},n.name)),r.jsxs("li",{children:[r.jsx("span",{className:"font-medium uppercase",children:"MCP"}),":"," ",e.mcp.enabled?`on, ${e.mcp.writes}`:"off"]})]}),e.profilePath!==null&&r.jsx("a",{href:e.profilePath,className:"mt-2 inline-block text-xs font-medium text-blue-600 hover:text-blue-700",children:"Agent profile →"})]})]})]})}function qb(){var o,c;const{data:e}=Po(),{data:t,isLoading:n}=Ub(),s=Ct(),a="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(Vb,{})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsx(Ra,{icon:r.jsx(Gn,{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(Ra,{icon:r.jsx(Vp,{className:"h-4.5 w-4.5"}),label:"Revenue today",value:t?ab(t.today.revenueMinor,a):"—",subtext:t?ue(t.today.revenueMinor,a):void 0,loading:n,color:"green"}),r.jsx(Ra,{icon:r.jsx(il,{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.jsx(Kb,{agents:t==null?void 0:t.agents,loading:n}),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((i,f)=>r.jsx(xe,{className:"h-11 w-full"},f))}):(o=t==null?void 0:t.recentOrders)!=null&&o.length?r.jsx("div",{className:"overflow-x-auto",role:"region",tabIndex:0,"aria-label":"Recent orders","data-testid":P("dashboard","recent-orders"),children: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(i=>r.jsxs("tr",{className:"cursor-pointer border-b border-zinc-50 last:border-0 hover:bg-zinc-50 transition-colors",onClick:()=>s(`/orders/${i.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:["#",i.orderNumber]})}),r.jsx("td",{className:"px-4 py-2.5 text-zinc-600 truncate max-w-[160px]",children:i.email}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx(Xn,{status:i.status,size:"sm"})}),r.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-sm text-zinc-700",children:ue(i.totalMinor,i.currency)}),r.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-zinc-400",children:ht(i.createdAt)})]},i.id))})]})}):r.jsx(Ge,{icon:r.jsx(Gn,{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((i,f)=>r.jsx(xe,{className:"h-10 w-full"},f))}):(c=t==null?void 0:t.lowStock)!=null&&c.length?r.jsx("div",{className:"divide-y divide-zinc-50",children:t.lowStock.map(i=>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:i.productName}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:i.sku})]}),r.jsxs("div",{className:"ml-3 text-right",children:[r.jsx("span",{className:T("font-mono text-sm font-semibold",i.status==="out_of_stock"?"text-red-600":"text-amber-600"),children:i.stock}),r.jsxs("p",{className:"text-[10px] text-zinc-400",children:["/",i.threshold]})]})]},i.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(ys,{className:"h-4 w-4 text-green-500"})}),r.jsx("p",{className:"text-xs text-zinc-500",children:"All stock levels are healthy"})]})]})})]})]})}const wn=l.forwardRef(({className:e,...t},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:T("w-full caption-bottom text-sm",e),...t})}));wn.displayName="Table";const jn=l.forwardRef(({className:e,...t},n)=>r.jsx("thead",{ref:n,className:T("[&_tr]:border-b [&_tr]:border-zinc-200",e),...t}));jn.displayName="TableHeader";const Nn=l.forwardRef(({className:e,...t},n)=>r.jsx("tbody",{ref:n,className:T("[&_tr:last-child]:border-0",e),...t}));Nn.displayName="TableBody";const Hb=l.forwardRef(({className:e,...t},n)=>r.jsx("tfoot",{ref:n,className:T("border-t border-zinc-200 bg-zinc-50/50 font-medium [&>tr]:last:border-b-0",e),...t}));Hb.displayName="TableFooter";const Ke=l.forwardRef(({className:e,...t},n)=>r.jsx("tr",{ref:n,className:T("border-b border-zinc-100 transition-colors hover:bg-zinc-50/60 data-[state=selected]:bg-blue-50",e),...t}));Ke.displayName="TableRow";const ne=l.forwardRef(({className:e,...t},n)=>r.jsx("th",{ref:n,className:T("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}));ne.displayName="TableHead";const re=l.forwardRef(({className:e,...t},n)=>r.jsx("td",{ref:n,className:T("h-11 px-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));re.displayName="TableCell";const Wb=l.forwardRef(({className:e,...t},n)=>r.jsx("caption",{ref:n,className:T("mt-4 text-sm text-zinc-500",e),...t}));Wb.displayName="TableCaption";function gu(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 ea="Checkbox",[Gb]=ut(ea),[Qb,ei]=Gb(ea);function Yb(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:c,name:i,onCheckedChange:f,required:u,value:d="on",internal_do_not_use_render:h}=e,[m,x]=Gt({prop:n,defaultProp:a??!1,onChange:f,caller:ea}),[g,p]=l.useState(null),[v,y]=l.useState(null),w=l.useRef(!1),N=g?!!c||!!g.closest("form"):!0,j={checked:m,disabled:o,setChecked:x,control:g,setControl:p,name:i,form:c,value:d,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:Bt(a)?!1:a,isFormControl:N,bubbleInput:v,setBubbleInput:y};return r.jsx(Qb,{scope:t,...j,children:Xb(h)?h(j):s})}var vu="CheckboxTrigger",yu=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:c,disabled:i,checked:f,required:u,setControl:d,setChecked:h,hasConsumerStoppedPropagationRef:m,isFormControl:x,bubbleInput:g}=ei(vu,e),p=de(a,d),v=l.useRef(f);return l.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const w=()=>h(v.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[o,h]),r.jsx(G.button,{type:"button",role:"checkbox","aria-checked":Bt(f)?"mixed":f,"aria-required":u,"data-state":Cu(f),"data-disabled":i?"":void 0,disabled:i,value:c,...s,ref:p,onKeyDown:D(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:D(n,y=>{h(w=>Bt(w)?!0:!w),g&&x&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})})});yu.displayName=vu;var ti=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:c,disabled:i,value:f,onCheckedChange:u,form:d,...h}=e;return r.jsx(Yb,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:i,required:c,onCheckedChange:u,name:s,form:d,value:f,internal_do_not_use_render:({isFormControl:m})=>r.jsxs(r.Fragment,{children:[r.jsx(yu,{...h,ref:t,__scopeCheckbox:n}),m&&r.jsx(Nu,{__scopeCheckbox:n})]})})});ti.displayName=ea;var bu="CheckboxIndicator",wu=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=ei(bu,n);return r.jsx(Qe,{present:s||Bt(o.checked)||o.checked===!0,children:r.jsx(G.span,{"data-state":Cu(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});wu.displayName=bu;var ju="CheckboxBubbleInput",Nu=l.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:c,required:i,disabled:f,name:u,value:d,form:h,bubbleInput:m,setBubbleInput:x}=ei(ju,e),g=de(n,x),p=gu(o),v=zl(s);l.useEffect(()=>{const w=m;if(!w)return;const N=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(N,"checked").set,C=!a.current;if(p!==o&&S){const E=new Event("click",{bubbles:C});w.indeterminate=Bt(o),S.call(w,Bt(o)?!1:o),w.dispatchEvent(E)}},[m,p,o,a]);const y=l.useRef(Bt(o)?!1:o);return r.jsx(G.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??y.current,required:i,disabled:f,name:u,value:d,form:h,...t,tabIndex:-1,ref:g,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Nu.displayName=ju;function Xb(e){return typeof e=="function"}function Bt(e){return e==="indeterminate"}function Cu(e){return Bt(e)?"indeterminate":e?"checked":"unchecked"}const io=l.forwardRef(({className:e,...t},n)=>r.jsx(ti,{ref:n,className:T("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(wu,{className:T("flex items-center justify-center text-current"),children:r.jsx(St,{className:"h-3 w-3",strokeWidth:3})})}));io.displayName=ti.displayName;var co=["Enter"," "],Zb=["ArrowDown","PageUp","Home"],Su=["ArrowUp","PageDown","End"],Jb=[...Zb,...Su],ew={ltr:[...co,"ArrowRight"],rtl:[...co,"ArrowLeft"]},tw={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Hr="Menu",[Cr,nw,rw]=Yo(Hr),[Cn,Eu]=ut(Hr,[rw,ar,Zs]),ta=ar(),Ru=Zs(),[sw,Sn]=Cn(Hr),[aw,Wr]=Cn(Hr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:a,onOpenChange:o,modal:c=!0}=e,i=ta(t),[f,u]=l.useState(null),d=l.useRef(!1),h=dt(o),m=Xs(a);return l.useEffect(()=>{const x=()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>d.current=!1;return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),r.jsx(Lo,{...i,children:r.jsx(sw,{scope:t,open:n,onOpenChange:h,content:f,onContentChange:u,children:r.jsx(aw,{scope:t,onClose:l.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:c,children:s})})})};Pu.displayName=Hr;var ow="MenuAnchor",ni=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,a=ta(n);return r.jsx(Fs,{...a,...s,ref:t})});ni.displayName=ow;var ri="MenuPortal",[iw,ku]=Cn(ri,{forceMount:void 0}),Tu=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:a}=e,o=Sn(ri,t);return r.jsx(iw,{scope:t,forceMount:n,children:r.jsx(Qe,{present:n||o.open,children:r.jsx(zr,{asChild:!0,container:a,children:s})})})};Tu.displayName=ri;var We="MenuContent",[cw,si]=Cn(We),Au=l.forwardRef((e,t)=>{const n=ku(We,e.__scopeMenu),{forceMount:s=n.forceMount,...a}=e,o=Sn(We,e.__scopeMenu),c=Wr(We,e.__scopeMenu);return r.jsx(Cr.Provider,{scope:e.__scopeMenu,children:r.jsx(Qe,{present:s||o.open,children:r.jsx(Cr.Slot,{scope:e.__scopeMenu,children:c.modal?r.jsx(lw,{...a,ref:t}):r.jsx(dw,{...a,ref:t})})})})}),lw=l.forwardRef((e,t)=>{const n=Sn(We,e.__scopeMenu),s=l.useRef(null),a=de(t,s);return l.useEffect(()=>{const o=s.current;if(o)return $s(o)},[]),r.jsx(ai,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:D(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),dw=l.forwardRef((e,t)=>{const n=Sn(We,e.__scopeMenu);return r.jsx(ai,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),uw=pn("MenuContent.ScrollLock"),ai=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:i,onEntryFocus:f,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:x,disableOutsideScroll:g,...p}=e,v=Sn(We,n),y=Wr(We,n),w=ta(n),N=Ru(n),j=nw(n),[S,C]=l.useState(null),E=l.useRef(null),k=de(t,E,v.onContentChange),z=l.useRef(0),O=l.useRef(""),U=l.useRef(0),I=l.useRef(null),Q=l.useRef("right"),V=l.useRef(0),Z=g?Lr:l.Fragment,B=g?{as:uw,allowPinchZoom:!0}:void 0,ae=A=>{var M,Y;const ce=O.current+A,le=j().filter(X=>!X.disabled),R=document.activeElement,K=(M=le.find(X=>X.ref.current===R))==null?void 0:M.textValue,H=le.map(X=>X.textValue),L=Nw(H,ce,K),J=(Y=le.find(X=>X.textValue===L))==null?void 0:Y.ref.current;(function X(ie){O.current=ie,window.clearTimeout(z.current),ie!==""&&(z.current=window.setTimeout(()=>X(""),1e3))})(ce),J&&setTimeout(()=>J.focus())};l.useEffect(()=>()=>window.clearTimeout(z.current),[]),Is();const F=l.useCallback(A=>{var le,R;return Q.current===((le=I.current)==null?void 0:le.side)&&Sw(A,(R=I.current)==null?void 0:R.area)},[]);return r.jsx(cw,{scope:n,searchRef:O,onItemEnter:l.useCallback(A=>{F(A)&&A.preventDefault()},[F]),onItemLeave:l.useCallback(A=>{var ce;F(A)||((ce=E.current)==null||ce.focus(),C(null))},[F]),onTriggerLeave:l.useCallback(A=>{F(A)&&A.preventDefault()},[F]),pointerGraceTimerRef:U,onPointerGraceIntentChange:l.useCallback(A=>{I.current=A},[]),children:r.jsx(Z,{...B,children:r.jsx(Or,{asChild:!0,trapped:a,onMountAutoFocus:D(o,A=>{var ce;A.preventDefault(),(ce=E.current)==null||ce.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:r.jsx(Ir,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:x,children:r.jsx(Qd,{asChild:!0,...N,dir:y.dir,orientation:"vertical",loop:s,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:D(f,A=>{y.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Fo,{role:"menu","aria-orientation":"vertical","data-state":Wu(v.open),"data-radix-menu-content":"",dir:y.dir,...w,...p,ref:k,style:{outline:"none",...p.style},onKeyDown:D(p.onKeyDown,A=>{const le=A.target.closest("[data-radix-menu-content]")===A.currentTarget,R=A.ctrlKey||A.altKey||A.metaKey,K=A.key.length===1;le&&(A.key==="Tab"&&A.preventDefault(),!R&&K&&ae(A.key));const H=E.current;if(A.target!==H||!Jb.includes(A.key))return;A.preventDefault();const J=j().filter(M=>!M.disabled).map(M=>M.ref.current);Su.includes(A.key)&&J.reverse(),ww(J)}),onBlur:D(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(z.current),O.current="")}),onPointerMove:D(e.onPointerMove,Sr(A=>{const ce=A.target,le=V.current!==A.clientX;if(A.currentTarget.contains(ce)&&le){const R=A.clientX>V.current?"right":"left";Q.current=R,V.current=A.clientX}}))})})})})})})});Au.displayName=We;var fw="MenuGroup",oi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{role:"group",...s,ref:t})});oi.displayName=fw;var hw="MenuLabel",Mu=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{...s,ref:t})});Mu.displayName=hw;var Rs="MenuItem",hc="menu.itemSelect",na=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...a}=e,o=l.useRef(null),c=Wr(Rs,e.__scopeMenu),i=si(Rs,e.__scopeMenu),f=de(t,o),u=l.useRef(!1),d=()=>{const h=o.current;if(!n&&h){const m=new CustomEvent(hc,{bubbles:!0,cancelable:!0});h.addEventListener(hc,x=>s==null?void 0:s(x),{once:!0}),wl(h,m),m.defaultPrevented?u.current=!1:c.onClose()}};return r.jsx(_u,{...a,ref:f,disabled:n,onClick:D(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:D(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:D(e.onKeyDown,h=>{const m=i.searchRef.current!=="";n||m&&h.key===" "||co.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});na.displayName=Rs;var _u=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:a,...o}=e,c=si(Rs,n),i=Ru(n),f=l.useRef(null),u=de(t,f),[d,h]=l.useState(!1),[m,x]=l.useState("");return l.useEffect(()=>{const g=f.current;g&&x((g.textContent??"").trim())},[o.children]),r.jsx(Cr.ItemSlot,{scope:n,disabled:s,textValue:a??m,children:r.jsx(Yd,{asChild:!0,...i,focusable:!s,children:r.jsx(G.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...o,ref:u,onPointerMove:D(e.onPointerMove,Sr(g=>{s?c.onItemLeave(g):(c.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:D(e.onPointerLeave,Sr(g=>c.onItemLeave(g))),onFocus:D(e.onFocus,()=>h(!0)),onBlur:D(e.onBlur,()=>h(!1))})})})}),mw="MenuCheckboxItem",Iu=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...a}=e;return r.jsx(Fu,{scope:e.__scopeMenu,checked:n,children:r.jsx(na,{role:"menuitemcheckbox","aria-checked":Ps(n)?"mixed":n,...a,ref:t,"data-state":ci(n),onSelect:D(a.onSelect,()=>s==null?void 0:s(Ps(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Iu.displayName=mw;var Ou="MenuRadioGroup",[pw,xw]=Cn(Ou,{value:void 0,onValueChange:()=>{}}),Du=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...a}=e,o=dt(s);return r.jsx(pw,{scope:e.__scopeMenu,value:n,onValueChange:o,children:r.jsx(oi,{...a,ref:t})})});Du.displayName=Ou;var zu="MenuRadioItem",Lu=l.forwardRef((e,t)=>{const{value:n,...s}=e,a=xw(zu,e.__scopeMenu),o=n===a.value;return r.jsx(Fu,{scope:e.__scopeMenu,checked:o,children:r.jsx(na,{role:"menuitemradio","aria-checked":o,...s,ref:t,"data-state":ci(o),onSelect:D(s.onSelect,()=>{var c;return(c=a.onValueChange)==null?void 0:c.call(a,n)},{checkForDefaultPrevented:!1})})})});Lu.displayName=zu;var ii="MenuItemIndicator",[Fu,gw]=Cn(ii,{checked:!1}),$u=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...a}=e,o=gw(ii,n);return r.jsx(Qe,{present:s||Ps(o.checked)||o.checked===!0,children:r.jsx(G.span,{...a,ref:t,"data-state":ci(o.checked)})})});$u.displayName=ii;var vw="MenuSeparator",Uu=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Uu.displayName=vw;var yw="MenuArrow",Vu=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,a=ta(n);return r.jsx($o,{...a,...s,ref:t})});Vu.displayName=yw;var bw="MenuSub",[z1,Bu]=Cn(bw),gr="MenuSubTrigger",Ku=l.forwardRef((e,t)=>{const n=Sn(gr,e.__scopeMenu),s=Wr(gr,e.__scopeMenu),a=Bu(gr,e.__scopeMenu),o=si(gr,e.__scopeMenu),c=l.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:f}=o,u={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const h=i.current;return()=>{window.clearTimeout(h),f(null)}},[i,f]),r.jsx(ni,{asChild:!0,...u,children:r.jsx(_u,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":Wu(n.open),...e,ref:lt(t,a.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:D(e.onPointerMove,Sr(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(o.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:D(e.onPointerLeave,Sr(h=>{var x,g;d();const m=(x=n.content)==null?void 0:x.getBoundingClientRect();if(m){const p=(g=n.content)==null?void 0:g.dataset.side,v=p==="right",y=v?-5:5,w=m[v?"left":"right"],N=m[v?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.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(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:D(e.onKeyDown,h=>{var x;const m=o.searchRef.current!=="";e.disabled||m&&h.key===" "||ew[s.dir].includes(h.key)&&(n.onOpenChange(!0),(x=n.content)==null||x.focus(),h.preventDefault())})})})});Ku.displayName=gr;var qu="MenuSubContent",Hu=l.forwardRef((e,t)=>{const n=ku(We,e.__scopeMenu),{forceMount:s=n.forceMount,...a}=e,o=Sn(We,e.__scopeMenu),c=Wr(We,e.__scopeMenu),i=Bu(qu,e.__scopeMenu),f=l.useRef(null),u=de(t,f);return r.jsx(Cr.Provider,{scope:e.__scopeMenu,children:r.jsx(Qe,{present:s||o.open,children:r.jsx(Cr.Slot,{scope:e.__scopeMenu,children:r.jsx(ai,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;c.isUsingKeyboardRef.current&&((h=f.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:D(e.onFocusOutside,d=>{d.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:D(e.onEscapeKeyDown,d=>{c.onClose(),d.preventDefault()}),onKeyDown:D(e.onKeyDown,d=>{var x;const h=d.currentTarget.contains(d.target),m=tw[c.dir].includes(d.key);h&&m&&(o.onOpenChange(!1),(x=i.trigger)==null||x.focus(),d.preventDefault())})})})})})});Hu.displayName=qu;function Wu(e){return e?"open":"closed"}function Ps(e){return e==="indeterminate"}function ci(e){return Ps(e)?"indeterminate":e?"checked":"unchecked"}function ww(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function jw(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function Nw(e,t,n){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let c=jw(e,Math.max(o,0));a.length===1&&(c=c.filter(u=>u!==n));const f=c.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function Cw(e,t){const{x:n,y:s}=e;let a=!1;for(let o=0,c=t.length-1;o<t.length;c=o++){const i=t[o],f=t[c],u=i.x,d=i.y,h=f.x,m=f.y;d>s!=m>s&&n<(h-u)*(s-d)/(m-d)+u&&(a=!a)}return a}function Sw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Cw(n,t)}function Sr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ew=Pu,Rw=ni,Pw=Tu,kw=Au,Tw=oi,Aw=Mu,Mw=na,_w=Iu,Iw=Du,Ow=Lu,Dw=$u,zw=Uu,Lw=Vu,Fw=Ku,$w=Hu,ra="DropdownMenu",[Uw]=ut(ra,[Eu]),Me=Eu(),[Vw,Gu]=Uw(ra),Qu=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:a,defaultOpen:o,onOpenChange:c,modal:i=!0}=e,f=Me(t),u=l.useRef(null),[d,h]=Gt({prop:a,defaultProp:o??!1,onChange:c,caller:ra});return r.jsx(Vw,{scope:t,triggerId:Ne(),triggerRef:u,contentId:Ne(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(m=>!m),[h]),modal:i,children:r.jsx(Ew,{...f,open:d,onOpenChange:h,dir:s,modal:i,children:n})})};Qu.displayName=ra;var Yu="DropdownMenuTrigger",Xu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...a}=e,o=Gu(Yu,n),c=Me(n);return r.jsx(Rw,{asChild:!0,...c,children:r.jsx(G.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...a,ref:lt(t,o.triggerRef),onPointerDown:D(e.onPointerDown,i=>{!s&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:D(e.onKeyDown,i=>{s||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});Xu.displayName=Yu;var Bw="DropdownMenuPortal",Zu=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Me(t);return r.jsx(Pw,{...s,...n})};Zu.displayName=Bw;var Ju="DropdownMenuContent",ef=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Gu(Ju,n),o=Me(n),c=l.useRef(!1);return r.jsx(kw,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...s,ref:t,onCloseAutoFocus:D(e.onCloseAutoFocus,i=>{var f;c.current||(f=a.triggerRef.current)==null||f.focus(),c.current=!1,i.preventDefault()}),onInteractOutside:D(e.onInteractOutside,i=>{const f=i.detail.originalEvent,u=f.button===0&&f.ctrlKey===!0,d=f.button===2||u;(!a.modal||d)&&(c.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)"}})});ef.displayName=Ju;var Kw="DropdownMenuGroup",qw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Tw,{...a,...s,ref:t})});qw.displayName=Kw;var Hw="DropdownMenuLabel",tf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Aw,{...a,...s,ref:t})});tf.displayName=Hw;var Ww="DropdownMenuItem",nf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Mw,{...a,...s,ref:t})});nf.displayName=Ww;var Gw="DropdownMenuCheckboxItem",rf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(_w,{...a,...s,ref:t})});rf.displayName=Gw;var Qw="DropdownMenuRadioGroup",Yw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Iw,{...a,...s,ref:t})});Yw.displayName=Qw;var Xw="DropdownMenuRadioItem",sf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Ow,{...a,...s,ref:t})});sf.displayName=Xw;var Zw="DropdownMenuItemIndicator",af=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Dw,{...a,...s,ref:t})});af.displayName=Zw;var Jw="DropdownMenuSeparator",of=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(zw,{...a,...s,ref:t})});of.displayName=Jw;var ej="DropdownMenuArrow",tj=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Lw,{...a,...s,ref:t})});tj.displayName=ej;var nj="DropdownMenuSubTrigger",cf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Fw,{...a,...s,ref:t})});cf.displayName=nj;var rj="DropdownMenuSubContent",lf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx($w,{...a,...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)"}})});lf.displayName=rj;var sj=Qu,aj=Xu,oj=Zu,df=ef,uf=tf,ff=nf,hf=rf,mf=sf,pf=af,xf=of,gf=cf,vf=lf;const li=sj,di=aj,ij=l.forwardRef(({className:e,inset:t,children:n,...s},a)=>r.jsxs(gf,{ref:a,className:T("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(tl,{className:"ml-auto"})]}));ij.displayName=gf.displayName;const cj=l.forwardRef(({className:e,...t},n)=>r.jsx(vf,{ref:n,className:T("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}));cj.displayName=vf.displayName;const sa=l.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(oj,{children:r.jsx(df,{ref:s,sideOffset:t,className:T("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})}));sa.displayName=df.displayName;const bt=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(ff,{ref:s,className:T("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}));bt.displayName=ff.displayName;const lj=l.forwardRef(({className:e,children:t,checked:n=!1,...s},a)=>r.jsxs(hf,{ref:a,className:T("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(pf,{children:r.jsx(St,{className:"h-4 w-4"})})}),t]}));lj.displayName=hf.displayName;const dj=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(mf,{ref:s,className:T("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(pf,{children:r.jsx(Fp,{className:"h-2 w-2 fill-current"})})}),t]}));dj.displayName=mf.displayName;const uj=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(uf,{ref:s,className:T("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",t&&"pl-8",e),...n}));uj.displayName=uf.displayName;const aa=l.forwardRef(({className:e,...t},n)=>r.jsx(xf,{ref:n,className:T("-mx-1 my-1 h-px bg-zinc-100",e),...t}));aa.displayName=xf.displayName;const fj=[{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"}],hj={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"};function mj(){const e=Ct(),[t,n]=l.useState("all"),[s,a]=l.useState(""),[o,c]=l.useState(new Set),{data:i,isLoading:f}=ll({status:t==="all"?void 0:t,q:s||void 0,sort:"createdAt:desc",limit:100}),u=m=>{c(x=>{const g=new Set(x);return g.has(m)?g.delete(m):g.add(m),g})},d=()=>{i&&(o.size===i.length?c(new Set):c(new Set(i.map(m=>m.id))))},h=i?o.size===i.length&&i.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:i?`${i.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:fj.map(m=>r.jsx("button",{onClick:()=>n(m.value),className:T("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(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search orders...",value:s,onChange:m=>a(m.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsxs(se,{variant:"outline",size:"sm",className:"gap-1.5",children:[r.jsx(Kp,{className:"h-3.5 w-3.5"}),"Filter"]})]})]}),o.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:[o.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[r.jsxs(se,{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(Dp,{className:"h-3.5 w-3.5"}),"Confirm All"]}),r.jsxs(se,{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(ol,{className:"h-3.5 w-3.5"}),"Cancel All"]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:f?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>r.jsx(xe,{className:"h-11 w-full"},x))}):i!=null&&i.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Ke,{children:[r.jsx(ne,{className:"w-10 pl-4",children:r.jsx(io,{checked:h,onCheckedChange:d,"aria-label":"Select all"})}),r.jsx(ne,{children:"Order #"}),r.jsx(ne,{children:"Customer"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Payment"}),r.jsx(ne,{className:"text-center",children:"Items"}),r.jsx(ne,{className:"text-right",children:"Total"}),r.jsx(ne,{className:"text-right",children:"Date"}),r.jsx(ne,{className:"w-10",children:r.jsx("span",{className:"sr-only",children:"Actions"})})]})}),r.jsx(Nn,{children:i.map(m=>r.jsxs(Ke,{"data-testid":P("orders","row",m.orderNumber),"data-state":o.has(m.id)?"selected":void 0,className:T("cursor-pointer",o.has(m.id)&&"bg-blue-50/50"),children:[r.jsx(re,{className:"pl-4",onClick:x=>x.stopPropagation(),children:r.jsx(io,{checked:o.has(m.id),onCheckedChange:()=>u(m.id),"aria-label":`Select order ${m.orderNumber}`})}),r.jsxs(re,{className:"font-mono text-sm font-medium text-blue-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:["#",m.orderNumber]}),r.jsx(re,{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(re,{onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx(Xn,{status:m.status})}),r.jsx(re,{className:"text-sm text-zinc-600",onClick:()=>e(`/orders/${m.orderNumber}`),"data-testid":P("orders","payment",m.orderNumber),children:hj[hm(m)]}),r.jsx(re,{className:"text-center text-zinc-500",onClick:()=>e(`/orders/${m.orderNumber}`),children:m.lineItems.length}),r.jsx(re,{className:"text-right font-mono text-sm",onClick:()=>e(`/orders/${m.orderNumber}`),children:ue(m.totalMinor,m.currency)}),r.jsx(re,{className:"text-right text-sm text-zinc-400",onClick:()=>e(`/orders/${m.orderNumber}`),children:ht(m.createdAt)}),r.jsx(re,{onClick:x=>x.stopPropagation(),children:r.jsxs(li,{children:[r.jsx(di,{asChild:!0,children:r.jsx(se,{variant:"ghost",size:"icon","aria-label":`Actions for order ${m.orderNumber}`,className:"h-8 w-8 text-zinc-400",children:r.jsx(rl,{className:"h-4 w-4"})})}),r.jsxs(sa,{align:"end",children:[r.jsx(bt,{onClick:()=>e(`/orders/${m.orderNumber}`),children:"View details"}),r.jsx(aa,{}),r.jsx(bt,{className:"text-red-600",children:"Cancel order"})]})]})})]},m.id))})]}):r.jsx(Ge,{icon:r.jsx(qt,{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 pj={breadcrumb:()=>"Orders"};function mc(e,[t,n]){return Math.min(n,Math.max(t,e))}var yf=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"}),xj="VisuallyHidden",gj=l.forwardRef((e,t)=>r.jsx(G.span,{...e,ref:t,style:{...yf,...e.style}}));gj.displayName=xj;var vj=[" ","Enter","ArrowUp","ArrowDown"],yj=[" ","Enter"],yn="Select",[oa,ia,bj]=Yo(yn),[ir]=ut(yn,[bj,ar]),ca=ar(),[wj,Jt]=ir(yn),[jj,Nj]=ir(yn),bf=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:c,defaultValue:i,onValueChange:f,dir:u,name:d,autoComplete:h,disabled:m,required:x,form:g}=e,p=ca(t),[v,y]=l.useState(null),[w,N]=l.useState(null),[j,S]=l.useState(!1),C=Xs(u),[E,k]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:yn}),[z,O]=Gt({prop:c,defaultProp:i,onChange:f,caller:yn}),U=l.useRef(null),I=v?g||!!v.closest("form"):!0,[Q,V]=l.useState(new Set),Z=Array.from(Q).map(B=>B.props.value).join(";");return r.jsx(Lo,{...p,children:r.jsxs(wj,{required:x,scope:t,trigger:v,onTriggerChange:y,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:j,onValueNodeHasChildrenChange:S,contentId:Ne(),value:z,onValueChange:O,open:E,onOpenChange:k,dir:C,triggerPointerDownPosRef:U,disabled:m,children:[r.jsx(oa.Provider,{scope:t,children:r.jsx(jj,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(B=>{V(ae=>new Set(ae).add(B))},[]),onNativeOptionRemove:l.useCallback(B=>{V(ae=>{const F=new Set(ae);return F.delete(B),F})},[]),children:n})}),I?r.jsxs(Kf,{"aria-hidden":!0,required:x,tabIndex:-1,name:d,autoComplete:h,value:z,onChange:B=>O(B.target.value),disabled:m,form:g,children:[z===void 0?r.jsx("option",{value:""}):null,Array.from(Q)]},Z):null]})})};bf.displayName=yn;var wf="SelectTrigger",jf=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=ca(n),c=Jt(wf,n),i=c.disabled||s,f=de(t,c.onTriggerChange),u=ia(n),d=l.useRef("touch"),[h,m,x]=Hf(p=>{const v=u().filter(N=>!N.disabled),y=v.find(N=>N.value===c.value),w=Wf(v,p,y);w!==void 0&&c.onValueChange(w.value)}),g=p=>{i||(c.onOpenChange(!0),x()),p&&(c.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(Fs,{asChild:!0,...o,children:r.jsx(G.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":qf(c.value)?"":void 0,...a,ref:f,onClick:D(a.onClick,p=>{p.currentTarget.focus(),d.current!=="mouse"&&g(p)}),onPointerDown:D(a.onPointerDown,p=>{d.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(g(p),p.preventDefault())}),onKeyDown:D(a.onKeyDown,p=>{const v=h.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&m(p.key),!(v&&p.key===" ")&&vj.includes(p.key)&&(g(),p.preventDefault())})})})});jf.displayName=wf;var Nf="SelectValue",Cf=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:c="",...i}=e,f=Jt(Nf,n),{onValueNodeHasChildrenChange:u}=f,d=o!==void 0,h=de(t,f.onValueNodeChange);return Pe(()=>{u(d)},[u,d]),r.jsx(G.span,{...i,ref:h,style:{pointerEvents:"none"},children:qf(f.value)?r.jsx(r.Fragment,{children:c}):o})});Cf.displayName=Nf;var Cj="SelectIcon",Sf=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return r.jsx(G.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});Sf.displayName=Cj;var Sj="SelectPortal",Ef=e=>r.jsx(zr,{asChild:!0,...e});Ef.displayName=Sj;var bn="SelectContent",Rf=l.forwardRef((e,t)=>{const n=Jt(bn,e.__scopeSelect),[s,a]=l.useState();if(Pe(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?Ts.createPortal(r.jsx(Pf,{scope:e.__scopeSelect,children:r.jsx(oa.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),o):null}return r.jsx(kf,{...e,ref:t})});Rf.displayName=bn;var Ye=10,[Pf,en]=ir(bn),Ej="SelectContentImpl",Rj=pn("SelectContent.RemoveScroll"),kf=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:c,side:i,sideOffset:f,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v,...y}=e,w=Jt(bn,n),[N,j]=l.useState(null),[S,C]=l.useState(null),E=de(t,M=>j(M)),[k,z]=l.useState(null),[O,U]=l.useState(null),I=ia(n),[Q,V]=l.useState(!1),Z=l.useRef(!1);l.useEffect(()=>{if(N)return $s(N)},[N]),Is();const B=l.useCallback(M=>{const[Y,...X]=I().map(me=>me.ref.current),[ie]=X.slice(-1),he=document.activeElement;for(const me of M)if(me===he||(me==null||me.scrollIntoView({block:"nearest"}),me===Y&&S&&(S.scrollTop=0),me===ie&&S&&(S.scrollTop=S.scrollHeight),me==null||me.focus(),document.activeElement!==he))return},[I,S]),ae=l.useCallback(()=>B([k,N]),[B,k,N]);l.useEffect(()=>{Q&&ae()},[Q,ae]);const{onOpenChange:F,triggerPointerDownPosRef:A}=w;l.useEffect(()=>{if(N){let M={x:0,y:0};const Y=ie=>{var he,me;M={x:Math.abs(Math.round(ie.pageX)-(((he=A.current)==null?void 0:he.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((me=A.current)==null?void 0:me.y)??0))}},X=ie=>{M.x<=10&&M.y<=10?ie.preventDefault():N.contains(ie.target)||F(!1),document.removeEventListener("pointermove",Y),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",Y),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",X,{capture:!0})}}},[N,F,A]),l.useEffect(()=>{const M=()=>F(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[F]);const[ce,le]=Hf(M=>{const Y=I().filter(he=>!he.disabled),X=Y.find(he=>he.ref.current===document.activeElement),ie=Wf(Y,M,X);ie&&setTimeout(()=>ie.ref.current.focus())}),R=l.useCallback((M,Y,X)=>{const ie=!Z.current&&!X;(w.value!==void 0&&w.value===Y||ie)&&(z(M),ie&&(Z.current=!0))},[w.value]),K=l.useCallback(()=>N==null?void 0:N.focus(),[N]),H=l.useCallback((M,Y,X)=>{const ie=!Z.current&&!X;(w.value!==void 0&&w.value===Y||ie)&&U(M)},[w.value]),L=s==="popper"?lo:Tf,J=L===lo?{side:i,sideOffset:f,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(Pf,{scope:n,content:N,viewport:S,onViewportChange:C,itemRefCallback:R,selectedItem:k,onItemLeave:K,itemTextRefCallback:H,focusSelectedItem:ae,selectedItemText:O,position:s,isPositioned:Q,searchRef:ce,children:r.jsx(Lr,{as:Rj,allowPinchZoom:!0,children:r.jsx(Or,{asChild:!0,trapped:w.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:D(a,M=>{var Y;(Y=w.trigger)==null||Y.focus({preventScroll:!0}),M.preventDefault()}),children:r.jsx(Ir,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:r.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:M=>M.preventDefault(),...y,...J,onPlaced:()=>V(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:D(y.onKeyDown,M=>{const Y=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Y&&M.key.length===1&&le(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let ie=I().filter(he=>!he.disabled).map(he=>he.ref.current);if(["ArrowUp","End"].includes(M.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const he=M.target,me=ie.indexOf(he);ie=ie.slice(me+1)}setTimeout(()=>B(ie)),M.preventDefault()}})})})})})})});kf.displayName=Ej;var Pj="SelectItemAlignedPosition",Tf=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=Jt(bn,n),c=en(bn,n),[i,f]=l.useState(null),[u,d]=l.useState(null),h=de(t,E=>d(E)),m=ia(n),x=l.useRef(!1),g=l.useRef(!0),{viewport:p,selectedItem:v,selectedItemText:y,focusSelectedItem:w}=c,N=l.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&p&&v&&y){const E=o.trigger.getBoundingClientRect(),k=u.getBoundingClientRect(),z=o.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(o.dir!=="rtl"){const he=O.left-k.left,me=z.left-he,ze=E.left-me,nt=E.width+ze,cr=Math.max(nt,k.width),lr=window.innerWidth-Ye,dr=mc(me,[Ye,Math.max(Ye,lr-cr)]);i.style.minWidth=nt+"px",i.style.left=dr+"px"}else{const he=k.right-O.right,me=window.innerWidth-z.right-he,ze=window.innerWidth-E.right-me,nt=E.width+ze,cr=Math.max(nt,k.width),lr=window.innerWidth-Ye,dr=mc(me,[Ye,Math.max(Ye,lr-cr)]);i.style.minWidth=nt+"px",i.style.right=dr+"px"}const U=m(),I=window.innerHeight-Ye*2,Q=p.scrollHeight,V=window.getComputedStyle(u),Z=parseInt(V.borderTopWidth,10),B=parseInt(V.paddingTop,10),ae=parseInt(V.borderBottomWidth,10),F=parseInt(V.paddingBottom,10),A=Z+B+Q+F+ae,ce=Math.min(v.offsetHeight*5,A),le=window.getComputedStyle(p),R=parseInt(le.paddingTop,10),K=parseInt(le.paddingBottom,10),H=E.top+E.height/2-Ye,L=I-H,J=v.offsetHeight/2,M=v.offsetTop+J,Y=Z+B+M,X=A-Y;if(Y<=H){const he=U.length>0&&v===U[U.length-1].ref.current;i.style.bottom="0px";const me=u.clientHeight-p.offsetTop-p.offsetHeight,ze=Math.max(L,J+(he?K:0)+me+ae),nt=Y+ze;i.style.height=nt+"px"}else{const he=U.length>0&&v===U[0].ref.current;i.style.top="0px";const ze=Math.max(H,Z+p.offsetTop+(he?R:0)+J)+X;i.style.height=ze+"px",p.scrollTop=Y-H+p.offsetTop}i.style.margin=`${Ye}px 0`,i.style.minHeight=ce+"px",i.style.maxHeight=I+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[m,o.trigger,o.valueNode,i,u,p,v,y,o.dir,s]);Pe(()=>N(),[N]);const[j,S]=l.useState();Pe(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const C=l.useCallback(E=>{E&&g.current===!0&&(N(),w==null||w(),g.current=!1)},[N,w]);return r.jsx(Tj,{scope:n,contentWrapper:i,shouldExpandOnScrollRef:x,onScrollButtonChange:C,children:r.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(G.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Tf.displayName=Pj;var kj="SelectPopperPosition",lo=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=Ye,...o}=e,c=ca(n);return r.jsx(Fo,{...c,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.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)"}})});lo.displayName=kj;var[Tj,ui]=ir(bn,{}),uo="SelectViewport",Af=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=en(uo,n),c=ui(uo,n),i=de(t,o.onViewportChange),f=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(oa.Slot,{scope:n,children:r.jsx(G.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:D(a.onScroll,u=>{const d=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=c;if(m!=null&&m.current&&h){const x=Math.abs(f.current-d.scrollTop);if(x>0){const g=window.innerHeight-Ye*2,p=parseFloat(h.style.minHeight),v=parseFloat(h.style.height),y=Math.max(p,v);if(y<g){const w=y+x,N=Math.min(g,w),j=w-N;h.style.height=N+"px",h.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,h.style.justifyContent="flex-end")}}}f.current=d.scrollTop})})})]})});Af.displayName=uo;var Mf="SelectGroup",[Aj,Mj]=ir(Mf),_j=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=Ne();return r.jsx(Aj,{scope:n,id:a,children:r.jsx(G.div,{role:"group","aria-labelledby":a,...s,ref:t})})});_j.displayName=Mf;var _f="SelectLabel",If=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=Mj(_f,n);return r.jsx(G.div,{id:a.id,...s,ref:t})});If.displayName=_f;var ks="SelectItem",[Ij,Of]=ir(ks),Df=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...c}=e,i=Jt(ks,n),f=en(ks,n),u=i.value===s,[d,h]=l.useState(o??""),[m,x]=l.useState(!1),g=de(t,w=>{var N;return(N=f.itemRefCallback)==null?void 0:N.call(f,w,s,a)}),p=Ne(),v=l.useRef("touch"),y=()=>{a||(i.onValueChange(s),i.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(Ij,{scope:n,value:s,disabled:a,textId:p,isSelected:u,onItemTextChange:l.useCallback(w=>{h(N=>N||((w==null?void 0:w.textContent)??"").trim())},[]),children:r.jsx(oa.ItemSlot,{scope:n,value:s,disabled:a,textValue:d,children:r.jsx(G.div,{role:"option","aria-labelledby":p,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...c,ref:g,onFocus:D(c.onFocus,()=>x(!0)),onBlur:D(c.onBlur,()=>x(!1)),onClick:D(c.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:D(c.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:D(c.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:D(c.onPointerMove,w=>{var N;v.current=w.pointerType,a?(N=f.onItemLeave)==null||N.call(f):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:D(c.onPointerLeave,w=>{var N;w.currentTarget===document.activeElement&&((N=f.onItemLeave)==null||N.call(f))}),onKeyDown:D(c.onKeyDown,w=>{var j;((j=f.searchRef)==null?void 0:j.current)!==""&&w.key===" "||(yj.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Df.displayName=ks;var vr="SelectItemText",zf=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,c=Jt(vr,n),i=en(vr,n),f=Of(vr,n),u=Nj(vr,n),[d,h]=l.useState(null),m=de(t,y=>h(y),f.onItemTextChange,y=>{var w;return(w=i.itemTextRefCallback)==null?void 0:w.call(i,y,f.value,f.disabled)}),x=d==null?void 0:d.textContent,g=l.useMemo(()=>r.jsx("option",{value:f.value,disabled:f.disabled,children:x},f.value),[f.disabled,f.value,x]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=u;return Pe(()=>(p(g),()=>v(g)),[p,v,g]),r.jsxs(r.Fragment,{children:[r.jsx(G.span,{id:f.textId,...o,ref:m}),f.isSelected&&c.valueNode&&!c.valueNodeHasChildren?Ts.createPortal(o.children,c.valueNode):null]})});zf.displayName=vr;var Lf="SelectItemIndicator",Ff=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Of(Lf,n).isSelected?r.jsx(G.span,{"aria-hidden":!0,...s,ref:t}):null});Ff.displayName=Lf;var fo="SelectScrollUpButton",$f=l.forwardRef((e,t)=>{const n=en(fo,e.__scopeSelect),s=ui(fo,e.__scopeSelect),[a,o]=l.useState(!1),c=de(t,s.onScrollButtonChange);return Pe(()=>{if(n.viewport&&n.isPositioned){let i=function(){const u=f.scrollTop>0;o(u)};const f=n.viewport;return i(),f.addEventListener("scroll",i),()=>f.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),a?r.jsx(Vf,{...e,ref:c,onAutoScroll:()=>{const{viewport:i,selectedItem:f}=n;i&&f&&(i.scrollTop=i.scrollTop-f.offsetHeight)}}):null});$f.displayName=fo;var ho="SelectScrollDownButton",Uf=l.forwardRef((e,t)=>{const n=en(ho,e.__scopeSelect),s=ui(ho,e.__scopeSelect),[a,o]=l.useState(!1),c=de(t,s.onScrollButtonChange);return Pe(()=>{if(n.viewport&&n.isPositioned){let i=function(){const u=f.scrollHeight-f.clientHeight,d=Math.ceil(f.scrollTop)<u;o(d)};const f=n.viewport;return i(),f.addEventListener("scroll",i),()=>f.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),a?r.jsx(Vf,{...e,ref:c,onAutoScroll:()=>{const{viewport:i,selectedItem:f}=n;i&&f&&(i.scrollTop=i.scrollTop+f.offsetHeight)}}):null});Uf.displayName=ho;var Vf=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=en("SelectScrollButton",n),c=l.useRef(null),i=ia(n),f=l.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return l.useEffect(()=>()=>f(),[f]),Pe(()=>{var d;const u=i().find(h=>h.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[i]),r.jsx(G.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:D(a.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:D(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:D(a.onPointerLeave,()=>{f()})})}),Oj="SelectSeparator",Bf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(G.div,{"aria-hidden":!0,...s,ref:t})});Bf.displayName=Oj;var mo="SelectArrow",Dj=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=ca(n),o=Jt(mo,n),c=en(mo,n);return o.open&&c.position==="popper"?r.jsx($o,{...a,...s,ref:t}):null});Dj.displayName=mo;var zj="SelectBubbleInput",Kf=l.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=l.useRef(null),o=de(s,a),c=gu(t);return l.useEffect(()=>{const i=a.current;if(!i)return;const f=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(f,"value").set;if(c!==t&&d){const h=new Event("change",{bubbles:!0});d.call(i,t),i.dispatchEvent(h)}},[c,t]),r.jsx(G.select,{...n,style:{...yf,...n.style},ref:o,defaultValue:t})});Kf.displayName=zj;function qf(e){return e===""||e===void 0}function Hf(e){const t=dt(e),n=l.useRef(""),s=l.useRef(0),a=l.useCallback(c=>{const i=n.current+c;t(i),(function f(u){n.current=u,window.clearTimeout(s.current),u!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(i)},[t]),o=l.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function Wf(e,t,n){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let c=Lj(e,Math.max(o,0));a.length===1&&(c=c.filter(u=>u!==n));const f=c.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function Lj(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Fj=bf,Gf=jf,$j=Cf,Uj=Sf,Vj=Ef,Qf=Rf,Bj=Af,Yf=If,Xf=Df,Kj=zf,qj=Ff,Zf=$f,Jf=Uf,eh=Bf;const Er=Fj,Rr=$j,Zn=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Gf,{ref:s,className:T("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(Uj,{asChild:!0,children:r.jsx(el,{className:"h-4 w-4 opacity-50 shrink-0"})})]}));Zn.displayName=Gf.displayName;const th=l.forwardRef(({className:e,...t},n)=>r.jsx(Zf,{ref:n,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(zp,{className:"h-4 w-4"})}));th.displayName=Zf.displayName;const nh=l.forwardRef(({className:e,...t},n)=>r.jsx(Jf,{ref:n,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(el,{className:"h-4 w-4"})}));nh.displayName=Jf.displayName;const Jn=l.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>r.jsx(Vj,{children:r.jsxs(Qf,{ref:a,className:T("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(th,{}),r.jsx(Bj,{className:T("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(nh,{})]})}));Jn.displayName=Qf.displayName;const Hj=l.forwardRef(({className:e,...t},n)=>r.jsx(Yf,{ref:n,className:T("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",e),...t}));Hj.displayName=Yf.displayName;const He=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Xf,{ref:s,className:T("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(qj,{children:r.jsx(St,{className:"h-4 w-4"})})}),r.jsx(Kj,{children:t})]}));He.displayName=Xf.displayName;const Wj=l.forwardRef(({className:e,...t},n)=>r.jsx(eh,{ref:n,className:T("-mx-1 my-1 h-px bg-zinc-100",e),...t}));Wj.displayName=eh.displayName;function rh({orderId:e,orderNumber:t,open:n,onOpenChange:s}){const[a,o]=l.useState(""),[c,i]=l.useState(""),[f,u]=l.useState(null),d=l.useRef(!1),[h,m]=l.useState(!1),x=ix();l.useEffect(()=>{n&&u(null)},[n]);const g=a.trim()!==""&&c.trim()!=="",p=()=>{o(""),i(""),u(null),s(!1)},v=async()=>{if(!(!g||d.current)){d.current=!0,m(!0),u(null);try{await x.mutateAsync({orderId:e,carrier:a.trim(),trackingNumber:c.trim()}),p()}catch(y){u(y instanceof Re?y.message:"The order could not be shipped.")}finally{d.current=!1,m(!1)}}};return r.jsx(Gs,{open:n,onOpenChange:y=>y?s(!0):p(),children:r.jsxs(Ur,{className:"max-w-md","data-testid":P("order","ship-dialog"),children:[r.jsx(Qs,{children:r.jsxs(Vr,{children:["Ship Order #",t]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"ship-carrier",children:"Carrier"}),r.jsx(pe,{id:"ship-carrier",value:a,onChange:y=>o(y.target.value),"data-testid":P("order","ship-carrier")})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"ship-tracking",children:"Tracking number"}),r.jsx(pe,{id:"ship-tracking",value:c,onChange:y=>i(y.target.value),"data-testid":P("order","ship-tracking")})]}),f&&r.jsx("p",{role:"alert",className:"text-sm text-red-600","data-testid":P("order","ship-error"),children:f})]}),r.jsxs(Ys,{children:[r.jsx(se,{variant:"outline",type:"button",onClick:p,"data-testid":P("order","ship-cancel"),children:"Cancel"}),r.jsx(se,{type:"button",onClick:()=>void v(),disabled:!g||h,"data-testid":P("order","ship-submit"),children:h?"Shipping...":"Ship order"})]})]})})}const os="record-payment",Pa={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Partially Refunded"},Gj={confirmed:"confirm",processing:"process",delivered:"mark-delivered",cancelled:"cancel"};function Qj(e,t,n){return fm(e,n).filter(s=>s!=="refunded"&&s!=="partially_refunded"&&s!=="confirmed"&&!(s==="cancelled"&&t>0))}function Yj({orderId:e,currentStatus:t,orderNumber:n,capturedMinor:s,statusBeforePartialRefund:a=null}){const o=ye(),{mutateAsync:c,isPending:i}=sx(),{mutateAsync:f,isPending:u}=ul(),[d,h]=l.useState(null),[m,x]=l.useState(null),[g,p]=l.useState(!1),v=Qj(t,s,a),y=t==="pending"&&s===0,w=d??t,N=i||u,j=v.length===0&&!y,S=async C=>{if(x(null),C==="shipped"){p(!0);return}const E=C===os?"confirmed":C;h(E);try{C===os?await f({orderId:e}):await c({orderId:e,action:Gj[E]??E})}catch(k){x(k instanceof Re?k.message:"The status could not be changed."),h(null),o.invalidateQueries({queryKey:["orders","detail",n]})}};return r.jsxs(r.Fragment,{children:[j?r.jsx("span",{className:"text-sm text-zinc-500 font-medium capitalize",children:Pa[t]}):r.jsxs(Er,{value:w,onValueChange:C=>void S(C),disabled:N,children:[r.jsx(Zn,{className:T("w-44 h-8 text-xs",N&&"opacity-50"),"aria-label":"Order status","data-testid":P("order","status-select"),children:r.jsx(Rr,{})}),r.jsxs(Jn,{children:[r.jsxs(He,{value:t,disabled:!0,"data-testid":P("order","status-option",t),children:[Pa[t]," (current)"]}),y&&r.jsx(He,{value:os,"data-testid":P("order","status-option",os),children:"Record payment"}),v.map(C=>r.jsx(He,{value:C,"data-testid":P("order","status-option",C),children:Pa[C]},C))]})]}),m&&r.jsx("span",{role:"alert",className:"text-xs text-red-600","data-testid":P("order","status-error"),children:m}),r.jsx(rh,{orderId:e,orderNumber:n,open:g,onOpenChange:p})]})}function Xj({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":P("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(Xn,{status:n.fromStatus,size:"sm"}),r.jsx("span",{className:"text-zinc-400 text-xs",children:"→"})]}),r.jsx(Xn,{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:Oe(n.timestamp),children:ht(n.timestamp)})]})]})]})]})},n.id))})})}const Kt=l.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{className:T("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}));Kt.displayName="Textarea";function Zj({orderId:e,notes:t}){const[n,s]=l.useState(""),a=dx(),o=async c=>{c.preventDefault(),n.trim()&&(await a.mutateAsync({orderId:e,body:n.trim()}),s(""))};return r.jsxs("div",{"data-testid":P("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((c,i)=>new Date(i.at).getTime()-new Date(c.at).getTime()).map((c,i)=>r.jsx(Jj,{note:c},i))}),r.jsxs("form",{onSubmit:c=>void o(c),className:"mt-4 flex gap-2",children:[r.jsx(Kt,{placeholder:"Add an internal note...",value:n,onChange:c=>s(c.target.value),rows:2,className:"flex-1 text-sm",onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),o(c))}}),r.jsx(se,{type:"submit",size:"icon","aria-label":"Add note",disabled:!n.trim()||a.isPending,className:"self-end h-9 w-9",children:r.jsx(al,{className:"h-4 w-4"})})]})]})}function Jj({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:Oe(e.at),children:ht(e.at)})]})]})}function eN(e,t){if(!(e instanceof Re))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 ${ue(n,t)} is more than the ${ue(s,t)} left to refund.`:e.message}function tN({order:e,onClose:t}){const{refundableMinor:n,currency:s}=e.payment,[a,o]=l.useState((n/100).toFixed(2)),[c,i]=l.useState(""),[f,u]=l.useState(null),[d,h]=l.useState(()=>crypto.randomUUID()),m=l.useRef(!1),[x,g]=l.useState(!1),p=cx(),v=sb(a),y=v!==null&&v>0&&v<=n,w=async()=>{if(!(!y||v===null||m.current)){m.current=!0,g(!0),u(null);try{if((await p.mutateAsync({orderId:e.id,amountMinor:v,requestId:d,...c.trim()&&{reason:c.trim()}})).refund.status==="failed"){h(crypto.randomUUID()),u("The payment provider refused the refund.");return}t()}catch(N){u(eN(N,s))}finally{m.current=!1,g(!1)}}};return r.jsx(Gs,{open:!0,onOpenChange:N=>!N&&t(),children:r.jsxs(Ur,{className:"max-w-md","data-testid":P("order","refund-dialog"),children:[r.jsx(Qs,{children:r.jsxs(Vr,{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:ue(n,s)})]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Ee,{htmlFor:"refund-amount",children:["Amount (",s,")"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pe,{id:"refund-amount",inputMode:"decimal",value:a,onChange:N=>o(N.target.value),"aria-invalid":!y,"data-testid":P("order","refund-amount")}),r.jsx(se,{variant:"outline",type:"button",onClick:()=>o((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 ",ue(n,s),"."]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"refund-reason",children:"Reason (optional)"}),r.jsx(Kt,{id:"refund-reason",placeholder:"Enter refund reason...",value:c,onChange:N=>i(N.target.value),rows:3,"data-testid":P("order","refund-reason")})]}),f&&r.jsx("p",{role:"alert",className:"text-sm text-red-600",children:f})]}),r.jsxs(Ys,{children:[r.jsx(se,{variant:"outline",type:"button",onClick:t,children:"Cancel"}),r.jsx(se,{variant:"destructive",type:"button",onClick:()=>void w(),disabled:!y||x,"data-testid":P("order","refund-confirm"),children:x?"Processing...":`Refund ${v!==null?ue(v,s):""}`})]})]})})}const nN=50;function rN(e,t){return Co({queryKey:["history",e,t],initialPageParam:void 0,queryFn:({pageParam:n})=>W.get(`/api/admin/${e}/${encodeURIComponent(t)}/history`,{limit:nN,cursor:n}),getNextPageParam:n=>n.nextCursor??void 0,enabled:t!==""})}function sN(e,t){return Ce({queryKey:["history","as-of",e,t],queryFn:()=>W.get(e,{at:t}),enabled:t!==null,retry:!1})}function po(e){return e==null?"—":typeof e=="object"?JSON.stringify(e):String(e)}function aN({seq:e,change:t}){return r.jsxs("li",{className:"font-mono text-xs text-zinc-600 break-all","data-testid":`history-change-${e}-${t.path}`,children:[r.jsxs("span",{className:"text-zinc-400",children:[t.path,": "]}),r.jsx("span",{className:"text-red-700",children:po(t.from)}),r.jsx("span",{className:"text-zinc-400",children:" → "}),r.jsx("span",{className:"text-green-700",children:po(t.to)})]})}function oN({entry:e,onAsOf:t}){return r.jsxs("li",{className:"py-3 space-y-1.5","data-testid":`history-row-${e.seq}`,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[r.jsx("time",{dateTime:e.at,className:"text-zinc-500",children:Oe(e.at)}),r.jsx("span",{className:"font-mono text-zinc-800",children:e.type}),r.jsx("span",{className:"font-mono text-zinc-500","data-testid":`history-row-${e.seq}-actor`,children:e.actor===null?"system":`${e.actor.kind}:${e.actor.id}`}),r.jsx("span",{className:"font-mono text-zinc-500","data-testid":`history-row-${e.seq}-command`,children:e.command??""}),r.jsx(se,{type:"button",variant:"outline",size:"sm",className:"ml-auto h-6 px-2 text-xs",onClick:()=>t(e.at),"data-testid":`history-as-of-${e.seq}`,children:"View as of"})]}),e.base?r.jsx("p",{className:"text-xs text-zinc-400",children:"The earliest state the event log holds."}):r.jsx("ul",{className:"space-y-0.5",children:e.changes.map(n=>r.jsx(aN,{seq:e.seq,change:n},n.path))})]})}function iN({detailPath:e,at:t,onClose:n}){const{data:s,error:a,isLoading:o}=sN(e,t);return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3 space-y-2","data-testid":"history-as-of-panel",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("h4",{className:"text-xs font-semibold text-zinc-700",children:["As of ",Oe(t)]}),r.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:n,children:r.jsx(Yt,{className:"h-3.5 w-3.5"})})]}),o?r.jsx(xe,{className:"h-24 w-full"}):a?r.jsx("p",{className:"text-xs text-red-600",children:a instanceof Re?a.message:"The record could not be read as of then."}):s?r.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:Object.entries(s.record).map(([c,i])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"text-zinc-400",children:c}),r.jsx("dd",{className:"font-mono text-zinc-700 break-all","data-testid":`history-as-of-field-${c}`,children:po(i)})]},c))}):null]})}function fi({collection:e,id:t,detailPath:n}){const{data:s,isLoading:a,isError:o,hasNextPage:c,fetchNextPage:i,isFetchingNextPage:f}=rN(e,t),[u,d]=l.useState(null);if(a)return r.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((x,g)=>r.jsx(xe,{className:"h-10 w-full"},g))});if(o||!s)return r.jsx(Ge,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"History could not be loaded"});const h=s.pages[0];if(h.historyStartsAt===null)return r.jsxs("p",{className:"py-4 text-center text-sm text-zinc-500","data-testid":"history-empty",children:["This record predates the event log’s window: the log keeps ",h.retentionDays," days of changes (events.retentionDays), so its earlier history is no longer held."]});const m=s.pages.flatMap(x=>x.entries);return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{className:"text-xs text-zinc-400",children:["From ",Oe(h.historyStartsAt),": the event log keeps ",h.retentionDays," days of changes."]}),u!==null&&r.jsx(iN,{detailPath:n,at:u,onClose:()=>d(null)}),r.jsx("ul",{className:"divide-y divide-zinc-100",children:m.map(x=>r.jsx(oN,{entry:x,onAsOf:d},x.seq))}),c&&r.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>void i(),disabled:f,children:f?"Loading…":"Load more"})]})}const cN=["pending","cancelled"],lN={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"},dN={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"},uN={provider:"Payment provider",manual:"Recorded manually",import:"Imported"};function fN(e){return e==="storefront"?"Storefront":e==="import"?"Imported":`Agent · ${e.slice(6)}`}const hN={pending:"Refund pending",succeeded:"Refunded",failed:"Failed"};function mN({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:T("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",dN[t.state]),"data-testid":P("order","payment-state"),children:lN[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":P("order","captured"),children:ue(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":P("order","refunded"),children:ue(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":P("order","net"),children:ue(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:uN[e.captureMethod]})]}),r.jsxs("div",{className:"flex justify-between gap-3",children:[r.jsx("dt",{className:"text-zinc-500",children:"Source"}),r.jsx("dd",{className:"truncate text-zinc-700","data-testid":P("order","source"),"data-source":e.source,children:fN(e.source)})]}),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":P("order","refund-row",n.id),children:[r.jsxs("span",{className:"text-zinc-500",children:[hN[n.status]," · ",Oe(n.createdAt)]}),r.jsx("span",{className:"font-mono text-zinc-700",children:ue(n.amountMinor,n.currency)})]},n.id))})]})}function pc({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 pN(){const{orderNumber:e}=vo(),[t,n]=l.useState(!1),[s,a]=l.useState(!1),[o,c]=l.useState(null),i=l.useRef(!1),[f,u]=l.useState(!1),{data:d,isLoading:h}=dl(e??""),{data:m=[]}=rx((d==null?void 0:d.id)??""),x=ul(),g=ax(),p=ox(),v=lx(),y=async C=>{if(!i.current){i.current=!0,u(!0),c(null);try{await C()}catch(E){c(E instanceof Re?E.message:"The order could not be updated.")}finally{i.current=!1,u(!1)}}};if(h)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{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(xe,{className:"h-48 w-full"}),r.jsx(xe,{className:"h-32 w-full"})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsx(xe,{className:"h-40 w-full"}),r.jsx(xe,{className:"h-48 w-full"})]})]})]});if(!d)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(qt,{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(Ve,{to:"/orders",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to orders"})]});const N=d.status==="pending"&&d.payment.capturedMinor===0?{label:"Record payment",icon:Ri,action:()=>void y(()=>x.mutateAsync({orderId:d.id}))}:d.status==="processing"?{label:"Mark Shipped",icon:il,action:()=>a(!0)}:d.status==="shipped"?{label:"Mark Delivered",icon:Ri,action:()=>void y(()=>p.mutateAsync(d.id))}:null,j=cN.includes(d.status)||v.isPending,S=v.isError?v.error.message:v.data?`Confirmation queued to ${v.data.email}`:null;return r.jsxs("div",{className:"space-y-4","data-testid":P("order","detail"),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(Ve,{to:"/orders",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700 transition-colors",children:[r.jsx(Eo,{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:["#",d.orderNumber]}),r.jsx(Xn,{status:d.status,"data-testid":P("order","status-badge")})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o!==null&&r.jsx("span",{role:"alert",className:"text-xs text-red-600","data-testid":P("order","action-error"),children:o}),S!==null&&r.jsx("span",{role:"status",className:"text-xs text-zinc-500","data-testid":P("order","resend-result"),children:S}),N&&r.jsxs(se,{size:"sm",onClick:N.action,disabled:f,className:"gap-1.5","data-testid":P("order","primary-action"),children:[r.jsx(N.icon,{className:"h-4 w-4"}),N.label]}),r.jsxs(li,{children:[r.jsx(di,{asChild:!0,children:r.jsx(se,{variant:"outline",size:"sm","data-testid":P("order","actions"),children:"Actions"})}),r.jsxs(sa,{align:"end",className:"w-44",children:[r.jsxs(bt,{onSelect:()=>{j||v.mutate({orderId:d.id})},className:"gap-2",disabled:j,"data-testid":P("order","action","resend-confirmation"),children:[r.jsx(sl,{className:"h-4 w-4"}),"Resend confirmation"]}),r.jsx(aa,{}),d.payment.refundableMinor>0&&r.jsxs(bt,{onClick:()=>n(!0),className:"gap-2","data-testid":P("order","action","refund"),children:[r.jsx(Up,{className:"h-4 w-4"}),"Issue refund"]}),r.jsxs(bt,{onClick:()=>void y(()=>g.mutateAsync({orderId:d.id})),className:"gap-2 text-red-600","data-testid":P("order","action","cancel"),disabled:d.payment.capturedMinor>0||["cancelled","refunded","delivered"].includes(d.status),children:[r.jsx(Lp,{className:"h-4 w-4"}),"Cancel order"]})]})]})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Pi,{className:"h-3.5 w-3.5"}),"Placed ",Oe(d.createdAt)]}),r.jsx("span",{className:"text-zinc-300",children:"·"}),r.jsx(Yj,{orderId:d.id,currentStatus:d.status,orderNumber:d.orderNumber,capturedMinor:d.payment.capturedMinor,statusBeforePartialRefund:um(d.history??[])})]}),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 (",d.lineItems.length,")"]})}),r.jsx("div",{className:"divide-y divide-zinc-50",children:d.lineItems.map(C=>r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[C.imageUrl?r.jsx("img",{src:C.imageUrl,alt:C.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(qt,{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:C.productName}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[C.variantName," · ",C.sku]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("p",{className:"font-mono text-sm text-zinc-700",children:ue(C.lineTotalMinor,d.currency)}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[C.qty," × ",ue(C.unitPriceMinor,d.currency)]})]})]},C.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:ue(d.subtotalMinor,d.currency)})]}),d.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:ue(d.taxTotalMinor,d.currency)})]}),d.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:ue(d.shippingTotalMinor,d.currency)})]}),d.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:["-",ue(d.discountTotalMinor,d.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:ue(d.totalMinor,d.currency)})]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:r.jsxs(Kr,{defaultValue:"notes",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-2",children:r.jsxs(or,{className:"h-8",children:[r.jsxs(Ae,{value:"notes",className:"gap-1.5 text-xs",children:[r.jsx(Xp,{className:"h-3.5 w-3.5"}),"Notes",m.length>0&&r.jsx("span",{className:"rounded-full bg-zinc-100 px-1.5 text-[10px]",children:m.length})]}),r.jsxs(Ae,{value:"timeline",className:"gap-1.5 text-xs","data-testid":P("order","tab","timeline"),children:[r.jsx(Pi,{className:"h-3.5 w-3.5"}),"Timeline"]}),r.jsxs(Ae,{value:"history",className:"gap-1.5 text-xs","data-testid":P("order","tab","history"),children:[r.jsx(Wn,{className:"h-3.5 w-3.5"}),"History"]})]})}),r.jsx(Ue,{value:"notes",className:"p-4",children:r.jsx(Zj,{orderId:d.id,notes:m})}),r.jsx(Ue,{value:"timeline",className:"p-4",children:d.history&&d.history.length>0?r.jsx(Xj,{entries:d.history}):r.jsx("p",{className:"text-sm text-zinc-400 text-center py-4",children:"No history yet."})}),r.jsx(Ue,{value:"history",className:"p-4",children:r.jsx(fi,{collection:"orders",id:d.id,detailPath:`/api/admin/orders/${encodeURIComponent(d.orderNumber)}`})})]})})]}),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 shrink-0 items-center justify-center rounded-full bg-zinc-100 text-sm font-semibold text-zinc-600",children:(d.email[0]??"?").toUpperCase()}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800 [overflow-wrap:anywhere]",children:d.email}),d.customerId&&r.jsx(Ve,{to:`/customers/${d.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(pc,{address:d.shippingAddress,label:"Shipping"}),r.jsx(pc,{address:d.billingAddress,label:"Billing"})]})]}),r.jsx(mN,{order:d}),d.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:d.notes})]})]})]}),t&&r.jsx(tN,{order:d,onClose:()=>n(!1)}),r.jsx(rh,{orderId:d.id,orderNumber:d.orderNumber,open:s,onOpenChange:a})]})}const xN={breadcrumb:e=>`#${e.orderNumber??""}`},gN=_s("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 sh({className:e,variant:t,...n}){return r.jsx("div",{className:T(gN({variant:t}),e),...n})}function vN(e={}){return Ce({queryKey:["products","list",e],queryFn:()=>W.get("/api/admin/products",e)})}function yN(e){return Ce({queryKey:["products","detail",e],queryFn:()=>W.get(`/api/admin/products/${e}`),enabled:!!e&&e!=="new"})}function bN(){const e=ye();return we({mutationFn:({product:t,idempotencyKey:n})=>W.post("/api/admin/products",t,n===void 0?void 0:{idempotencyKey:n}),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function wN(){const e=ye();return we({mutationFn:({id:t,data:n,idempotencyKey:s})=>W.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 jN(){const e=ye();return we({mutationFn:t=>W.post(`/api/admin/products/${t}/duplicate`),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function NN(){const e=ye();return we({mutationFn:t=>W.post(`/api/admin/products/${t}/archive`),onSuccess:()=>{e.invalidateQueries({queryKey:["products"]})}})}function CN(){return we({mutationFn:({id:e,field:t,context:n})=>W.post(`/api/admin/products/${e}/enhance`,{field:t,context:n})})}const SN=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Draft",value:"draft"},{label:"Archived",value:"archived"}],EN={active:"success",draft:"default",archived:"secondary"};function RN(){const e=Ct(),[t,n]=l.useState("all"),[s,a]=l.useState(""),{data:o,isLoading:c}=vN({status:t==="all"?void 0:t,q:s||void 0,limit:100}),i=jN(),f=NN();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:o?`${o.length} products`:"Loading..."})]}),r.jsxs(se,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(wr,{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:SN.map(u=>r.jsx("button",{onClick:()=>n(u.value),className:T("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===u.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:u.label},u.value))}),r.jsxs("div",{className:"relative flex-1 sm:max-w-xs sm:ml-auto",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search products...",value:s,onChange:u=>a(u.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:6}).map((u,d)=>r.jsx(xe,{className:"h-11 w-full"},d))}):o!=null&&o.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Ke,{children:[r.jsx(ne,{className:"w-12",children:"Image"}),r.jsx(ne,{children:"Name"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Type"}),r.jsx(ne,{className:"text-right",children:"Price"}),r.jsx(ne,{children:"Stock"}),r.jsx(ne,{className:"text-right",children:"Updated"}),r.jsx(ne,{className:"w-10"})]})}),r.jsx(Nn,{children:o.map(u=>{const d=u.media[0],h=u.variants[0],m=u.variants.reduce((p,v)=>p+v.stock,0),x=u.variants.some(p=>p.stock<=p.lowStockThreshold),g=u.variants.some(p=>p.stock===0);return r.jsxs(Ke,{"data-testid":P("products","row",u.id),className:"cursor-pointer",onClick:()=>e(`/products/${u.slug}`),children:[r.jsx(re,{children:d?r.jsx("img",{src:d.url,alt:d.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(qt,{className:"h-3.5 w-3.5 text-zinc-300"})})}),r.jsx(re,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-zinc-800",children:u.name}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:u.slug})]})}),r.jsx(re,{children:r.jsx(sh,{variant:EN[u.status],className:"capitalize",children:u.status})}),r.jsx(re,{className:"text-xs text-zinc-500 capitalize",children:u.type}),r.jsx(re,{className:"text-right font-mono text-sm",children:h?ue(h.priceMinor,"GBP"):"—"}),r.jsx(re,{children:r.jsx("span",{className:T("text-sm font-mono font-medium",g?"text-red-600":x?"text-amber-600":"text-zinc-700"),children:m})}),r.jsx(re,{className:"text-right text-xs text-zinc-400",children:ht(u.updatedAt)}),r.jsx(re,{onClick:p=>p.stopPropagation(),children:r.jsxs(li,{children:[r.jsx(di,{asChild:!0,children:r.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-zinc-400 opacity-0 group-hover:opacity-100",children:r.jsx(rl,{className:"h-4 w-4"})})}),r.jsxs(sa,{align:"end",children:[r.jsx(bt,{onClick:()=>e(`/products/${u.slug}`),children:"Edit"}),r.jsxs(bt,{onClick:()=>void i.mutateAsync(u.id),className:"gap-2",children:[r.jsx($p,{className:"h-3.5 w-3.5"}),"Duplicate"]}),r.jsx(aa,{}),r.jsxs(bt,{onClick:()=>void f.mutateAsync(u.id),className:"gap-2 text-zinc-500",children:[r.jsx(Mp,{className:"h-3.5 w-3.5"}),"Archive"]})]})]})})]},u.id)})})]}):r.jsx(Ge,{icon:r.jsx(qt,{className:"h-5 w-5"}),title:"No products found",description:s?"Try a different search.":"Create your first product.",action:r.jsxs(se,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(wr,{className:"h-4 w-4"}),"Add Product"]})})})]})}const PN={breadcrumb:()=>"Products"};function kN(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 TN({productId:e,variants:t,onChange:n,currency:s,existing:a=!1}){const[o,c]=l.useState(t.map(d=>({...d,_priceDisplay:(d.priceMinor/100).toFixed(2)}))),i=(d,h,m)=>{c(x=>{const g=x.map(p=>{if(p.id!==d)return p;if(h==="_priceDisplay"){const v=parseFloat(m);return{...p,_priceDisplay:m,priceMinor:isNaN(v)?p.priceMinor:Math.round(v*100)}}return{...p,[h]:m}});return n(g.map(({_priceDisplay:p,...v})=>v)),g})},f=()=>{const d=kN(e),h=[...o,{...d,_priceDisplay:"0.00"}];c(h),n(h.map(({_priceDisplay:m,...x})=>x))},u=d=>{const h=o.filter(m=>m.id!==d);c(h),n(h.map(({_priceDisplay:m,...x})=>x))};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:a?"No variants.":"No variants yet. Add one below."})}),o.map(d=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0","data-testid":P("product","variant-row",d.id),children:[r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"font-mono text-xs",children:d.sku}):r.jsx(pe,{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:a?r.jsx("span",{className:"text-xs",children:d.name}):r.jsx(pe,{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(pe,{value:d._priceDisplay,onChange:h=>i(d.id,"_priceDisplay",h.target.value),"data-testid":P("product","variant-price",d.id),onBlur:h=>{const m=parseFloat(h.target.value);isNaN(m)||i(d.id,"_priceDisplay",m.toFixed(2))},className:"h-7 w-20 text-right font-mono text-xs"})]})}),r.jsx("td",{className:"px-3 py-2 text-right",children:a?r.jsx(Ve,{to:`/inventory?q=${encodeURIComponent(d.sku)}`,"data-testid":P("product","variant-stock",d.id),title:"Adjust stock in Inventory",className:"font-mono text-xs text-zinc-700 underline underline-offset-2 hover:text-zinc-900",children:d.stock}):r.jsx(pe,{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:a?r.jsx("span",{className:"text-xs capitalize",children:d.status}):r.jsxs(Er,{value:d.status,onValueChange:h=>i(d.id,"status",h),children:[r.jsx(Zn,{className:"h-7 w-24 text-xs",children:r.jsx(Rr,{})}),r.jsxs(Jn,{children:[r.jsx(He,{value:"active",children:"Active"}),r.jsx(He,{value:"inactive",children:"Inactive"})]})]})}),r.jsx("td",{className:"px-3 py-2",children:!a&&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(ol,{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)]})]}),!a&&r.jsxs(se,{variant:"outline",size:"sm",onClick:f,className:"gap-1.5",children:[r.jsx(wr,{className:"h-3.5 w-3.5"}),"Add Variant"]})]})]})}function AN({media:e,onChange:t}){const[n,s]=l.useState(""),[a,o]=l.useState(""),[c,i]=l.useState(!1),[f,u]=l.useState(null),d=()=>{if(!n.trim())return;const g=[...e,{url:n.trim(),altText:a.trim(),position:e.length}];t(g),s(""),o("")},h=g=>{const p=e.filter((v,y)=>y!==g).map((v,y)=>({...v,position:y}));t(p)},m=g=>{const p=e[g];if(!p)return;const v=[p,...e.filter((y,w)=>w!==g)].map((y,w)=>({...y,position:w}));t(v)},x=(g,p)=>{const v=e.map((y,w)=>w===g?{...y,altText:p}:y);t(v)};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((g,p)=>r.jsxs("div",{className:T("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:g.url?r.jsx("img",{src:g.url,alt:g.altText||"Product image",className:"h-full w-full object-cover",onError:v=>{v.target.style.display="none"}}):r.jsx(qp,{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(nx,{className:"h-3 w-3"})}),r.jsx("button",{onClick:()=>h(p),className:"rounded bg-white/90 p-1 text-red-600 hover:bg-white",title:"Remove",children:r.jsx(Yt,{className:"h-3 w-3"})})]}),r.jsx("div",{className:"border-t border-zinc-100 px-1.5 py-1",children:f===p?r.jsx("input",{autoFocus:!0,value:g.altText,onChange:v=>x(p,v.target.value),onBlur:()=>u(null),className:"w-full text-[10px] bg-transparent border-b border-zinc-300 outline-none",placeholder:"Alt text..."}):r.jsx("button",{onClick:()=>u(p),className:"w-full text-left text-[10px] text-zinc-400 hover:text-zinc-600 truncate",children:g.altText||"Add alt text"})})]},p))}),r.jsx("div",{className:T("rounded-md border-2 border-dashed p-4 transition-colors",c?"border-blue-400 bg-blue-50":"border-zinc-200"),onDragOver:g=>{g.preventDefault(),i(!0)},onDragLeave:()=>i(!1),onDrop:g=>{g.preventDefault(),i(!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(Ee,{className:"text-xs",children:"Image URL"}),r.jsx(pe,{value:n,onChange:g=>s(g.target.value),placeholder:"https://cdn.example.com/image.jpg",className:"text-xs h-8",onKeyDown:g=>g.key==="Enter"&&d()})]}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Ee,{className:"text-xs",children:"Alt Text"}),r.jsx(pe,{value:a,onChange:g=>o(g.target.value),placeholder:"Describe the image",className:"text-xs h-8",onKeyDown:g=>g.key==="Enter"&&d()})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(se,{type:"button",size:"sm",onClick:d,disabled:!n.trim(),className:"h-8 gap-1",children:[r.jsx(wr,{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 MN({title:e,description:t,url:n}){const o=e.length>60,c=t.length>155,i=o?e.slice(0,60)+"...":e,f=c?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:T("text-[17px] leading-snug text-blue-700 cursor-pointer hover:underline mb-1",!e&&"text-zinc-300 italic"),children:i||"Page title appears here"}),r.jsx("p",{className:T("text-sm leading-relaxed text-zinc-500",!t&&"text-zinc-300 italic"),children:f||"Meta description appears here..."})]})}),(o||c)&&r.jsxs("div",{className:"space-y-1.5",children:[o&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(ys,{className:"h-3.5 w-3.5 shrink-0"}),"Title is ",e.length," chars — Google shows ~60. Consider shortening."]}),c&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(ys,{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:T(o?"text-amber-500":"text-zinc-400"),children:["Title: ",e.length,"/",60]}),r.jsxs("span",{className:T(c?"text-amber-500":"text-zinc-400"),children:["Description: ",t.length,"/",155]})]})]})}function ka({productId:e,field:t,context:n,onApply:s,className:a}){const[o,c]=l.useState(null),i=CN(),f=async()=>{c(null);const h={};n.name&&(h.name=n.name),n.current&&(h.current=n.current);const m=await i.mutateAsync({id:e,field:t,context:h});c(m.suggestion)},u=()=>{o&&(s(o),c(null))},d=()=>{c(null)};return r.jsxs("div",{className:T("space-y-2",a),"data-testid":P("product","ai-enrich",t),children:[r.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:()=>void f(),disabled:i.isPending,className:"gap-1.5 text-xs text-purple-700 border-purple-200 hover:bg-purple-50 hover:border-purple-300",children:[r.jsx(Qa,{className:T("h-3.5 w-3.5",i.isPending&&"animate-spin")}),i.isPending?"Enhancing...":"Enhance with AI"]}),o&&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:o}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsxs(se,{type:"button",size:"sm",onClick:u,className:"gap-1.5 bg-purple-600 hover:bg-purple-700 text-white text-xs",children:[r.jsx(St,{className:"h-3.5 w-3.5"}),"Apply"]}),r.jsxs(se,{type:"button",variant:"ghost",size:"sm",onClick:d,className:"gap-1.5 text-zinc-500 text-xs",children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Dismiss"]})]})]})]})}const _N={name:"",slug:"",description:"",shortDescription:"",status:"draft",type:"simple",seoTitle:"",seoDescription:"",media:[],variants:[],categoryIds:[],metadata:{}};function IN(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function xc(){const{slug:e}=vo(),t=Ct(),n=!e||e==="new",{data:s,isLoading:a}=yN(n?"":e??""),o=bN(),c=wN(),[i,f]=l.useState(_N),[u,d]=l.useState(!1),[h,m]=l.useState(!1),[x,g]=Xt();l.useEffect(()=>{s&&f(s)},[s]);const p=(j,S)=>{d(!0),f(C=>{const E={...C,[j]:S};return j==="name"&&!h&&(E.slug=IN(S)),E})},v=async()=>{const j=x;if(g(),n){const S=await o.mutateAsync({product:i,idempotencyKey:j});t(`/products/${S.slug}`)}else if(s){const S=new Set(s.variants.map(k=>k.id)),C=(i.variants??[]).filter(k=>S.has(k.id)).map(({id:k,priceMinor:z,compareAtPriceMinor:O})=>({id:k,priceMinor:z,compareAtPriceMinor:O})),E={...i,variants:C};await c.mutateAsync({id:s.id,data:E,idempotencyKey:j}),d(!1)}},y=o.isPending||c.isPending;if(!n&&a)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-48"}),r.jsx(xe,{className:"h-96 w-full"})]});if(!n&&!s)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(qt,{className:"mb-3 h-8 w-8 text-zinc-300"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Product not found"}),r.jsx(Ve,{to:"/products",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to products"})]});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(Ve,{to:"/products",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(Eo,{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":i.name||"Edit Product"}),u&&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(se,{onClick:()=>void v(),disabled:y||!i.name,className:"gap-1.5","data-testid":P("product","save"),children:y?r.jsxs(r.Fragment,{children:[r.jsx(_r,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ex,{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(Kr,{defaultValue:"general",children:[r.jsxs(or,{className:"mb-4",children:[r.jsx(Ae,{value:"general",children:"General"}),r.jsx(Ae,{value:"variants","data-testid":P("product","tab","variants"),children:"Variants"}),r.jsx(Ae,{value:"media",children:"Media"}),r.jsx(Ae,{value:"seo",children:"SEO"}),s&&r.jsx(Ae,{value:"history","data-testid":P("product","tab","history"),children:"History"})]}),r.jsx(Ue,{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(Ee,{children:["Product Name ",r.jsx("span",{className:"text-red-500",children:"*"})]}),r.jsx(pe,{value:i.name??"",onChange:j=>p("name",j.target.value),placeholder:"e.g. Classic White T-Shirt","data-testid":P("product","name"),className:"text-base"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{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(pe,{value:i.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(Ee,{children:"Description"}),!n&&r.jsx(ka,{productId:w,field:"description",context:{...i.name?{name:i.name}:{},...i.description?{current:i.description}:{}},onApply:j=>p("description",j)})]}),r.jsx(Kt,{value:i.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(Ee,{children:"Short Description"}),r.jsx(Kt,{value:i.shortDescription??"",onChange:j=>p("shortDescription",j.target.value),placeholder:"Brief one-line description...",rows:2})]})]})}),r.jsx(Ue,{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(TN,{productId:w,variants:i.variants??[],onChange:j=>p("variants",j),currency:"GBP",existing:!n})]})}),r.jsx(Ue,{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(AN,{media:i.media??[],onChange:j=>p("media",j)})]})}),r.jsx(Ue,{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(Ee,{children:"SEO Title"}),!n&&r.jsx(ka,{productId:w,field:"title",context:i.name?{name:i.name}:{},onApply:j=>p("seoTitle",j),className:"scale-90 origin-right"})]}),r.jsx(pe,{value:i.seoTitle??"",onChange:j=>p("seoTitle",j.target.value),placeholder:i.name??"SEO title..."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"SEO Description"}),!n&&r.jsx(ka,{productId:w,field:"seoDescription",context:{...i.name?{name:i.name}:{},...i.seoDescription?{current:i.seoDescription}:{}},onApply:j=>p("seoDescription",j),className:"scale-90 origin-right"})]}),r.jsx(Kt,{value:i.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(MN,{title:i.seoTitle||i.name||"",description:i.seoDescription||i.shortDescription||"",url:`https://yourstore.com/products/${i.slug??""}`})]})]})}),s&&r.jsx(Ue,{value:"history",children:r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(fi,{collection:"products",id:s.id,detailPath:`/api/admin/products/${encodeURIComponent(s.id)}`})})})]})}),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(Er,{value:i.status??"draft",onValueChange:j=>p("status",j),children:[r.jsx(Zn,{"data-testid":P("product","status"),children:r.jsx(Rr,{})}),r.jsxs(Jn,{children:[r.jsx(He,{value:"draft",children:"Draft"}),r.jsx(He,{value:"active",children:"Active"}),r.jsx(He,{value:"archived",children:"Archived"})]})]}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[i.status==="draft"&&"Not visible to customers.",i.status==="active"&&"Visible and purchasable.",i.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(Er,{value:i.type??"simple",onValueChange:j=>p("type",j),children:[r.jsx(Zn,{children:r.jsx(Rr,{})}),r.jsxs(Jn,{children:[r.jsx(He,{value:"simple",children:"Simple"}),r.jsx(He,{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,S)=>j+S.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 ON={breadcrumb:e=>"Edit"},DN={breadcrumb:()=>"New Product"},zN=[{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 LN({row:e,onAdjust:t}){const[n,s]=l.useState(0),[a,o]=l.useState("manual"),[c,i]=l.useState(!1),[f,u]=Xt(),d=()=>{n!==0&&(t(n,a,f),u(),s(0),i(!0),setTimeout(()=>i(!1),1500))};return r.jsxs("div",{className:"flex items-center gap-2","data-testid":P("inventory","adjust",e.variantId),children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>s(h=>h-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(Zp,{className:"h-3 w-3"})}),r.jsx("input",{type:"number",value:n,onChange:h=>s(parseInt(h.target.value)||0),className:T("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(h=>h+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(wr,{className:"h-3 w-3"})})]}),r.jsxs(Er,{value:a,onValueChange:h=>o(h),children:[r.jsx(Zn,{className:"h-7 w-28 text-xs",children:r.jsx(Rr,{})}),r.jsx(Jn,{children:zN.map(h=>r.jsx(He,{value:h.value,children:h.label},h.value))})]}),r.jsx(se,{size:"sm",variant:c?"secondary":"default",className:"h-7 px-2 text-xs gap-1",onClick:d,disabled:n===0||c,children:c?r.jsxs(r.Fragment,{children:[r.jsx(St,{className:"h-3 w-3 text-green-600"}),r.jsx("span",{className:"text-green-600",children:"Done"})]}):"Apply"})]})}const FN=qo,$N=Ho,ah=l.forwardRef(({className:e,...t},n)=>r.jsx(qs,{className:T("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}));ah.displayName="SheetOverlay";const UN=_s("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"}}),oh=l.forwardRef(({side:e="right",className:t,children:n,...s},a)=>r.jsxs($N,{children:[r.jsx(ah,{}),r.jsxs(Hs,{ref:a,className:T(UN({side:e}),"border-zinc-200",t),...s,children:[n,r.jsxs(Td,{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(Yt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));oh.displayName="SheetContent";const ih=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col space-y-2 text-left",e),...t});ih.displayName="SheetHeader";const ch=l.forwardRef(({className:e,...t},n)=>r.jsx(Wo,{ref:n,className:T("text-lg font-semibold text-zinc-900",e),...t}));ch.displayName="SheetTitle";const VN=l.forwardRef(({className:e,...t},n)=>r.jsx(Go,{ref:n,className:T("text-sm text-zinc-500",e),...t}));VN.displayName="SheetDescription";function BN(e={}){return Ce({queryKey:["inventory","list",e],queryFn:()=>W.get("/api/admin/inventory",e)})}function KN(e){return Ce({queryKey:["inventory","history",e],queryFn:()=>W.get(`/api/admin/inventory/${e}/history`),enabled:!!e})}function qN(){const e=ye();return we({mutationFn:({variantId:t,delta:n,reason:s,idempotencyKey:a})=>W.post(`/api/admin/inventory/${t}/adjust`,{delta:n,reason:s},a===void 0?void 0:{idempotencyKey:a}),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(a=>a.variantId===t?{...a,stock:Math.max(0,a.stock+n)}:a)),{previousData:s}},onError:(t,n,s)=>{s!=null&&s.previousData&&e.setQueryData(["inventory","list",{}],s.previousData)},onSuccess:()=>{e.invalidateQueries({queryKey:["inventory"]})}})}function HN({variantId:e,productName:t,sku:n,onClose:s}){const{data:a,isLoading:o}=KN(e);return r.jsx(FN,{open:!0,onOpenChange:c=>!c&&s(),children:r.jsxs(oh,{className:"w-[480px] sm:max-w-[480px] overflow-y-auto",children:[r.jsxs(ih,{children:[r.jsx(ch,{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:o?r.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((c,i)=>r.jsx(xe,{className:"h-12 w-full"},i))}):!a||a.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:a.map(c=>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:Oe(c.timestamp)}),r.jsxs("td",{className:T("px-3 py-2 text-right font-mono text-sm font-medium",c.adjustment>0?"text-green-600":"text-red-600"),children:[c.adjustment>0?"+":"",c.adjustment]}),r.jsx("td",{className:"px-3 py-2 text-right font-mono text-sm text-zinc-700",children:c.newQty}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 capitalize",children:c.reason.replace(/-/g," ")}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500",children:c.actor})]},c.id))})]})})})]})})}const WN={in_stock:"success",low_stock:"warning",out_of_stock:"destructive"},gc={in_stock:"In Stock",low_stock:"Low Stock",out_of_stock:"Out of Stock"};function GN(){const[e]=Ac(),[t,n]=l.useState(()=>e.get("q")??""),[s,a]=l.useState("all"),[o,c]=l.useState(null),{data:i,isLoading:f}=BN({q:t||void 0,status:s==="all"?void 0:s,sort:"urgency",limit:200}),u=qN(),d=m=>(x,g,p)=>{u.mutateAsync({variantId:m,delta:x,reason:g,idempotencyKey:p})},h=m=>m==="out_of_stock"?"border-l-4 border-l-red-300":m==="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(m=>r.jsx("button",{onClick:()=>a(m),className:T("rounded-full px-3 py-1 text-xs font-medium transition-colors",s===m?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:m==="all"?"All":gc[m]},m))}),r.jsxs("div",{className:"relative ml-auto max-w-xs flex-1",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search SKU or product...",value:t,onChange:m=>n(m.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:f?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>r.jsx(xe,{className:"h-11 w-full"},x))}):i!=null&&i.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Ke,{children:[r.jsx(ne,{children:"Product"}),r.jsx(ne,{children:"SKU / Options"}),r.jsx(ne,{className:"text-right",children:"Stock"}),r.jsx(ne,{className:"text-right",children:"Threshold"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Adjust"}),r.jsx(ne,{className:"text-right",children:"History"})]})}),r.jsx(Nn,{children:i.map(m=>r.jsxs(Ke,{"data-testid":P("inventory","row",m.variantId),className:T("transition-colors",h(m.status)),children:[r.jsx(re,{children:r.jsx("p",{className:"font-medium text-zinc-800 text-sm",children:m.productName})}),r.jsx(re,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-mono text-xs text-zinc-500",children:m.sku}),m.options.length>0&&r.jsx("p",{className:"text-[10px] text-zinc-400",children:m.options.map(x=>`${x.name}: ${x.value}`).join(" · ")})]})}),r.jsx(re,{className:T("text-right font-mono text-base font-semibold",m.status==="out_of_stock"?"text-red-600":m.status==="low_stock"?"text-amber-600":"text-zinc-800"),children:m.stock}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-400",children:m.threshold}),r.jsx(re,{children:r.jsx(sh,{variant:WN[m.status],className:"text-[10px]",children:gc[m.status]})}),r.jsx(re,{children:r.jsx(LN,{row:m,onAdjust:d(m.variantId)})}),r.jsx(re,{className:"text-right",children:r.jsxs("button",{onClick:()=>c(m),className:"flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-700 font-medium ml-auto",children:[r.jsx(Wn,{className:"h-3.5 w-3.5"}),"History"]})})]},m.variantId))})]}):r.jsx(Ge,{icon:r.jsx(Jc,{className:"h-5 w-5"}),title:"No inventory found",description:"No variants match your filters."})}),o&&r.jsx(HN,{variantId:o.variantId,productName:o.productName,sku:o.sku,onClose:()=>c(null)})]})}const QN={breadcrumb:()=>"Inventory"};function YN(){const e=Ct(),[t,n]=l.useState(""),{data:s,isLoading:a}=db({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(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search by name or email...",value:t,onChange:o=>n(o.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:a?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((o,c)=>r.jsx(xe,{className:"h-11 w-full"},c))}):s!=null&&s.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Ke,{children:[r.jsx(ne,{children:"Customer"}),r.jsx(ne,{className:"text-right",children:"Orders"}),r.jsx(ne,{className:"text-right",children:"Total Spent"}),r.jsx(ne,{children:"Since"}),r.jsx(ne,{className:"text-right",children:"Last Order"})]})}),r.jsx(Nn,{children:s.map(o=>{var i;const c=[o.firstName,o.lastName].filter(Boolean).join(" ");return r.jsxs(Ke,{"data-testid":P("customers","row",o.id),className:"cursor-pointer",onClick:()=>e(`/customers/${o.id}`),children:[r.jsx(re,{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:(((i=o.firstName)==null?void 0:i[0])??o.email[0]??"?").toUpperCase()}),r.jsxs("div",{children:[c&&r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:c}),r.jsx("p",{className:"text-xs text-zinc-500",children:o.email})]})]})}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-700",children:o.orderCount}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-700",children:ue(o.totalSpentMinor,"GBP")}),r.jsx(re,{className:"text-sm text-zinc-500",children:Oe(o.createdAt)}),r.jsx(re,{className:"text-right text-sm text-zinc-400",children:o.orderCount>0?ht(o.updatedAt):"—"})]},o.id)})})]}):r.jsx(Ge,{icon:r.jsx(Ro,{className:"h-5 w-5"}),title:"No customers found",description:t?"Try a different search.":"Customers will appear as orders are placed."})})]})}const XN={breadcrumb:()=>"Customers"};function ZN({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 min-w-0 items-center gap-1.5",children:[r.jsx(sl,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.email})]}),e.phone&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Jp,{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(Op,{className:"h-3 w-3"}),"Customer since ",Oe(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(Ta,{icon:r.jsx(Gn,{className:"h-4 w-4 text-blue-500"}),label:"Total Orders",value:String(t.orderCount)}),r.jsx(Ta,{icon:r.jsx(Ya,{className:"h-4 w-4 text-green-500"}),label:"Lifetime Value","data-testid":P("customer","stat","lifetime-value"),value:ue(t.lifetimeRevenueMinor,"GBP"),mono:!0}),r.jsx(Ta,{icon:r.jsx(Ya,{className:"h-4 w-4 text-indigo-500"}),label:"Avg Order","data-testid":P("customer","stat","avg-order"),value:ue(t.avgOrderValueMinor,"GBP"),mono:!0})]}),t.lastOrderAt&&r.jsxs("p",{className:"text-xs text-zinc-400",children:["Last order: ",ht(t.lastOrderAt)]})]})}function Ta({icon:e,label:t,value:n,mono:s,"data-testid":a}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-white p-3","data-testid":a,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 JN({orders:e,isLoading:t}){const n=Ct();return t?r.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,a)=>r.jsx(xe,{className:"h-11 w-full"},a))}):!e||e.length===0?r.jsx(Ge,{icon:r.jsx(Gn,{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(wn,{children:[r.jsx(jn,{children:r.jsxs(Ke,{children:[r.jsx(ne,{children:"Order #"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Items"}),r.jsx(ne,{className:"text-right",children:"Total"}),r.jsx(ne,{className:"text-right",children:"Date"})]})}),r.jsx(Nn,{children:e.map(s=>r.jsxs(Ke,{"data-testid":P("customer","orders-row",s.id),className:"cursor-pointer",onClick:()=>n(`/orders/${s.orderNumber}`),children:[r.jsxs(re,{className:"font-mono text-sm font-medium text-blue-600",children:["#",s.orderNumber]}),r.jsx(re,{children:r.jsx(Xn,{status:s.status})}),r.jsxs(re,{className:"text-zinc-500",children:[s.lineItems.length," item",s.lineItems.length!==1?"s":""]}),r.jsx(re,{className:"text-right font-mono text-sm",children:ue(s.totalMinor,s.currency)}),r.jsx(re,{className:"text-right text-sm text-zinc-500",children:ht(s.createdAt)})]},s.id))})]})})}function e1({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:Oe(t.at),children:ht(t.at)})]})]},n))})}function t1(){const{id:e}=vo(),[t,n]=l.useState(""),s=l.useRef(!1),[a,o]=l.useState(!1),{data:c,isLoading:i}=uu(e??""),{data:f,isLoading:u}=ub(e??""),d=fb(),h=async v=>{if(v.preventDefault(),!(!t.trim()||!e||s.current)){s.current=!0,o(!0);try{await d.mutateAsync({customerId:e,body:t.trim()}),n("")}finally{s.current=!1,o(!1)}}};if(i)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-32"}),r.jsx(xe,{className:"h-32 w-full"}),r.jsx(xe,{className:"h-48 w-full"})]});if(!c)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(Ve,{to:"/customers",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to customers"})]});const{customer:m,stats:x}=c,g=[m.firstName,m.lastName].filter(Boolean).join(" ")||m.email,p=m.metadata.adminNotes??[];return r.jsxs("div",{className:"space-y-5","data-testid":P("customer","detail"),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ve,{to:"/customers",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(Eo,{className:"h-4 w-4"}),"Customers"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("span",{className:"min-w-0 text-sm font-medium text-zinc-900 [overflow-wrap:anywhere]",children:g})]}),r.jsxs(Kr,{defaultValue:"overview",children:[r.jsxs(or,{children:[r.jsx(Ae,{value:"overview","data-testid":P("customer","tab","overview"),children:"Overview"}),r.jsx(Ae,{value:"history","data-testid":P("customer","tab","history"),children:"History"})]}),r.jsxs(Ue,{value:"overview",className:"space-y-5",children:[r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(ZN,{customer:m,stats:x})}),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(JN,{orders:f,isLoading:u})})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-3","data-testid":P("customer","notes"),children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Notes"}),r.jsx(e1,{notes:p}),r.jsxs("form",{onSubmit:v=>void h(v),className:"flex gap-2 pt-2",children:[r.jsx(Kt,{placeholder:"Add a note about this customer...",value:t,onChange:v=>n(v.target.value),rows:2,className:"flex-1 text-sm"}),r.jsx(se,{type:"submit",size:"icon",disabled:!t.trim()||a,className:"self-end h-9 w-9",children:r.jsx(al,{className:"h-4 w-4"})})]})]})]}),r.jsx(Ue,{value:"history",children:r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(fi,{collection:"customers",id:m.id,detailPath:`/api/admin/customers/${encodeURIComponent(m.id)}`})})})]})]})}const n1={breadcrumb:e=>"Customer"},lh=(e,t)=>`/api/admin/settings/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;function r1(){return Ce({queryKey:["settings"],queryFn:()=>W.get("/api/admin/settings")})}function s1(){const e=ye();return we({mutationFn:({slot:t,path:n,value:s})=>W.put(lh(t,n),{value:s}),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}function a1(){const e=ye();return we({mutationFn:({slot:t,path:n})=>W.delete(lh(t,n)),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}const o1={payments:"Payments",email:"Email",reviews:"Reviews",search:"Search",analytics:"Analytics",shipping:"Shipping",tax:"Tax",ai:"AI"},i1=(e,t)=>`${e}-${t}`;function c1(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 l1({slot:e,field:t,onSaved:n}){const s=l.useRef(null),a=s1(),o=a1(),[c,i]=l.useState(null),f=l.useRef(!1),u=i1(e,t.path),d=t.source==="config"||t.source==="env",h=async()=>{var g;const x=((g=s.current)==null?void 0:g.value)??"";if(!(x===""||f.current)){f.current=!0,i(null);try{await a.mutateAsync({slot:e,path:t.path,value:x}),s.current&&(s.current.value=""),n()}catch(p){i(p instanceof Re?p.message:"The value was not saved")}finally{f.current=!1}}},m=async()=>{i(null);try{await o.mutateAsync({slot:e,path:t.path}),n()}catch(x){i(x instanceof Re?x.message:"The value was not cleared")}};return r.jsxs("div",{"data-testid":`settings-field-${u}`,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-${u}`,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-${u}`,className:"min-w-0 truncate text-sm text-zinc-600 sm:w-44",children:c1(t)}),!d&&r.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pe,{ref:s,id:`settings-input-${u}`,"data-testid":`settings-input-${u}`,type:t.secret?"password":"text",autoComplete:"off",spellCheck:!1,placeholder:t.secret&&t.state==="set"?"Enter a new value":""}),r.jsx(se,{type:"button",size:"sm",className:"h-9","data-testid":`settings-save-${u}`,disabled:a.isPending,onClick:()=>void h(),children:"Save"}),t.source==="settings"&&r.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-9","data-testid":`settings-clear-${u}`,disabled:o.isPending,onClick:()=>void m(),children:"Clear"})]}),c!==null&&r.jsx("p",{role:"alert",className:"text-xs text-red-600",children:c})]})]})}function d1({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:o1[e.slot]??e.slot}),r.jsx("span",{className:"text-xs text-zinc-500",children:e.provider})]}),e.fields.map(n=>r.jsx(l1,{slot:e.slot,field:n,onSaved:t},n.path))]})}function u1(){const{data:e,isLoading:t}=r1(),[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(xe,{className:"h-40 w-full"}):e===void 0||e.slots.length===0?r.jsx(Ge,{icon:r.jsx(Wp,{className:"h-5 w-5"}),title:"Nothing to set here",description:"None of this store's providers takes keys from Settings."}):e.slots.map(a=>r.jsx(d1,{slot:a,onSaved:()=>s(!0)},a.slot))]})}const f1={breadcrumb:()=>"Settings"},h1=100;function m1(e){return Co({queryKey:["activity",e],initialPageParam:void 0,queryFn:({pageParam:t})=>W.getPage("/api/admin/activity",{...e,limit:h1,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 p1(e){return W.getText("/api/admin/activity/export",e)}const x1={applied:"bg-green-50 text-green-700",refused:"bg-red-50 text-red-700",replayed:"bg-zinc-100 text-zinc-600"};function vc(e){if(e==="")return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function g1(e){const t={};for(const a of["actor","command","subject","correlation","outcome"]){const o=e[a].trim();o!==""&&(t[a]=o)}const n=vc(e.since),s=vc(e.until);return n!==void 0&&(t.since=n),s!==void 0&&(t.until=s),t}function v1(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 y1={actor:"",command:"",subject:"",correlation:"",outcome:"",since:"",until:""};function b1(){const[e]=Ac(),[t,n]=l.useState(()=>({...y1,correlation:e.get("correlation")??""})),[s,a]=l.useState(!1),[o,c]=l.useState(null),i=g1(t),{data:f,isLoading:u,isError:d,fetchNextPage:h,hasNextPage:m,isFetchingNextPage:x}=m1(i),g=(f==null?void 0:f.pages.flatMap(y=>y.data))??[],p=y=>w=>n(N=>({...N,[y]:w})),v=async()=>{a(!0),c(null);try{const{since:y,until:w,correlation:N}=i;v1(await p1({...y!==void 0&&{since:y},...w!==void 0&&{until:w},...N!==void 0&&{correlation:N}}))}catch(y){c(y instanceof Error?y.message:String(y))}finally{a(!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(se,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void v(),disabled:s,"data-testid":"activity-export",children:[s?r.jsx(_r,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(Bp,{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(pe,{placeholder:"Actor (admin:<id>, system, …)",value:t.actor,onChange:y=>p("actor")(y.target.value),className:"h-8 text-sm","aria-label":"Actor","data-testid":"activity-filter-actor"}),r.jsx(pe,{placeholder:"Command (inventory.adjust, …)",value:t.command,onChange:y=>p("command")(y.target.value),className:"h-8 text-sm","aria-label":"Command","data-testid":"activity-filter-command"}),r.jsx(pe,{placeholder:"Subject id",value:t.subject,onChange:y=>p("subject")(y.target.value),className:"h-8 text-sm","aria-label":"Subject","data-testid":"activity-filter-subject"}),r.jsx(pe,{placeholder:"Correlation id",value:t.correlation,onChange:y=>p("correlation")(y.target.value),className:"h-8 text-sm","aria-label":"Correlation id","data-testid":"activity-filter-correlation"}),r.jsxs("select",{value:t.outcome,onChange:y=>p("outcome")(y.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(pe,{type:"datetime-local",value:t.since,onChange:y=>p("since")(y.target.value),className:"h-8 text-sm","aria-label":"From","data-testid":"activity-filter-since"}),r.jsx(pe,{type:"datetime-local",value:t.until,onChange:y=>p("until")(y.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((y,w)=>r.jsx(xe,{className:"h-11 w-full"},w))}):d?r.jsx(Ge,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"Activity could not be loaded"}):g.length===0?r.jsx(Ge,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"No activity found",description:"Changes to the store appear here as they are made."}):r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Ke,{children:[r.jsx(ne,{children:"Time"}),r.jsx(ne,{children:"Actor"}),r.jsx(ne,{children:"Command"}),r.jsx(ne,{children:"Subjects"}),r.jsx(ne,{children:"Outcome"}),r.jsx(ne,{children:"Correlation id"})]})}),r.jsx(Nn,{children:g.map(y=>r.jsxs(Ke,{"data-testid":`activity-row-${y.id}`,children:[r.jsx(re,{className:"whitespace-nowrap text-xs text-zinc-500",children:Oe(y.at)}),r.jsxs(re,{className:"font-mono text-xs",children:[y.actor.kind,":",y.actor.id]}),r.jsx(re,{className:"font-mono text-xs",children:y.command}),r.jsx(re,{className:"font-mono text-xs text-zinc-600",children:y.subjects.map(w=>r.jsxs("div",{children:[w.type,":",w.id]},`${w.type}:${w.id}`))}),r.jsx(re,{children:r.jsxs("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",x1[y.outcome]),children:[y.outcome,y.responseStatus!==null&&` ${y.responseStatus}`]})}),r.jsx(re,{className:"font-mono text-xs text-zinc-500",children:y.correlationId??""})]},y.id))})]})}),m&&r.jsx(se,{variant:"outline",size:"sm",onClick:()=>void h(),disabled:x,children:x?"Loading…":"Load more"})]})}const w1={breadcrumb:()=>"Activity"},j1={pending:"bg-amber-50 text-amber-700",approved:"bg-blue-50 text-blue-700",applied:"bg-green-50 text-green-700",rejected:"bg-zinc-100 text-zinc-600",failed:"bg-red-50 text-red-700"},N1={pending:"Pending",approved:"Approved",applied:"Applied",rejected:"Rejected",failed:"Failed"};function C1(e){return typeof e=="string"?e:JSON.stringify(e)}function S1(e,t){return e.kind==="policy"?`policy ${e.rule}`:e.id===t?"you":`admin ${e.id}`}function E1({proposal:e,me:t,onReject:n}){const s=fl(),a=l.useRef(!1),[o,c]=l.useState(!1),[i,f]=l.useState(null),{id:u,decision:d,outcome:h}=e,m=e.proposer.agent,x=e.proposer.userId,g=async()=>{if(!a.current){a.current=!0,c(!0),f(null);try{await s.mutateAsync(u)}catch(v){f(v instanceof Re?v.message:"The proposal could not be approved.")}finally{a.current=!1,c(!1)}}},p=Object.entries(e.args);return r.jsxs("article",{className:"min-w-0 space-y-3 rounded-lg border border-zinc-200 bg-white p-4","data-testid":P("inbox","row",u),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-mono text-sm font-semibold break-all text-zinc-900",children:e.command}),r.jsx("p",{className:"font-mono text-xs break-all text-zinc-500",children:e.tool})]}),r.jsx("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",j1[e.status]),"data-testid":P("inbox","status",u),children:N1[e.status]})]}),r.jsxs("p",{className:"text-xs break-words text-zinc-500",children:[m.name,m.version!==void 0&&` ${m.version}`," for"," ",x===null?"a shopper":x===t?"you":`admin ${x}`,","," ",Oe(e.createdAt)]}),r.jsx(du,{proposal:e,scope:"inbox"}),(p.length>0||e.handles.length>0)&&r.jsxs("dl",{className:"grid min-w-0 grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-3 gap-y-1 rounded-md bg-zinc-50 p-2 text-xs",children:[p.map(([v,y])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"font-mono text-zinc-500 break-all",children:v}),r.jsx("dd",{className:"font-mono whitespace-pre-wrap break-all text-zinc-800",children:C1(y)})]},v)),e.handles.map(v=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"font-mono text-zinc-500 break-all",children:v}),r.jsxs("dd",{className:"text-zinc-400 italic",children:["the agent’s ",v]})]},v))]}),d!==void 0&&r.jsxs("p",{className:"text-xs break-words text-zinc-600",children:[e.status==="rejected"?"Rejected":"Approved"," by"," ",S1(d.by,t),", ",Oe(d.at),d.reason!==void 0&&`: ${d.reason}`]}),e.status==="failed"&&(h==null?void 0:h.message)!==void 0&&r.jsx("p",{className:"text-xs break-words text-red-600",children:h.message}),e.status==="applied"&&r.jsx(Ve,{to:`/activity?correlation=${encodeURIComponent(e.correlationId)}`,className:"text-xs text-blue-600 hover:underline",children:"See what it changed"}),e.status==="pending"&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(se,{size:"sm",className:"gap-1.5",onClick:()=>void g(),disabled:o,"data-testid":P("inbox","approve",u),children:[o?r.jsx(_r,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(St,{className:"h-3.5 w-3.5"}),"Approve"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>n(e),disabled:o,"data-testid":P("inbox","reject",u),children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Reject"]}),i!==null&&r.jsx("p",{className:"text-xs text-red-600",children:i})]})]})}const R1=500;function P1({proposal:e,onClose:t}){const[n,s]=l.useState(""),[a,o]=l.useState(null),c=l.useRef(!1),[i,f]=l.useState(!1),u=hl();l.useEffect(()=>{e!==null&&(s(""),o(null))},[e]);const d=async()=>{if(!(e===null||c.current)){c.current=!0,f(!0),o(null);try{await u.mutateAsync({id:e.id,reason:n.trim()}),t()}catch(h){o(h instanceof Re?h.message:"The proposal could not be rejected.")}finally{c.current=!1,f(!1)}}};return r.jsx(Gs,{open:e!==null,onOpenChange:h=>!h&&t(),children:r.jsxs(Ur,{className:"max-w-md",children:[r.jsx(Qs,{children:r.jsxs(Vr,{children:["Reject ",e==null?void 0:e.command]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"proposal-reason",children:"Reason (optional)"}),r.jsx(Kt,{id:"proposal-reason",value:n,maxLength:R1,onChange:h=>s(h.target.value),"data-testid":P("inbox","reason")})]}),a!==null&&r.jsx("p",{className:"text-sm text-red-600",children:a}),r.jsxs(Ys,{children:[r.jsx(se,{variant:"outline",onClick:t,disabled:i,children:"Cancel"}),r.jsx(se,{variant:"destructive",onClick:()=>void d(),disabled:i,"data-testid":P("inbox","reject-confirm"),children:"Reject"})]})]})})}function k1(){const[e,t]=l.useState("pending"),[n,s]=l.useState(null),{data:a}=Po(),{data:o,isLoading:c,isError:i,fetchNextPage:f,hasNextPage:u,isFetchingNextPage:d}=fx(e),h=(o==null?void 0:o.pages.flatMap(m=>m.items))??[];return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inbox"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Changes agents asked for. Nothing runs until you approve it, as you."})]}),r.jsx(Kr,{value:e,onValueChange:m=>t(m),children:r.jsxs(or,{children:[r.jsx(Ae,{value:"pending","data-testid":P("inbox","tab","pending"),children:"Pending"}),r.jsx(Ae,{value:"decided","data-testid":P("inbox","tab","decided"),children:"Decided"})]})}),c?r.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((m,x)=>r.jsx(xe,{className:"h-28 w-full"},x))}):i?r.jsx(Ge,{icon:r.jsx(Ga,{className:"h-5 w-5"}),title:"The inbox could not be loaded"}):h.length===0?r.jsx(Ge,{icon:r.jsx(Ga,{className:"h-5 w-5"}),title:e==="pending"?"Nothing waiting":"Nothing decided yet",description:"An agent's change to the store appears here until someone decides it."}):r.jsx("div",{className:"space-y-3",children:h.map(m=>r.jsx(E1,{proposal:m,me:a==null?void 0:a.userId,onReject:s},m.id))}),u&&r.jsx(se,{variant:"outline",size:"sm",onClick:()=>void f(),disabled:d,children:d?"Loading…":"Load more"}),r.jsx(P1,{proposal:n,onClose:()=>s(null)})]})}const T1={breadcrumb:()=>"Inbox"};function A1(){const e=Ct();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(se,{variant:"outline",onClick:()=>e("/"),children:"Go to Dashboard"})})]})}let yc=null;async function M1(){return vs()?null:(yc??(yc=Pp()),await yc,vs()?null:wh("/login"))}const dh=bh([{path:"/login",element:r.jsx(Lb,{})},{path:"/",element:r.jsx(Ib,{}),loader:M1,handle:{breadcrumb:()=>null},children:[{index:!0,element:r.jsx(qb,{}),handle:{breadcrumb:()=>"Dashboard"}},{path:"orders",handle:pj,children:[{index:!0,element:r.jsx(mj,{})},{path:":orderNumber",element:r.jsx(pN,{}),handle:xN}]},{path:"products",handle:PN,children:[{index:!0,element:r.jsx(RN,{})},{path:"new",element:r.jsx(xc,{}),handle:DN},{path:":slug",element:r.jsx(xc,{}),handle:ON}]},{path:"inventory",element:r.jsx(GN,{}),handle:QN},{path:"customers",handle:XN,children:[{index:!0,element:r.jsx(YN,{})},{path:":id",element:r.jsx(t1,{}),handle:n1}]},{path:"activity",element:r.jsx(b1,{}),handle:w1},{path:"inbox",element:r.jsx(k1,{}),handle:T1},{path:"settings",element:r.jsx(u1,{}),handle:f1},{path:"*",element:r.jsx(A1,{})}]}],{basename:"/admin"});Cp(()=>{gs.clear(),dh.navigate("/login")});const uh=document.getElementById("root");if(!uh)throw new Error("Root element not found");Eh.createRoot(uh).render(r.jsx(l.StrictMode,{children:r.jsx(Jh,{client:gs,children:r.jsx(jh,{router:dh})})}));