PageSourceSearch

https://stevehofstetter.com/assets/admin-ClA2nWnW.js

js stevehofstetter.com collected 2026-10-02 10:07:03 UTC 407,374 bytes, 3 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/admin-report-CADr6cPP.js","assets/index-Cw_vWzcG.js","assets/index-B7IqKIwa.css","assets/seven-day-itinerary-grid-BxT6cWzh.js","assets/loader-circle-CFReBPM-.js","assets/check-aenHoWvI.js","assets/copy-Q6hdaqAj.js","assets/input-C6iN-KGn.js","assets/regions-C8cpqIh1.js","assets/index-BnQWHVRb.js","assets/chevron-right-nbuxMMx8.js","assets/search-xqZOL2xB.js","assets/download-C2A-xwHS.js","assets/select-C3hP61dO.js","assets/index-CeSLzpw6.js","assets/chevron-down-BxGR1GEJ.js","assets/index-C9quj048.js","assets/use-upload-kkb3alVX.js","assets/use-upload-D9e3sqm0.css","assets/label-qVDuR2Rg.js","assets/textarea-C1ir9wus.js","assets/switch-DYGgxqMj.js","assets/table-BvueJhDD.js","assets/tabs-DoygPEVT.js","assets/badge-B8aAVdnW.js","assets/checkbox-B_lbU-ay.js","assets/instagram-MPP_qsQi.js","assets/arrow-left-BnuaOQMX.js","assets/upload-BU8OO0kQ.js","assets/users-CMFgl17y.js","assets/calendar-Dcl2e2II.js","assets/circle-check-B60zK6nN.js","assets/triangle-alert-DSNNdcX-.js","assets/star-DB1O5zJt.js","assets/external-link-DafRhKqP.js","assets/globe-Cz4T4Gaf.js","assets/admin-runs-BrNFyAwt.js","assets/admin-threads-B6ykSR_3.js","assets/card-T5hEyJwb.js","assets/image-plus-B15uaG3J.js","assets/sparkles-CZEXO4Vz.js","assets/eye-off-C72LzT3E.js","assets/admin-membership-Ctm5Fqor.js","assets/skeleton-CNI0NEzJ.js","assets/clock-B5471JeQ.js","assets/lock-Bzr75Rvj.js","assets/ticket-BeKadSSO.js","assets/admin-booking-BJvhmlKK.js","assets/calendar-days-BzigvEwy.js","assets/rotate-ccw-DQIADpyK.js","assets/ticketing-admin-BUziw4g2.js","assets/user-plus-CuGllrY1.js","assets/format-BEeSy016.js","assets/info-Dl2JEE-m.js","assets/admin-kindness-DZb_s7dz.js","assets/index.esm-Cu0LiIpY.js","assets/form-CIvGkM2B.js","assets/kindness-DKKBgnzY.js"])))=>i.map(i=>d[i]);
2import{c as Rt,r as h,j as e,a4 as nt,aP as sm,aQ as nm,B as F,O as Ze,P as Xe,aR as Je,Q as et,R as at,aS as Qe,aD as rm,aT as am,aF as Ss,aI as uc,aE as mc,aG as vn,aU as hc,aV as pc,aH as fc,aW as im,aK as om,aX as lm,aY as cm,aZ as dm,a_ as um,a$ as mm,b0 as hm,b1 as pm,b2 as fm,b3 as ht,b4 as gm,b5 as xm,b6 as vm,b7 as ym,b8 as Dn,b9 as Ri,au as jm,L as Ys,X as en,ba as bm,bb as Li,bc as wm,aj as Nm,G as Ye,bd as Wr,be as Cm,bf as Bn,bg as Fi,bh as Sm,bi as km,bj as Tm,bk as Am,bl as Pm,bm as Mm,M as Hs,bn as gt,bo as ut,bp as gc,ah as ls,bq as us,br as Dm,bs as Im,bt as Em,bu as Rm,bv as Lm,bw as Fm,bx as Vm,by as $m,bz as Om,bA as Bm,bB as Um,bC as _m,bD as qm,bE as Gm,bF as Km,bG as zm,bH as Hm,bI as Wm,bJ as xc,bK as Ym,bL as Qm,bM as Zm,bN as Xm,bO as Jm,bP as eh,bQ as th,bR as sh,bS as nh,bT as rh,bU as ah,at as Ka,bV as ih,bW as oh,bX as lh,bY as ch,bZ as dh,b_ as uh,b$ as mh,c0 as hh,c1 as ph,c2 as bo,c3 as wo,c4 as No,c5 as za,c6 as fh,c7 as gh,c8 as jr,c9 as xh,ca as Co,cb as ya,cc as vh,A as vc,E as Ha,cd as yh,ce as jh,cf as bh,cg as wh,ch as Nh,ci as Ch,cj as Sh,ck as kh,cl as Th,cm as Ah,cn as Ph,co as Mh,cp as Dh,aa as Ih,cq as Eh,cr as Wa,cs as Rh,m as Lh,ct as So,cu as ko,cv as Fh,cw as To,cx as Vi,cy as Vh,cz as $h,cA as Oh,cB as Bh,cC as Ao,cD as Uh}from"./index-Cw_vWzcG.js";import{Q as _h}from"./index-C9quj048.js";import{u as qh}from"./use-upload-kkb3alVX.js";import{u as Gh,S as yc,D as $i,a as jc,c as br,U as Kh}from"./seven-day-itinerary-grid-BxT6cWzh.js";import{I as ne}from"./input-C6iN-KGn.js";import{P as ms,L as Z}from"./label-qVDuR2Rg.js";import{T as Pt}from"./textarea-C1ir9wus.js";import{S as $r}from"./switch-DYGgxqMj.js";import{D as Ya,a as Qa,b as Za,c as yn,d as zh,r as hn,t as Hh,A as Qs,s as bc,h as wc,e as Wh,f as Yh,g as Qh,z as Zh}from"./regions-C8cpqIh1.js";import{T as Pe,a as Me,b as he,c as U,d as De,e as _,A as Un,f as _n,g as qn,h as Gn,i as Kn,j as zn,k as Hn,l as Wn}from"./table-BvueJhDD.js";import{T as Yr,a as Qr,b as Le,c as Ce,Y as Xh}from"./tabs-DoygPEVT.js";import{B as it}from"./badge-B8aAVdnW.js";import{S as ns,a as rs,b as as,c as is,d as Ge,C as Oi}from"./select-C3hP61dO.js";import{C as In}from"./checkbox-B_lbU-ay.js";import{S as Ms}from"./search-xqZOL2xB.js";import{L as le}from"./loader-circle-CFReBPM-.js";import{C as It}from"./chevron-down-BxGR1GEJ.js";import{E as jn,I as Jh}from"./instagram-MPP_qsQi.js";import{A as Nc}from"./arrow-left-BnuaOQMX.js";import{U as Us}from"./upload-BU8OO0kQ.js";import{U as Bi}from"./users-CMFgl17y.js";import{C as tn}from"./calendar-Dcl2e2II.js";import{C as Xa}from"./check-aenHoWvI.js";import{C as ep}from"./circle-check-B60zK6nN.js";import{T as tp}from"./triangle-alert-DSNNdcX-.js";import{S as sp}from"./star-DB1O5zJt.js";import{E as np}from"./external-link-DafRhKqP.js";import{C as rp}from"./chevron-right-nbuxMMx8.js";import{G as ap}from"./globe-Cz4T4Gaf.js";const ip=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],op=Rt("arrow-down",ip);const lp=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],cp=Rt("arrow-up",lp);const dp=[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]],up=Rt("car-front",dp);const mp=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Yn=Rt("chevrons-up-down",mp);const hp=[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]],pp=Rt("facebook",hp);const fp=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ui=Rt("grip-vertical",fp);const gp=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],xp=Rt("log-out",gp);const vp=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],En=Rt("pencil",vp);const yp=[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.
21-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]],jp=Rt("plane",yp);const bp=[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]],Po=Rt("train-front",bp);const wp=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Np=Rt("wallet",wp),Cc=h.createContext({});function Qn(t){const s=h.useRef(null);return s.current===null&&(s.current=t()),s.current}const Cp=typeof window<"u",Sc=Cp?h.useLayoutEffect:h.useEffect,_i=h.createContext(null);function qi(t,s){t.indexOf(s)===-1&&t.push(s)}function Or(t,s){const n=t.indexOf(s);n>-1&&t.splice(n,1)}function Sp([...t],s,n){const r=s<0?t.length+s:s;if(r>=0&&r<t.length){const a=n<0?t.length+n:n,[o]=t.splice(s,1);t.splice(a,0,o)}return t}const Bt=(t,s,n)=>n>s?s:n<t?t:n;let Gi=()=>{};const cs={},kc=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Tc(t){return typeof t=="object"&&t!==null}const Ac=t=>/^0[^.\s]+$/u.test(t);function Pc(t){let s;return()=>(s===void 0&&(s=t()),s)}const yt=t=>t,kp=(t,s)=>n=>s(t(n)),Zn=(...t)=>t.reduce(kp),Rn=(t,s,n)=>{const r=s-t;return r===0?1:(n-t)/r};class Ki{constructor(){this.subscriptions=[]}add(s){return qi(this.subscriptions,s),()=>Or(this.subscriptions,s)}notify(s,n,r){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](s,n,r);else for(let o=0;o<a;o++){const i=this.subscriptions[o];i&&i(s,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const mt=t=>t*1e3,vt=t=>t/1e3;function Mc(t,s){return s?t*(1e3/s):0}const Dc=(t,s,n)=>(((1-3*n+3*s)*t+(3*n-6*s))*t+3*s)*t,Tp=1e-7,Ap=12;function Pp(t,s,n,r,a){let o,i,d=0;do i=s+(n-s)/2,o=Dc(i,r,a)-t,o>0?n=i:s=i;while(Math.abs(o)>Tp&&++d<Ap);return i}function Xn(t,s,n,r){if(t===s&&n===r)return yt;const a=o=>Pp(o,0,1,t,n);return o=>o===0||o===1?o:Dc(a(o),s,r)}const Ic=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,Ec=t=>s=>1-t(1-s),Rc=Xn(.33,1.53,.69,.99),zi=Ec(Rc),Lc=Ic(zi),Fc=t=>t>=1?1:(t*=2)<1?.5*zi(t):.5*(2-Math.pow(2,-10*(t-1))),Hi=t=>1-Math.sin(Math.acos(t)),Vc=Ec(Hi),$c=Ic(Hi),Mp=Xn(.42,0,1,1),Dp=Xn(0,0,.58,1),Oc=Xn(.42,0,.58,1),Ip=t=>Array.isArray(t)&&typeof t[0]!="number",Bc=t=>Array.isArray(t)&&typeof t[0]=="number",Ep={linear:yt,easeIn:Mp,easeInOut:Oc,easeOut:Dp,circIn:Hi,circInOut:$c,circOut:Vc,backIn:zi,backInOut:Lc,backOut:Rc,anticipate:Fc},Rp=t=>typeof t=="string",Mo=t=>{if(Bc(t)){Gi(t.length===4);const[s,n,r,a]=t;return Xn(s,n,r,a)}else if(Rp(t))return Ep[t];return t},wr=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Lp(t,s){let n=new Set,r=new Set,a=!1,o=!1;const i=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function u(l){i.has(l)&&(c.schedule(l),t()),l(d)}const c={schedule:(l,p=!1,g=!1)=>{const w=g&&a?n:r;return p&&i.add(l),w.add(l),l},cancel:l=>{r.delete(l),i.delete(l)},process:l=>{if(d=l,a){o=!0;return}a=!0;const p=n;n=r,r=p,n.forEach(u),n.clear(),a=!1,o&&(o=!1,c.process(l))}};return c}const Fp=40;function Uc(t,s){let n=!1,r=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=wr.reduce((y,T)=>(y[T]=Lp(o),y),{}),{setup:d,read:u,resolveKeyframes:c,preUpdate:l,update:p,preRender:g,render:v,postRender:w}=i,A=()=>{const y=cs.useManualTiming,T=y?a.timestamp:performance.now();n=!1,y||(a.delta=r?1e3/60:Math.max(Math.min(T-a.timestamp,Fp),1)),a.timestamp=T,a.isProcessing=!0,d.process(a),u.process(a),c.process(a),l.process(a),p.process(a),g.process(a),v.process(a),w.process(a),a.isProcessing=!1,n&&s&&(r=!1,t(A))},N=()=>{n=!0,r=!0,a.isProcessing||t(A)};return{schedule:wr.reduce((y,T)=>{const L=i[T];return y[T]=(O,q=!1,z=!1)=>(n||N(),L.schedule(O,q,z)),y},{}),cancel:y=>{for(let T=0;T<wr.length;T++)i[wr[T]].cancel(y)},state:a,steps:i}}const{schedule:we,cancel:Wt,state:qe,steps:ja}=Uc(typeof requestAnimationFrame<"u"?requestAnimationFrame:yt,!0);let Mr;function Vp(){Mr=void 0}const tt={now:()=>(Mr===void 0&&tt.set(qe.isProcessing||cs.useManualTiming?qe.timestamp:performance.now()),Mr),set:t=>{Mr=t,queueMicrotask(Vp)}},_c=t=>s=>typeof s=="string"&&s.startsWith(t),qc=_c("--"),$p=_c("var(--"),Wi=t=>$p(t)?Op.test(t.split("/*")[0].trim()):!1,Op=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Do(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const sn={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Ln={...sn,transform:t=>Bt(0,1,t)},Nr={...sn,default:1},bn=t=>Math.round(t*1e5)/1e5,Yi=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Bp(t){return t==null}const Up=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Qi=(t,s)=>n=>!!(typeof n=="string"&&Up.test(n)&&n.startsWith(t)||s&&!Bp(n)&&Object.prototype.hasOwnProperty.call(n,s)),Gc=(t,s,n)=>r=>{if(typeof r!="string")return r;const[a,o,i,d]=r.match(Yi);return{[t]:parseFloat(a),[s]:parseFloat(o),[n]:parseFloat(i),alpha:d!==void 0?parseFloat(d):1}},_p=t=>Bt(0,255,t),ba={...sn,transform:t=>Math.round(_p(t))},Ns={test:Qi("rgb","red"),parse:Gc("red","green","blue"),transform:({red:t,green:s,blue:n,alpha:r=1})=>"rgba("+ba.transform(t)+", "+ba.transform(s)+", "+ba.transform(n)+", "+bn(Ln.transform(r))+")"};function qp(t){let s="",n="",r="",a="";return t.length>5?(s=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),a=t.substring(7,9)):(s=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),a=t.substring(4,5),s+=s,n+=n,r+=r,a+=a),{red:parseInt(s,16),green:parseInt(n,16),blue:parseInt(r,16),alph
vendor: 115,670 bytes, line 2
2a:a?parseInt(a,16)/255:1}}const Ja={test:Qi("#"),parse:qp,transform:Ns.transform},Jn=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),ts=Jn("deg"),Ot=Jn("%"),ae=Jn("px"),Gp=Jn("vh"),Kp=Jn("vw"),Io={...Ot,parse:t=>Ot.parse(t)/100,transform:t=>Ot.transform(t*100)},_s={test:Qi("hsl","hue"),parse:Gc("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+Ot.transform(bn(s))+", "+Ot.transform(bn(n))+", "+bn(Ln.transform(r))+")"},Ve={test:t=>Ns.test(t)||Ja.test(t)||_s.test(t),parse:t=>Ns.test(t)?Ns.parse(t):_s.test(t)?_s.parse(t):Ja.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ns.transform(t):_s.transform(t),getAnimatableNone:t=>{const s=Ve.parse(t);return s.alpha=0,Ve.transform(s)}},zp=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Hp(t){return isNaN(t)&&typeof t=="string"&&(t.match(Yi)?.length||0)+(t.match(zp)?.length||0)>0}const Kc="number",zc="color",Wp="var",Yp="var(",Eo="${}",Qp=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Zs(t){const s=t.toString(),n=[],r={color:[],number:[],var:[]},a=[];let o=0;const d=s.replace(Qp,u=>(Ve.test(u)?(r.color.push(o),a.push(zc),n.push(Ve.parse(u))):u.startsWith(Yp)?(r.var.push(o),a.push(Wp),n.push(u)):(r.number.push(o),a.push(Kc),n.push(parseFloat(u))),++o,Eo)).split(Eo);return{values:n,split:d,indexes:r,types:a}}function Zp(t){return Zs(t).values}function Hc({split:t,types:s}){const n=t.length;return r=>{let a="";for(let o=0;o<n;o++)if(a+=t[o],r[o]!==void 0){const i=s[o];i===Kc?a+=bn(r[o]):i===zc?a+=Ve.transform(r[o]):a+=r[o]}return a}}function Xp(t){return Hc(Zs(t))}const Jp=t=>typeof t=="number"?0:Ve.test(t)?Ve.getAnimatableNone(t):t,ef=(t,s)=>typeof t=="number"?s?.trim().endsWith("/")?t:0:Jp(t);function tf(t){const s=Zs(t);return Hc(s)(s.values.map((r,a)=>ef(r,s.split[a])))}const Et={test:Hp,parse:Zp,createTransformer:Xp,getAnimatableNone:tf};function wa(t,s,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(s-t)*6*n:n<1/2?s:n<2/3?t+(s-t)*(2/3-n)*6:t}function sf({hue:t,saturation:s,lightness:n,alpha:r}){t/=360,s/=100,n/=100;let a=0,o=0,i=0;if(!s)a=o=i=n;else{const d=n<.5?n*(1+s):n+s-n*s,u=2*n-d;a=wa(u,d,t+1/3),o=wa(u,d,t),i=wa(u,d,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:r}}function Br(t,s){return n=>n>0?s:t}const Se=(t,s,n)=>t+(s-t)*n,Na=(t,s,n)=>{const r=t*t,a=n*(s*s-r)+r;return a<0?0:Math.sqrt(a)},nf=[Ja,Ns,_s],rf=t=>nf.find(s=>s.test(t));function Ro(t){const s=rf(t);if(!s)return!1;let n=s.parse(t);return s===_s&&(n=sf(n)),n}const Lo=(t,s)=>{const n=Ro(t),r=Ro(s);if(!n||!r)return Br(t,s);const a={...n};return o=>(a.red=Na(n.red,r.red,o),a.green=Na(n.green,r.green,o),a.blue=Na(n.blue,r.blue,o),a.alpha=Se(n.alpha,r.alpha,o),Ns.transform(a))},ei=new Set(["none","hidden"]);function af(t,s){return ei.has(t)?n=>n<=0?t:s:n=>n>=1?s:t}function of(t,s){return n=>Se(t,s,n)}function Zi(t){return typeof t=="number"?of:typeof t=="string"?Wi(t)?Br:Ve.test(t)?Lo:df:Array.isArray(t)?Wc:typeof t=="object"?Ve.test(t)?Lo:lf:Br}function Wc(t,s){const n=[...t],r=n.length,a=t.map((o,i)=>Zi(o)(o,s[i]));return o=>{for(let i=0;i<r;i++)n[i]=a[i](o);return n}}function lf(t,s){const n={...t,...s},r={};for(const a in n)t[a]!==void 0&&s[a]!==void 0&&(r[a]=Zi(t[a])(t[a],s[a]));return a=>{for(const o in r)n[o]=r[o](a);return n}}function cf(t,s){const n=[],r={color:0,var:0,number:0};for(let a=0;a<s.values.length;a++){const o=s.types[a],i=t.indexes[o][r[o]],d=t.values[i]??0;n[a]=d,r[o]++}return n}const df=(t,s)=>{const n=Et.createTransformer(s),r=Zs(t),a=Zs(s);return r.indexes.var.length===a.indexes.var.length&&r.indexes.color.length===a.indexes.color.length&&r.indexes.number.length>=a.indexes.number.length?ei.has(t)&&!a.values.length||ei.has(s)&&!r.values.length?af(t,s):Zn(Wc(cf(r,a),a.values),n):Br(t,s)};function Yc(t,s,n){return typeof t=="number"&&typeof s=="number"&&typeof n=="number"?Se(t,s,n):Zi(t)(t,s)}const uf=t=>{const s=({timestamp:n})=>t(n);return{start:(n=!0)=>we.update(s,n),stop:()=>Wt(s),now:()=>qe.isProcessing?qe.timestamp:tt.now()}},Qc=(t,s,n=10)=>{let r="";const a=Math.max(Math.round(s/n),2);for(let o=0;o<a;o++)r+=Math.round(t(o/(a-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},Ur=2e4;function Xi(t){let s=0;const n=50;let r=t.next(s);for(;!r.done&&s<Ur;)s+=n,r=t.next(s);return s>=Ur?1/0:s}function mf(t,s=100,n){const r=n({...t,keyframes:[0,s]}),a=Math.min(Xi(r),Ur);return{type:"keyframes",ease:o=>r.next(a*o).value/s,duration:vt(a)}}const Ie={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function ti(t,s){return t*Math.sqrt(1-s*s)}const hf=12;function pf(t,s,n){let r=n;for(let a=1;a<hf;a++)r=r-t(r)/s(r);return r}const Ca=.001;function ff({duration:t=Ie.duration,bounce:s=Ie.bounce,velocity:n=Ie.velocity,mass:r=Ie.mass}){let a,o,i=1-s;i=Bt(Ie.minDamping,Ie.maxDamping,i),t=Bt(Ie.minDuration,Ie.maxDuration,vt(t)),i<1?(a=c=>{const l=c*i,p=l*t,g=l-n,v=ti(c,i),w=Math.exp(-p);return Ca-g/v*w},o=c=>{const p=c*i*t,g=p*n+n,v=Math.pow(i,2)*Math.pow(c,2)*t,w=Math.exp(-p),A=ti(Math.pow(c,2),i);return(-a(c)+Ca>0?-1:1)*((g-v)*w)/A}):(a=c=>{const l=Math.exp(-c*t),p=(c-n)*t+1;return-Ca+l*p},o=c=>{const l=Math.exp(-c*t),p=(n-c)*(t*t);return l*p});const d=5/t,u=pf(a,o,d);if(t=mt(t),isNaN(u))return{stiffness:Ie.stiffness,damping:Ie.damping,duration:t};{const c=Math.pow(u,2)*r;return{stiffness:c,damping:i*2*Math.sqrt(r*c),duration:t}}}const gf=["duration","bounce"],xf=["stiffness","damping","mass"];function Fo(t,s){return s.some(n=>t[n]!==void 0)}function vf(t){let s={velocity:Ie.velocity,stiffness:Ie.stiffness,damping:Ie.damping,mass:Ie.mass,isResolvedFromDuration:!1,...t};if(!Fo(t,xf)&&Fo(t,gf))if(s.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),a=r*r,o=2*Bt(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:Ie.mass,stiffness:a,damping:o}}else{const n=ff({...t,velocity:0});s={...s,...n,mass:Ie.mass},s.isResolvedFromDuration=!0}return s}function _r(t=Ie.visualDuration,s=Ie.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:r,restDelta:a}=n;const o=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],d={done:!1,value:o},{stiffness:u,damping:c,mass:l,duration:p,velocity:g,isResolvedFromDuration:v}=vf({...n,velocity:-vt(n.velocity||0)}),w=g||0,A=c/(2*Math.sqrt(u*l)),N=i-o,I=vt(Math.sqrt(u/l)),C=Math.abs(N)<5;r||(r=C?Ie.restSpeed.granular:Ie.restSpeed.default),a||(a=C?Ie.restDelta.granular:Ie.restDelta.default);let y,T,L,O,q,z;if(A<1)L=ti(I,A),O=(w+A*I*N)/L,y=j=>{const E=Math.exp(-A*I*j);return i-E*(O*Math.sin(L*j)+N*Math.cos(L*j))},q=A*I*O+N*L,z=A*I*N-O*L,T=j=>Math.exp(-A*I*j)*(q*Math.sin(L*j)+z*Math.cos(L*j));else if(A===1){y=E=>i-Math.exp(-I*E)*(N+(w+I*N)*E);const j=w+I*N;T=E=>Math.exp(-I*E)*(I*j*E-w)}else{const j=I*Math.sqrt(A*A-1);y=R=>{const re=Math.exp(-A*I*R),H=Math.min(j*R,300);return i-re*((w+A*I*N)*Math.sinh(H)+j*N*Math.cosh(H))/j};const E=(w+A*I*N)/j,W=A*I*E-N*j,ie=A*I*N-E*j;T=R=>{const re=Math.exp(-A*I*R),H=Math.min(j*R,300);return re*(W*Math.sinh(H)+ie*Math.cosh(H))}}const x={calculatedDuration:v&&p||null,velocity:j=>mt(T(j)),next:j=>{if(!v&&A<1){const W=Math.exp(-A*I*j),ie=Math.sin(L*j),R=Math.cos(L*j),re=i-W*(O*ie+N*R),H=mt(W*(q*ie+z*R));return d.done=Math.abs(H)<=r&&Math.abs(i-re)<=a,d.value=d.done?i:re,d}const E=y(j);if(v)d.done=j>=p;else{const W=mt(T(j));d.done=Math.abs(W)<=r&&Math.abs(i-E)<=a}return d.value=d.done?i:E,d},toString:()=>{const j=Math.min(Xi(x),Ur),E=Qc(W=>x.next(j*W).value,j,30);return j+"ms "+E},toTransition:()=>{}};return x}_r.applyToOptions=t=>{const s=mf(t,100,_r);return t.ease=s.ease,t.duration=mt(s.duration),t.type="keyframes",t};const yf=5;function Zc(t,s,n){const r=Math.max(s-yf,0);return Mc(n-t(r),s-r)}function si({keyframes:t,velocity:s=0,power:n=.8,timeConstant:r=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:i,min:d,max:u,restDelta:c=.5,restSpeed:l}){const p=t[0],g={done:!1,value:p},v=z=>d!==void 0&&z<d||u!==void 0&&z>u,w=z=>d===void 0?u:u===void 0||Math.abs(d-z)<Math.abs(u-z)?d:u;let A=n*s;const N=p+A,I=i===void 0?N:i(N);I!==N&&(A=I-p);const C=z=>-A*Math.exp(-z/r),y=z=>I+C(z),T=z=>{const x=C(z),j=y(z);g.done=Math.abs(x)<=c,g.value=g.done?I:j};let L,O;const q=z=>{v(g.value)&&(L=z,O=_r({keyframes:[g.value,w(g.value)],velocity:Zc(y,z,g.value),damping:a,stiffness:o,restDelta:c,restSpeed:l}))};return q(0),{calculatedDuration:null,next:z=>{let x=!1;return!O&&L===void 0&&(x=!0,T(z),q(z)),L!==void 0&&z>=L?O.next(z-L):(!x&&T(z),g)}}}function jf(t,s,n){const r=[],a=n||cs.mix||Yc,o=t.length-1;for(let i=0;i<o;i++){let d=a(t[i],t[i+1]);if(s){const u=Array.isArray(s)?s[i]||yt:s;d=Zn(u,d)}r.push(d)}return r}function Xc(t,s,{clamp:n=!0,ease:r,mixer:a}={}){const o=t.length;if(Gi(o===s.length),o===1)return()=>s[0];if(o===2&&s[0]===s[1])return()=>s[1];const i=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),s=[...s].reverse());const d=jf(s,r,a),u=d.length,c=l=>{if(i&&l<t[0])return s[0];let p=0;if(u>1)for(;p<t.length-2&&!(l<t[p+1]);p++);const g=Rn(t[p],t[p+1],l);return d[p](g)};return n?l=>c(Bt(t[0],t[o-1],l)):c}function bf(t,s){const n=t[t.length-1];for(let r=1;r<=s;r++){const a=Rn(0,s,r);t.push(Se(n,1,a))}}function wf(t){const s=[0];return bf(s,t.length-1),s}function Nf(t,s){return t.map(n=>n*s)}function Cf(t,s){return t.map(()=>s||Oc).splice(0,t.length-1)}function wn({duration:t=300,keyframes:s,times:n,ease:r="easeInOut"}){const a=Ip(r)?r.map(Mo):Mo(r),o={done:!1,value:s[0]},i=Nf(n&&n.length===s.length?n:wf(s),t),d=Xc(i,s,{ease:Array.isArray(a)?a:Cf(s,a)});return{calculatedDuration:t,next:u=>(o.value=d(u),o.done=u>=t,o)}}const Sf=t=>t!==null;function Zr(t,{repeat:s,repeatType:n="loop"},r,a=1){const o=t.filter(Sf),d=a<0||s&&n!=="loop"&&s%2===1?0:o.length-1;return!d||r===void 0?o[d]:r}const kf={decay:si,inertia:si,tween:wn,keyframes:wn,spring:_r};function Jc(t){typeof t.type=="string"&&(t.type=kf[t.type])}class Ji{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(s=>{this.resolve=s})}notifyFinished(){this.resolve()}then(s,n){return this.finished.then(s,n)}}const Tf=t=>t/100;class qr extends Ji{constructor(s){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==tt.now()&&this.tick(tt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=s,this.initAnimation(),this.play(),s.autoplay===!1&&this.pause()}initAnimation(){const{options:s}=this;Jc(s);const{type:n=wn,repeat:r=0,repeatDelay:a=0,repeatType:o,velocity:i=0}=s;let{keyframes:d}=s;const u=n||wn;u!==wn&&typeof d[0]!="number"&&(this.mixKeyframes=Zn(Tf,Yc(d[0],d[1])),d=[0,100]);const c=u({...s,keyframes:d});o==="mirror"&&(this.mirroredGenerator=u({...s,keyframes:[...d].reverse(),velocity:-i})),c.calculatedDuration===null&&(c.calculatedDuration=Xi(c));const{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+a,this.totalDuration=this.resolvedDuration*(r+1)-a,this.generator=c}updateTime(s){const n=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(s,n=!1){const{generator:r,totalDuration:a,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:d,calculatedDuration:u}=this;if(this.startTime===null)return r.next(0);const{delay:c=0,keyframes:l,repeat:p,repeatType:g,repeatDelay:v,type:w,onUpdate:A,finalKeyframe:N}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),n?this.currentTime=s:this.updateTime(s);const I=this.currentTime-c*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?I<0:I>a;this.currentTime=Math.max(I,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let y=this.currentTime,T=r;if(p){const z=Math.min(this.currentTime,a)/d;let x=Math.floor(z),j=z%1;!j&&z>=1&&(j=1),j===1&&x--,x=Math.min(x,p+1),x%2&&(g==="reverse"?(j=1-j,v&&(j-=v/d)):g==="mirror"&&(T=i)),y=Bt(0,1,j)*d}let L;C?(this.delayState.value=l[0],L=this.delayState):L=T.next(y),o&&!C&&(L.value=o(L.value));let{done:O}=L;!C&&u!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const q=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return q&&w!==si&&(L.value=Zr(l,this.options,N,this.speed)),A&&A(L.value),q&&this.finish(),L}then(s,n){return this.finished.then(s,n)}get duration(){return vt(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+vt(s)}get time(){return vt(this.currentTime)}set time(s){s=mt(s),this.currentTime=s,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=s,this.tick(s))}getGeneratorVelocity(){const s=this.currentTime;if(s<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(s);const n=this.generator.next(s).value;return Zc(r=>this.generator.next(r).value,s,n)}get speed(){return this.playbackSpeed}set speed(s){const n=this.playbackSpeed!==s;n&&this.driver&&this.updateTime(tt.now()),this.playbackSpeed=s,n&&this.driver&&(this.time=vt(this.currentTime))}play(){if(this.isStopped)return;const{driver:s=uf,startTime:n}=this.options;this.driver||(this.driver=s(a=>this.tick(a))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(tt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}attachTimeline(s){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),s.observe(this)}}function Af(t){for(let s=1;s<t.length;s++)t[s]??(t[s]=t[s-1])}const Cs=t=>t*180/Math.PI,ni=t=>{const s=Cs(Math.atan2(t[1],t[0]));return ri(s)},Pf={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ni,rotateZ:ni,skewX:t=>Cs(Math.atan(t[1])),skewY:t=>Cs(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},ri=t=>(t=t%360,t<0&&(t+=360),t),Vo=ni,$o=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Oo=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Mf={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:$o,scaleY:Oo,scale:t=>($o(t)+Oo(t))/2,rotateX:t=>ri(Cs(Math.atan2(t[6],t[5]))),rotateY:t=>ri(Cs(Math.atan2(-t[2],t[0]))),rotateZ:Vo,rotate:Vo,skewX:t=>Cs(Math.atan(t[4])),skewY:t=>Cs(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ai(t){return t.includes("scale")?1:0}function ii(t,s){if(!t||t==="none")return ai(s);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,a;if(n)r=Mf,a=n;else{const d=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Pf,a=d}if(!a)return ai(s);const o=r[s],i=a[1].split(",").map(If);return typeof o=="function"?o(i):i[o]}const Df=(t,s)=>{const{transform:n="none"}=getComputedStyle(t);return ii(n,s)};function If(t){return parseFloat(t.trim())}const nn=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],rn=new Set(nn),Bo=t=>t===sn||t===ae,Ef=new Set(["x","y","z"]),Rf=nn.filter(t=>!Ef.has(t));function Lf(t){const s=[];return Rf.forEach(n=>{const r=t.getValue(n);r!==void 0&&(s.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),s}const ss={width:({x:t},{paddingLeft:s="0",paddingRight:n="0",boxSizing:r})=>{const a=t.max-t.min;return r==="border-box"?a:a-parseFloat(s)-parseFloat(n)},height:({y:t},{paddingTop:s="0",paddingBottom:n="0",boxSizing:r})=>{const a=t.max-t.min;return r==="border-box"?a:a-parseFloat(s)-parseFloat(n)},top:(t,{top:s})=>parseFloat(s),left:(t,{left:s})=>parseFloat(s),bottom:({y:t},{top:s})=>parseFloat(s)+(t.max-t.min),right:({x:t},{left:s})=>parseFloat(s)+(t.max-t.min),x:(t,{transform:s})=>ii(s,"x"),y:(t,{transform:s})=>ii(s,"y")};ss.translateX=ss.x;ss.translateY=ss.y;const ks=new Set;let oi=!1,li=!1,ci=!1;function ed(){if(li){const t=Array.from(ks).filter(r=>r.needsMeasurement),s=new Set(t.map(r=>r.element)),n=new Map;s.forEach(r=>{const a=Lf(r);a.length&&(n.set(r,a),r.render())}),t.forEach(r=>r.measureInitialState()),s.forEach(r=>{r.render();const a=n.get(r);a&&a.forEach(([o,i])=>{r.getValue(o)?.set(i)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}li=!1,oi=!1,ks.forEach(t=>t.complete(ci)),ks.clear()}function td(){ks.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(li=!0)})}function Ff(){ci=!0,td(),ed(),ci=!1}class eo{constructor(s,n,r,a,o,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...s],this.onComplete=n,this.name=r,this.motionValue=a,this.element=o,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(ks.add(this),oi||(oi=!0,we.read(td),we.resolveKeyframes(ed))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:n,element:r,motionValue:a}=this;if(s[0]===null){const o=a?.get(),i=s[s.length-1];if(o!==void 0)s[0]=o;else if(r&&n){const d=r.readValue(n,i);d!=null&&(s[0]=d)}s[0]===void 0&&(s[0]=i),a&&o===void 0&&a.set(s[0])}Af(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),ks.delete(this)}cancel(){this.state==="scheduled"&&(ks.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Vf=t=>t.startsWith("--");function sd(t,s,n){Vf(s)?t.style.setProperty(s,n):t.style[s]=n}const $f={};function nd(t,s){const n=Pc(t);return()=>$f[s]??n()}const Of=nd(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),rd=nd(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),gn=([t,s,n,r])=>`cubic-bezier(${t}, ${s}, ${n}, ${r})`,Uo={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:gn([0,.65,.55,1]),circOut:gn([.55,0,1,.45]),backIn:gn([.31,.01,.66,-.59]),backOut:gn([.33,1.53,.69,.99])};function ad(t,s){if(t)return typeof t=="function"?rd()?Qc(t,s):"ease-out":Bc(t)?gn(t):Array.isArray(t)?t.map(n=>ad(n,s)||Uo.easeOut):Uo[t]}function Bf(t,s,n,{delay:r=0,duration:a=300,repeat:o=0,repeatType:i="loop",ease:d="easeOut",times:u}={},c=void 0){const l={[s]:n};u&&(l.offset=u);const p=ad(d,a);Array.isArray(p)&&(l.easing=p);const g={delay:r,duration:a,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return c&&(g.pseudoElement=c),t.animate(l,g)}function id(t){return typeof t=="function"&&"applyToOptions"in t}function Uf({type:t,...s}){return id(t)&&rd()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class od extends Ji{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:n,name:r,keyframes:a,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:d,onComplete:u}=s;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=s,Gi(typeof s.type!="string");const c=Uf(s);this.animation=Bf(n,r,a,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Zr(a,this.options,d,this.speed);this.updateMotionValue&&this.updateMotionValue(l),sd(n,r,l),this.animation.cancel()}u?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const s=this.options?.element;!this.isPseudoElement&&s?.isConnected&&this.animation.commitStyles?.()}get duration(){const s=this.animation.effect?.getComputedTiming?.().duration||0;return vt(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+vt(s)}get time(){return vt(Number(this.animation.currentTime)||0)}set time(s){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=mt(s),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(s){s<0&&(this.finishedTime=null),this.animation.playbackRate=s}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(s){this.manualStartTime=this.animation.startTime=s}attachTimeline({timeline:s,rangeStart:n,rangeEnd:r,observe:a}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,s&&Of()?(this.animation.timeline=s,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),yt):a(this)}}const ld={anticipate:Fc,backInOut:Lc,circInOut:$c};function _f(t){return t in ld}function qf(t){typeof t.ease=="string"&&_f(t.ease)&&(t.ease=ld[t.ease])}const Sa=10;class Gf extends od{constructor(s){qf(s),Jc(s),super(s),s.startTime!==void 0&&s.autoplay!==!1&&(this.startTime=s.startTime),this.options=s}updateMotionValue(s){const{motionValue:n,onUpdate:r,onComplete:a,element:o,...i}=this.options;if(!n)return;if(s!==void 0){n.set(s);return}const d=new qr({...i,autoplay:!1}),u=Math.max(Sa,tt.now()-this.startTime),c=Bt(0,Sa,u-Sa),l=d.sample(u).value,{name:p}=this.options;o&&p&&sd(o,p,l),n.setWithVelocity(d.sample(Math.max(0,u-c)).value,l,c),d.stop()}}const _o=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Et.test(t)||t==="0")&&!t.startsWith("url("));function Kf(t){const s=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==s)return!0}function zf(t,s,n,r){const a=t[0];if(a===null)return!1;if(s==="display"||s==="visibility")return!0;const o=t[t.length-1],i=_o(a,s),d=_o(o,s);return!i||!d?!1:Kf(t)||(n==="spring"||id(n))&&r}function di(t){t.duration=0,t.type="keyframes"}const cd=new Set(["opacity","clipPath","filter","transform"]),Hf=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Wf(t){for(let s=0;s<t.length;s++)if(typeof t[s]=="string"&&Hf.test(t[s]))return!0;return!1}const Yf=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),Qf=Pc(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Zf(t){const{motionValue:s,name:n,repeatDelay:r,repeatType:a,damping:o,type:i,keyframes:d}=t;if(!(s?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:l}=s.owner.getProps();return Qf()&&n&&(cd.has(n)||Yf.has(n)&&Wf(d))&&(n!=="transform"||!l)&&!c&&!r&&a!=="mirror"&&o!==0&&i!=="inertia"}const Xf=40;class Jf extends Ji{constructor({autoplay:s=!0,delay:n=0,type:r="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:i="loop",keyframes:d,name:u,motionValue:c,element:l,...p}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=tt.now();const g={autoplay:s,delay:n,type:r,repeat:a,repeatDelay:o,repeatType:i,name:u,motionValue:c,element:l,...p},v=l?.KeyframeResolver||eo;this.keyframeResolver=new v(d,(w,A,N)=>this.onKeyframesResolved(w,A,g,!N),u,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(s,n,r,a){this.keyframeResolver=void 0;const{name:o,type:i,velocity:d,delay:u,isHandoff:c,onUpdate:l}=r;this.resolvedAt=tt.now();let p=!0;zf(s,o,i,d)||(p=!1,(cs.instantAnimations||!u)&&l?.(Zr(s,r,n)),s[0]=s[s.length-1],di(r),r.repeat=0);const v={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>Xf?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:s},w=p&&!c&&Zf(v),A=v.motionValue?.owner?.current;let N;if(w)try{N=new Gf({...v,element:A})}catch{N=new qr(v)}else N=new qr(v);N.finished.then(()=>{this.notifyFinished()}).catch(yt),this.pendingTimeline&&(this.stopTimeline=N.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=N}get finished(){return this._animation?this.animation.finished:this._finished}then(s,n){return this.finished.finally(s).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Ff()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(s){this.animation.time=s}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(s){this.animation.speed=s}get startTime(){return this.animation.startTime}attachTimeline(s){return this._animation?this.stopTimeline=this.animation.attachTimeline(s):this.pendingTimeline=s,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function dd(t,s,n,r=0,a=1){const o=Array.from(t).sort((c,l)=>c.sortNodePosition(l)).indexOf(s),i=t.size,d=(i-1)*r;return typeof n=="function"?n(o,i):a===1?o*r:d-o*r}const eg=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function tg(t){const s=eg.exec(t);if(!s)return[,];const[,n,r,a]=s;return[`--${n??r}`,a]}function ud(t,s,n=1){const[r,a]=tg(t);if(!r)return;const o=window.getComputedStyle(s).getPropertyValue(r);if(o){const i=o.trim();return kc(i)?parseFloat(i):i}return Wi(a)?ud(a,s,n+1):a}const sg={type:"spring",stiffness:500,damping:25,restSpeed:10},ng=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),rg={type:"keyframes",duration:.8},ag={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ig=(t,{keyframes:s})=>s.length>2?rg:rn.has(t)?t.startsWith("scale")?ng(s[1]):sg:ag;function md(t,s){if(t?.inherit&&s){const{inherit:n,...r}=t;return{...s,...r}}return t}function to(t,s){const n=t?.[s]??t?.default??t;return n!==t?md(n,t):n}const og=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function lg(t){for(const s in t)if(!og.has(s))return!0;return!1}const so=(t,s,n,r={},a,o)=>i=>{const d=to(r,t)||{},u=d.delay||r.delay||0;let{elapsed:c=0}=r;c=c-mt(u);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:s.getVelocity(),...d,delay:-c,onUpdate:g=>{s.set(g),d.onUpdate&&d.onUpdate(g)},onComplete:()=>{i(),d.onComplete&&d.onComplete()},name:t,motionValue:s,element:o?void 0:a};lg(d)||Object.assign(l,ig(t,l)),l.duration&&(l.duration=mt(l.duration)),l.repeatDelay&&(l.repeatDelay=mt(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let p=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(di(l),l.delay===0&&(p=!0)),(cs.instantAnimations||cs.skipAnimations||a?.shouldSkipAnimations)&&(p=!0,di(l),l.delay=0),l.allowFlatten=!d.type&&!d.ease,p&&!o&&s.get()!==void 0){const g=Zr(l.keyframes,d);if(g!==void 0){we.update(()=>{l.onUpdate(g),l.onComplete()});return}}return d.isSync?new qr(l):new Jf(l)};function qo(t){const s=[{},{}];return t?.values.forEach((n,r)=>{s[0][r]=n.get(),s[1][r]=n.getVelocity()}),s}function no(t,s,n,r){if(typeof s=="function"){const[a,o]=qo(r);s=s(n!==void 0?n:t.custom,a,o)}if(typeof s=="string"&&(s=t.variants&&t.variants[s]),typeof s=="function"){const[a,o]=qo(r);s=s(n!==void 0?n:t.custom,a,o)}return s}function Ts(t,s,n){const r=t.getProps();return no(r,s,n!==void 0?n:r.custom,t)}const hd=new Set(["width","height","top","left","right","bottom",...nn]),Go=30,cg=t=>!isNaN(parseFloat(t)),Nn={current:void 0};class dg{constructor(s,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const a=tt.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(s),this.owner=n.owner}setCurrent(s){this.current=s,this.updatedAt=tt.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=cg(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,n){this.events[s]||(this.events[s]=new Ki);const r=this.events[s].add(n);return s==="change"?()=>{r(),we.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,n){this.passiveEffect=s,this.stopPassiveEffect=n}set(s){this.passiveEffect?this.passiveEffect(s,this.updateAndNotify):this.updateAndNotify(s)}setWithVelocity(s,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-r}jump(s,n=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(s){this.dependents||(this.dependents=new Set),this.dependents.add(s)}removeDependent(s){this.dependents&&this.dependents.delete(s)}get(){return Nn.current&&Nn.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const s=tt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>Go)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Go);return Mc(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(s){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=s(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function As(t,s){return new dg(t,s)}const ui=t=>Array.isArray(t);function ug(t,s,n){t.hasValue(s)?t.getValue(s).set(n):t.addValue(s,As(n))}function mg(t){return ui(t)?t[t.length-1]||0:t}function hg(t,s){const n=Ts(t,s);let{transitionEnd:r={},transition:a={},...o}=n||{};o={...o,...r};for(const i in o){const d=mg(o[i]);ug(t,i,d)}}const Be=t=>!!(t&&t.getVelocity);function pg(t){return!!(Be(t)&&t.add)}function mi(t,s){const n=t.getValue("willChange");if(pg(n))return n.add(s);if(!n&&cs.WillChange){const r=new cs.WillChange("auto");t.addValue("willChange",r),r.add(s)}}function ro(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const fg="framerAppearId",pd="data-"+ro(fg);function fd(t){return t.props[pd]}function gg({protectedKeys:t,needsAnimating:s},n){const r=t.hasOwnProperty(n)&&s[n]!==!0;return s[n]=!1,r}function gd(t,s,{delay:n=0,transitionOverride:r,type:a}={}){let{transition:o,transitionEnd:i,...d}=s;const u=t.getDefaultTransition();o=o?md(o,u):u;const c=o?.reduceMotion;r&&(o=r);const l=[],p=a&&t.animationState&&t.animationState.getState()[a];for(const g in d){const v=t.getValue(g,t.latestValues[g]??null),w=d[g];if(w===void 0||p&&gg(p,g))continue;const A={delay:n,...to(o||{},g)},N=v.get();if(N!==void 0&&!v.isAnimating()&&!Array.isArray(w)&&w===N&&!A.velocity){we.update(()=>v.set(w));continue}let I=!1;if(window.MotionHandoffAnimation){const T=fd(t);if(T){const L=window.MotionHandoffAnimation(T,g,we);L!==null&&(A.startTime=L,I=!0)}}mi(t,g);const C=c??t.shouldReduceMotion;v.start(so(g,v,w,C&&hd.has(g)?{type:!1}:A,t,I));const y=v.animation;y&&l.push(y)}if(i){const g=()=>we.update(()=>{i&&hg(t,i)});l.length?Promise.all(l).then(g):g()}return l}function hi(t,s,n={}){const r=Ts(t,s,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(a=n.transitionOverride);const o=r?()=>Promise.all(gd(t,r,n)):()=>Promise.resolve(),i=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:c=0,staggerChildren:l,staggerDirection:p}=a;return xg(t,s,u,c,l,p,n)}:()=>Promise.resolve(),{when:d}=a;if(d){const[u,c]=d==="beforeChildren"?[o,i]:[i,o];return u().then(()=>c())}else return Promise.all([o(),i(n.delay)])}function xg(t,s,n=0,r=0,a=0,o=1,i){const d=[];for(const u of t.variantChildren)u.notify("AnimationStart",s),d.push(hi(u,s,{...i,delay:n+(typeof r=="function"?0:r)+dd(t.variantChildren,u,r,a,o)}).then(()=>u.notify("AnimationComplete",s)));return Promise.all(d)}function vg(t,s,n={}){t.notify("AnimationStart",s);let r;if(Array.isArray(s)){const a=s.map(o=>hi(t,o,n));r=Promise.all(a)}else if(typeof s=="string")r=hi(t,s,n);else{const a=typeof s=="function"?Ts(t,s,n.custom):s;r=Promise.all(gd(t,a,n))}return r.then(()=>{t.notify("AnimationComplete",s)})}const yg={test:t=>t==="auto",parse:t=>t},xd=t=>s=>s.test(t),vd=[sn,ae,Ot,ts,Kp,Gp,yg],Ko=t=>vd.find(xd(t));function jg(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ac(t):!0}const bg=new Set(["brightness","contrast","saturate","opacity"]);function wg(t){const[s,n]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[r]=n.match(Yi)||[];if(!r)return t;const a=n.replace(r,"");let o=bg.has(s)?1:0;return r!==n&&(o*=100),s+"("+o+a+")"}const Ng=/\b([a-z-]*)\(.*?\)/gu,pi={...Et,getAnimatableNone:t=>{const s=t.match(Ng);return s?s.map(wg).join(" "):t}},fi={...Et,getAnimatableNone:t=>{const s=Et.parse(t);return Et.createTransformer(t)(s.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},zo={...sn,transform:Math.round},Cg={rotate:ts,rotateX:ts,rotateY:ts,rotateZ:ts,scale:Nr,scaleX:Nr,scaleY:Nr,scaleZ:Nr,skew:ts,skewX:ts,skewY:ts,distance:ae,translateX:ae,translateY:ae,translateZ:ae,x:ae,y:ae,z:ae,perspective:ae,transformPerspective:ae,opacity:Ln,originX:Io,originY:Io,originZ:ae},ao={borderWidth:ae,borderTopWidth:ae,borderRightWidth:ae,borderBottomWidth:ae,borderLeftWidth:ae,borderRadius:ae,borderTopLeftRadius:ae,borderTopRightRadius:ae,borderBottomRightRadius:ae,borderBottomLeftRadius:ae,width:ae,maxWidth:ae,height:ae,maxHeight:ae,top:ae,right:ae,bottom:ae,left:ae,inset:ae,insetBlock:ae,insetBlockStart:ae,insetBlockEnd:ae,insetInline:ae,insetInlineStart:ae,insetInlineEnd:ae,padding:ae,paddingTop:ae,paddingRight:ae,paddingBottom:ae,paddingLeft:ae,paddingBlock:ae,paddingBlockStart:ae,paddingBlockEnd:ae,paddingInline:ae,paddingInlineStart:ae,paddingInlineEnd:ae,margin:ae,marginTop:ae,marginRight:ae,marginBottom:ae,marginLeft:ae,marginBlock:ae,marginBlockStart:ae,marginBlockEnd:ae,marginInline:ae,marginInlineStart:ae,marginInlineEnd:ae,fontSize:ae,backgroundPositionX:ae,backgroundPositionY:ae,...Cg,zIndex:zo,fillOpacity:Ln,strokeOpacity:Ln,numOctaves:zo},Sg={...ao,color:Ve,backgroundColor:Ve,outlineColor:Ve,fill:Ve,stroke:Ve,borderColor:Ve,borderTopColor:Ve,borderRightColor:Ve,borderBottomColor:Ve,borderLeftColor:Ve,filter:pi,WebkitFilter:pi,mask:fi,WebkitMask:fi},yd=t=>Sg[t],kg=new Set([pi,fi]);function jd(t,s){let n=yd(t);return kg.has(n)||(n=Et),n.getAnimatableNone?n.getAnimatableNone(s):void 0}const Tg=new Set(["auto","none","0"]);function Ag(t,s,n){let r=0,a;for(;r<t.length&&!a;){const o=t[r];typeof o=="string"&&!Tg.has(o)&&Zs(o).values.length&&(a=t[r]),r++}if(a&&n)for(const o of s)t[o]=jd(n,a)}class Pg extends eo{constructor(s,n,r,a,o){super(s,n,r,a,o,!0)}readKeyframes(){const{unresolvedKeyframes:s,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<s.length;l++){let p=s[l];if(typeof p=="string"&&(p=p.trim(),Wi(p))){const g=ud(p,n.current);g!==void 0&&(s[l]=g),l===s.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!hd.has(r)||s.length!==2)return;const[a,o]=s,i=Ko(a),d=Ko(o),u=Do(a),c=Do(o);if(u!==c&&ss[r]){this.needsMeasurement=!0;return}if(i!==d)if(Bo(i)&&Bo(d))for(let l=0;l<s.length;l++){const p=s[l];typeof p=="string"&&(s[l]=parseFloat(p))}else ss[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:s,name:n}=this,r=[];for(let a=0;a<s.length;a++)(s[a]===null||jg(s[a]))&&r.push(a);r.length&&Ag(s,r,n)}measureInitialState(){const{element:s,unresolvedKeyframes:n,name:r}=this;if(!s||!s.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ss[r](s.measureViewportBox(),window.getComputedStyle(s.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&s.getValue(r,a).jump(a,!1)}measureEndState(){const{element:s,name:n,unresolvedKeyframes:r}=this;if(!s||!s.current)return;const a=s.getValue(n);a&&a.jump(this.measuredOrigin,!1);const o=r.length-1,i=r[o];r[o]=ss[n](s.measureViewportBox(),window.getComputedStyle(s.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([d,u])=>{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function bd(t,s,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const a=n?.[t]??r.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(r=>r!=null)}const wd=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Mg(t){return Tc(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:io}=Uc(queueMicrotask,!1),At={x:!1,y:!1};function Nd(){return At.x||At.y}function Dg(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function Cd(t,s){const n=bd(t),r=new AbortController,a={passive:!0,...s,signal:r.signal};return[n,a,()=>r.abort()]}function Ig(t){return!(t.pointerType==="touch"||Nd())}function Eg(t,s,n={}){const[r,a,o]=Cd(t,n);return r.forEach(i=>{let d=!1,u=!1,c;const l=()=>{i.removeEventListener("pointerleave",w)},p=N=>{c&&(c(N),c=void 0),l()},g=N=>{d=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),u&&(u=!1,p(N))},v=()=>{d=!0,window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",g,a)},w=N=>{if(N.pointerType!=="touch"){if(d){u=!0;return}p(N)}},A=N=>{if(!Ig(N))return;u=!1;const I=s(i,N);typeof I=="function"&&(c=I,i.addEventListener("pointerleave",w,a))};i.addEventListener("pointerenter",A,a),i.addEventListener("pointerdown",v,a)}),o}const Sd=(t,s)=>s?t===s?!0:Sd(t,s.parentElement):!1,oo=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Rg=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Lg(t){return Rg.has(t.tagName)||t.isContentEditable===!0}const Fg=new Set(["INPUT","SELECT","TEXTAREA"]);function Vg(t){return Fg.has(t.tagName)||t.isContentEditable===!0}const Dr=new WeakSet;function Ho(t){return s=>{s.key==="Enter"&&t(s)}}function ka(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const $g=(t,s)=>{const n=t.currentTarget;if(!n)return;const r=Ho(()=>{if(Dr.has(n))return;ka(n,"down");const a=Ho(()=>{ka(n,"up")}),o=()=>ka(n,"cancel");n.addEventListener("keyup",a,s),n.addEventListener("blur",o,s)});n.addEventListener("keydown",r,s),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),s)};function Wo(t){return oo(t)&&!Nd()}const Yo=new WeakSet;function Og(t,s,n={}){const[r,a,o]=Cd(t,n),i=d=>{const u=d.currentTarget;if(!Wo(d)||Yo.has(d))return;Dr.add(u),n.stopPropagation&&Yo.add(d);const c=s(u,d),l=(v,w)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",g),Dr.has(u)&&Dr.delete(u),Wo(v)&&typeof c=="function"&&c(v,{success:w})},p=v=>{l(v,u===window||u===document||n.useGlobalTarget||Sd(u,v.target))},g=v=>{l(v,!1)};window.addEventListener("pointerup",p,a),window.addEventListener("pointercancel",g,a)};return r.forEach(d=>{(n.useGlobalTarget?window:d).addEventListener("pointerdown",i,a),Mg(d)&&(d.addEventListener("focus",c=>$g(c,a)),!Lg(d)&&!d.hasAttribute("tabindex")&&(d.tabIndex=0))}),o}function lo(t){return Tc(t)&&"ownerSVGElement"in t}const Ir=new WeakMap;let Er;const kd=(t,s,n)=>(r,a)=>a&&a[0]?a[0][t+"Size"]:lo(r)&&"getBBox"in r?r.getBBox()[s]:r[n],Bg=kd("inline","width","offsetWidth"),Ug=kd("block","height","offsetHeight");function _g({target:t,borderBoxSize:s}){Ir.get(t)?.forEach(n=>{n(t,{get width(){return Bg(t,s)},get height(){return Ug(t,s)}})})}function qg(t){t.forEach(_g)}function Gg(){typeof ResizeObserver>"u"||(Er=new ResizeObserver(qg))}function Kg(t,s){Er||Gg();const n=bd(t);return n.forEach(r=>{let a=Ir.get(r);a||(a=new Set,Ir.set(r,a)),a.add(s),Er?.observe(r)}),()=>{n.forEach(r=>{const a=Ir.get(r);a?.delete(s),a?.size||Er?.unobserve(r)})}}const Rr=new Set;let qs;function zg(){qs=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Rr.forEach(s=>s(t))},window.addEventListener("resize",qs)}function Hg(t){return Rr.add(t),qs||zg(),()=>{Rr.delete(t),!Rr.size&&typeof qs=="function"&&(window.removeEventListener("resize",qs),qs=void 0)}}function Qo(t,s){return typeof t=="function"?Hg(t):Kg(t,s)}function Wg(t){return lo(t)&&t.tagName==="svg"}function Yg(...t){const s=!Array.isArray(t[0]),n=s?0:-1,r=t[0+n],a=t[1+n],o=t[2+n],i=t[3+n],d=Xc(a,o,i);return s?d(r):d}const Qg=[...vd,Ve,Et],Zg=t=>Qg.find(xd(t)),Zo=()=>({translate:0,scale:1,origin:0,originPoint:0}),Gs=()=>({x:Zo(),y:Zo()}),Xo=()=>({min:0,max:0}),$e=()=>({x:Xo(),y:Xo()}),Xg=new WeakMap;function Xr(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Fn(t){return typeof t=="string"||Array.isArray(t)}const co=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],uo=["initial",...co];function Jr(t){return Xr(t.animate)||uo.some(s=>Fn(t[s]))}function Td(t){return!!(Jr(t)||t.variants)}function Jg(t,s,n){for(const r in s){const a=s[r],o=n[r];if(Be(a))t.addValue(r,a);else if(Be(o))t.addValue(r,As(a,{owner:t}));else if(o!==a)if(t.hasValue(r)){const i=t.getValue(r);i.liveStyle===!0?i.jump(a):i.hasAnimated||i.set(a)}else{const i=t.getStaticValue(r);t.addValue(r,As(i!==void 0?i:a,{owner:t}))}}for(const r in n)s[r]===void 0&&t.removeValue(r);return s}const gi={current:null},Ad={current:!1},ex=typeof window<"u";function tx(){if(Ad.current=!0,!!ex)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>gi.current=t.matches;t.addEventListener("change",s),s()}else gi.current=!1}const Jo=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Gr={};function Pd(t){Gr=t}function sx(){return Gr}class nx{scrapeMotionValuesFromProps(s,n,r){return{}}constructor({parent:s,props:n,presenceContext:r,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:i,visualState:d},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=eo,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const v=tt.now();this.renderScheduledAt<v&&(this.renderScheduledAt=v,we.render(this.render,!1,!0))};const{latestValues:c,renderState:l}=d;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=l,this.parent=s,this.props=n,this.presenceContext=r,this.depth=s?s.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=u,this.blockInitialAnimation=!!i,this.isControllingVariants=Jr(n),this.isVariantNode=Td(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:p,...g}=this.scrapeMotionValuesFromProps(n,{},this);for(const v in g){const w=g[v];c[v]!==void 0&&Be(w)&&w.set(c[v])}}mount(s){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=s,Xg.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Ad.current||tx(),this.shouldReduceMotion=gi.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Wt(this.notifyUpdate),Wt(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const n=this.features[s];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(s){this.children.add(s),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(s)}removeChild(s){this.children.delete(s),this.enteringChildren&&this.enteringChildren.delete(s)}bindToMotionValue(s,n){if(this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)(),n.accelerate&&cd.has(s)&&this.current instanceof HTMLElement){const{factory:i,keyframes:d,times:u,ease:c,duration:l}=n.accelerate,p=new od({element:this.current,name:s,keyframes:d,times:u,ease:c,duration:mt(l)}),g=i(p);this.valueSubscriptions.set(s,()=>{g(),p.cancel()});return}const r=rn.has(s);r&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",i=>{this.latestValues[s]=i,this.props.onUpdate&&we.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,s,n)),this.valueSubscriptions.set(s,()=>{a(),o&&o(),n.owner&&n.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in Gr){const n=Gr[s];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[s]&&a&&r(this.props)&&(this.features[s]=new a(this)),this.features[s]){const o=this.features[s];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):$e()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,n){this.latestValues[s]=n}update(s,n){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<Jo.length;r++){const a=Jo[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const o="on"+a,i=s[o];i&&(this.propEventSubscriptions[a]=this.on(a,i))}this.prevMotionValues=Jg(this,this.scrapeMotionValuesFromProps(s,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(s){return this.props.variants?this.props.variants[s]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(s){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(s),()=>n.variantChildren.delete(s)}addValue(s,n){const r=this.values.get(s);n!==r&&(r&&this.removeValue(s),this.bindToMotionValue(s,n),this.values.set(s,n),this.latestValues[s]=n.get())}removeValue(s){this.values.delete(s);const n=this.valueSubscriptions.get(s);n&&(n(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,n){if(this.props.values&&this.props.values[s])return this.props.values[s];let r=this.values.get(s);return r===void 0&&n!==void 0&&(r=As(n===null?void 0:n,{owner:this}),this.addValue(s,r)),r}readValue(s,n){let r=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:this.getBaseTargetFromProps(this.props,s)??this.readValueFromInstance(this.current,s,this.options);return r!=null&&(typeof r=="string"&&(kc(r)||Ac(r))?r=parseFloat(r):!Zg(r)&&Et.test(n)&&(r=jd(s,n)),this.setBaseTarget(s,Be(r)?r.get():r)),Be(r)?r.get():r}setBaseTarget(s,n){this.baseTarget[s]=n}getBaseTarget(s){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=no(this.props,n,this.presenceContext?.custom);o&&(r=o[s])}if(n&&r!==void 0)return r;const a=this.getBaseTargetFromProps(this.props,s);return a!==void 0&&!Be(a)?a:this.initialValues[s]!==void 0&&r===void 0?void 0:this.baseTarget[s]}on(s,n){return this.events[s]||(this.events[s]=new Ki),this.events[s].add(n)}notify(s,...n){this.events[s]&&this.events[s].notify(...n)}scheduleRenderMicrotask(){io.render(this.render)}}class Md extends nx{constructor(){super(...arguments),this.KeyframeResolver=Pg}sortInstanceNodePosition(s,n){return s.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(s,n){const r=s.style;return r?r[n]:void 0}removeValueFromRenderState(s,{vars:n,style:r}){delete n[s],delete r[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;Be(s)&&(this.childSubscription=s.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class hs{constructor(s){this.isMounted=!1,this.node=s}update(){}}function Dd({top:t,left:s,right:n,bottom:r}){return{x:{min:s,max:n},y:{min:t,max:r}}}function rx({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function ax(t,s){if(!s)return t;const n=s({x:t.left,y:t.top}),r=s({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Ta(t){return t===void 0||t===1}function xi({scale:t,scaleX:s,scaleY:n}){return!Ta(t)||!Ta(s)||!Ta(n)}function js(t){return xi(t)||Id(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Id(t){return el(t.x)||el(t.y)}function el(t){return t&&t!=="0%"}function Kr(t,s,n){const r=t-n,a=s*r;return n+a}function tl(t,s,n,r,a){return a!==void 0&&(t=Kr(t,a,r)),Kr(t,n,r)+s}function vi(t,s=0,n=1,r,a){t.min=tl(t.min,s,n,r,a),t.max=tl(t.max,s,n,r,a)}function Ed(t,{x:s,y:n}){vi(t.x,s.translate,s.scale,s.originPoint),vi(t.y,n.translate,n.scale,n.originPoint)}const sl=.999999999999,nl=1.0000000000001;function ix(t,s,n,r=!1){const a=n.length;if(!a)return;s.x=s.y=1;let o,i;for(let d=0;d<a;d++){o=n[d],i=o.projectionDelta;const{visualElement:u}=o.options;u&&u.props.style&&u.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&($t(t.x,-o.scroll.offset.x),$t(t.y,-o.scroll.offset.y)),i&&(s.x*=i.x.scale,s.y*=i.y.scale,Ed(t,i)),r&&js(o.latestValues)&&Lr(t,o.latestValues,o.layout?.layoutBox))}s.x<nl&&s.x>sl&&(s.x=1),s.y<nl&&s.y>sl&&(s.y=1)}function $t(t,s){t.min+=s,t.max+=s}function rl(t,s,n,r,a=.5){const o=Se(t.min,t.max,a);vi(t,s,n,o,r)}function al(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Lr(t,s,n){const r=n??t;rl(t.x,al(s.x,r.x),s.scaleX,s.scale,s.originX),rl(t.y,al(s.y,r.y),s.scaleY,s.scale,s.originY)}function Rd(t,s){return Dd(ax(t.getBoundingClientRect(),s))}function ox(t,s,n){const r=Rd(t,n),{scroll:a}=s;return a&&($t(r.x,a.offset.x),$t(r.y,a.offset.y)),r}const lx={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},cx=nn.length;function dx(t,s,n){let r="",a=!0;for(let o=0;o<cx;o++){const i=nn[o],d=t[i];if(d===void 0)continue;let u=!0;if(typeof d=="number")u=d===(i.startsWith("scale")?1:0);else{const c=parseFloat(d);u=i.startsWith("scale")?c===1:c===0}if(!u||n){const c=wd(d,ao[i]);if(!u){a=!1;const l=lx[i]||i;r+=`${l}(${c}) `}n&&(s[i]=c)}}return r=r.trim(),n?r=n(s,a?"":r):a&&(r="none"),r}function mo(t,s,n){const{style:r,vars:a,transformOrigin:o}=t;let i=!1,d=!1;for(const u in s){const c=s[u];if(rn.has(u)){i=!0;continue}else if(qc(u)){a[u]=c;continue}else{const l=wd(c,ao[u]);u.startsWith("origin")?(d=!0,o[u]=l):r[u]=l}}if(s.transform||(i||n?r.transform=dx(s,t.transform,n):r.transform&&(r.transform="none")),d){const{originX:u="50%",originY:c="50%",originZ:l=0}=o;r.transformOrigin=`${u} ${c} ${l}`}}function Ld(t,{style:s,vars:n},r,a){const o=t.style;let i;for(i in s)o[i]=s[i];a?.applyProjectionStyles(o,r);for(i in n)o.setProperty(i,n[i])}function il(t,s){return s.max===s.min?0:t/(s.max-s.min)*100}const pn={correct:(t,s)=>{if(!s.target)return t;if(typeof t=="string")if(ae.test(t))t=parseFloat(t);else return t;const n=il(t,s.target.x),r=il(t,s.target.y);return`${n}% ${r}%`}},ux={correct:(t,{treeScale:s,projectionDelta:n})=>{const r=t,a=Et.parse(t);if(a.length>5)return r;const o=Et.createTransformer(t),i=typeof a[0]!="number"?1:0,d=n.x.scale*s.x,u=n.y.scale*s.y;a[0+i]/=d,a[1+i]/=u;const c=Se(d,u,.5);return typeof a[2+i]=="number"&&(a[2+i]/=c),typeof a[3+i]=="number"&&(a[3+i]/=c),o(a)}},yi={borderRadius:{...pn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:pn,borderTopRightRadius:pn,borderBottomLeftRadius:pn,borderBottomRightRadius:pn,boxShadow:ux};function Fd(t,{layout:s,layoutId:n}){return rn.has(t)||t.startsWith("origin")||(s||n!==void 0)&&(!!yi[t]||t==="opacity")}function ho(t,s,n){const r=t.style,a=s?.style,o={};if(!r)return o;for(const i in r)(Be(r[i])||a&&Be(a[i])||Fd(i,t)||n?.getValue(i)?.liveStyle!==void 0)&&(o[i]=r[i]);return o}function mx(t){return window.getComputedStyle(t)}class hx extends Md{constructor(){super(...arguments),this.type="html",this.renderInstance=Ld}readValueFromInstance(s,n){if(rn.has(n))return this.projection?.isProjecting?ai(n):Df(s,n);{const r=mx(s),a=(qc(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(s,{transformPagePoint:n}){return Rd(s,n)}build(s,n,r){mo(s,n,r.transformTemplate)}scrapeMotionValuesFromProps(s,n,r){return ho(s,n,r)}}const px={offset:"stroke-dashoffset",array:"stroke-dasharray"},fx={offset:"strokeDashoffset",array:"strokeDasharray"};function gx(t,s,n=1,r=0,a=!0){t.pathLength=1;const o=a?px:fx;t[o.offset]=`${-r}`,t[o.array]=`${s} ${n}`}const xx=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Vd(t,{attrX:s,attrY:n,attrScale:r,pathLength:a,pathSpacing:o=1,pathOffset:i=0,...d},u,c,l){if(mo(t,d,c),u){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:p,style:g}=t;p.transform&&(g.transform=p.transform,delete p.transform),(g.transform||p.transformOrigin)&&(g.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),g.transform&&(g.transformBox=l?.transformBox??"fill-box",delete p.transformBox);for(const v of xx)p[v]!==void 0&&(g[v]=p[v],delete p[v]);s!==void 0&&(p.x=s),n!==void 0&&(p.y=n),r!==void 0&&(p.scale=r),a!==void 0&&gx(p,a,o,i,!1)}const $d=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),Od=t=>typeof t=="string"&&t.toLowerCase()==="svg";function vx(t,s,n,r){Ld(t,s,void 0,r);for(const a in s.attrs)t.setAttribute($d.has(a)?a:ro(a),s.attrs[a])}function Bd(t,s,n){const r=ho(t,s,n);for(const a in t)if(Be(t[a])||Be(s[a])){const o=nn.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[o]=t[a]}return r}class yx extends Md{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=$e}getBaseTargetFromProps(s,n){return s[n]}readValueFromInstance(s,n){if(rn.has(n)){const r=yd(n);return r&&r.default||0}return n=$d.has(n)?n:ro(n),s.getAttribute(n)}scrapeMotionValuesFromProps(s,n,r){return Bd(s,n,r)}build(s,n,r){Vd(s,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(s,n,r,a){vx(s,n,r,a)}mount(s){this.isSVGTag=Od(s.tagName),super.mount(s)}}const jx=uo.length;function Ud(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Ud(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const s={};for(let n=0;n<jx;n++){const r=uo[n],a=t.props[r];(Fn(a)||a===!1)&&(s[r]=a)}return s}function _d(t,s){if(!Array.isArray(s))return!1;const n=s.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(s[r]!==t[r])return!1;return!0}const bx=[...co].reverse(),wx=co.length;function Nx(t){return s=>Promise.all(s.map(({animation:n,options:r})=>vg(t,n,r)))}function Cx(t){let s=Nx(t),n=ol(),r=!0,a=!1;const o=c=>(l,p)=>{const g=Ts(t,p,c==="exit"?t.presenceContext?.custom:void 0);if(g){const{transition:v,transitionEnd:w,...A}=g;l={...l,...A,...w}}return l};function i(c){s=c(t)}function d(c){const{props:l}=t,p=Ud(t.parent)||{},g=[],v=new Set;let w={},A=1/0;for(let I=0;I<wx;I++){const C=bx[I],y=n[C],T=l[C]!==void 0?l[C]:p[C],L=Fn(T),O=C===c?y.isActive:null;O===!1&&(A=I);let q=T===p[C]&&T!==l[C]&&L;if(q&&(r||a)&&t.manuallyAnimateOnMount&&(q=!1),y.protectedKeys={...w},!y.isActive&&O===null||!T&&!y.prevProp||Xr(T)||typeof T=="boolean")continue;if(C==="exit"&&y.isActive&&O!==!0){y.prevResolvedValues&&(w={...w,...y.prevResolvedValues});continue}const z=Sx(y.prevProp,T);let x=z||C===c&&y.isActive&&!q&&L||I>A&&L,j=!1;const E=Array.isArray(T)?T:[T];let W=E.reduce(o(C),{});O===!1&&(W={});const{prevResolvedValues:ie={}}=y,R={...ie,...W},re=te=>{x=!0,v.has(te)&&(j=!0,v.delete(te)),y.needsAnimating[te]=!0;const ce=t.getValue(te);ce&&(ce.liveStyle=!1)};for(const te in R){const ce=W[te],V=ie[te];if(w.hasOwnProperty(te))continue;let ue=!1;ui(ce)&&ui(V)?ue=!_d(ce,V):ue=ce!==V,ue?ce!=null?re(te):v.add(te):ce!==void 0&&v.has(te)?re(te):y.protectedKeys[te]=!0}y.prevProp=T,y.prevResolvedValues=W,y.isActive&&(w={...w,...W}),(r||a)&&t.blockInitialAnimation&&(x=!1);const H=q&&z;x&&(!H||j)&&g.push(...E.map(te=>{const ce={type:C};if(typeof te=="string"&&(r||a)&&!H&&t.manuallyAnimateOnMount&&t.parent){const{parent:V}=t,ue=Ts(V,te);if(V.enteringChildren&&ue){const{delayChildren:$}=ue.transition||{};ce.delay=dd(V.enteringChildren,t,$)}}return{animation:te,options:ce}}))}if(v.size){const I={};if(typeof l.initial!="boolean"){const C=Ts(t,Array.isArray(l.initial)?l.initial[0]:l.initial);C&&C.transition&&(I.transition=C.transition)}v.forEach(C=>{const y=t.getBaseTarget(C),T=t.getValue(C);T&&(T.liveStyle=!0),I[C]=y??null}),g.push({animation:I})}let N=!!g.length;return r&&(l.initial===!1||l.initial===l.animate)&&!t.manuallyAnimateOnMount&&(N=!1),r=!1,a=!1,N?s(g):Promise.resolve()}function u(c,l){if(n[c].isActive===l)return Promise.resolve();t.variantChildren?.forEach(g=>g.animationState?.setActive(c,l)),n[c].isActive=l;const p=d(c);for(const g in n)n[g].protectedKeys={};return p}return{animateChanges:d,setActive:u,setAnimateFunction:i,getState:()=>n,reset:()=>{n=ol(),a=!0}}}function Sx(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!_d(s,t):!1}function ys(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ol(){return{animate:ys(!0),whileInView:ys(),whileHover:ys(),whileTap:ys(),whileDrag:ys(),whileFocus:ys(),exit:ys()}}function ji(t,s){t.min=s.min,t.max=s.max}function Tt(t,s){ji(t.x,s.x),ji(t.y,s.y)}function ll(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const qd=1e-4,kx=1-qd,Tx=1+qd,Gd=.01,Ax=0-Gd,Px=0+Gd;function st(t){return t.max-t.min}function Mx(t,s,n){return Math.abs(t-s)<=n}function cl(t,s,n,r=.5){t.origin=r,t.originPoint=Se(s.min,s.max,t.origin),t.scale=st(n)/st(s),t.translate=Se(n.min,n.max,t.origin)-t.originPoint,(t.scale>=kx&&t.scale<=Tx||isNaN(t.scale))&&(t.scale=1),(t.translate>=Ax&&t.translate<=Px||isNaN(t.translate))&&(t.translate=0)}function Cn(t,s,n,r){cl(t.x,s.x,n.x,r?r.originX:void 0),cl(t.y,s.y,n.y,r?r.originY:void 0)}function dl(t,s,n,r=0){const a=r?Se(n.min,n.max,r):n.min;t.min=a+s.min,t.max=t.min+st(s)}function Dx(t,s,n,r){dl(t.x,s.x,n.x,r?.x),dl(t.y,s.y,n.y,r?.y)}function ul(t,s,n,r=0){const a=r?Se(n.min,n.max,r):n.min;t.min=s.min-a,t.max=t.min+st(s)}function zr(t,s,n,r){ul(t.x,s.x,n.x,r?.x),ul(t.y,s.y,n.y,r?.y)}function ml(t,s,n,r,a){return t-=s,t=Kr(t,1/n,r),a!==void 0&&(t=Kr(t,1/a,r)),t}function Ix(t,s=0,n=1,r=.5,a,o=t,i=t){if(Ot.test(s)&&(s=parseFloat(s),s=Se(i.min,i.max,s/100)-i.min),typeof s!="number")return;let d=Se(o.min,o.max,r);t===o&&(d-=s),t.min=ml(t.min,s,n,d,a),t.max=ml(t.max,s,n,d,a)}function hl(t,s,[n,r,a],o,i){Ix(t,s[n],s[r],s[a],s.scale,o,i)}const Ex=["x","scaleX","originX"],Rx=["y","scaleY","originY"];function pl(t,s,n,r){hl(t.x,s,Ex,n?n.x:void 0,r?r.x:void 0),hl(t.y,s,Rx,n?n.y:void 0,r?r.y:void 0)}function fl(t){return t.translate===0&&t.scale===1}function Kd(t){return fl(t.x)&&fl(t.y)}function gl(t,s){return t.min===s.min&&t.max===s.max}function Lx(t,s){return gl(t.x,s.x)&&gl(t.y,s.y)}function xl(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function zd(t,s){return xl(t.x,s.x)&&xl(t.y,s.y)}function vl(t){return st(t.x)/st(t.y)}function yl(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Vt(t){return[t("x"),t("y")]}function Fx(t,s,n){let r="";const a=t.x.translate/s.x,o=t.y.translate/s.y,i=n?.z||0;if((a||o||i)&&(r=`translate3d(${a}px, ${o}px, ${i}px) `),(s.x!==1||s.y!==1)&&(r+=`scale(${1/s.x}, ${1/s.y}) `),n){const{transformPerspective:c,rotate:l,rotateX:p,rotateY:g,skewX:v,skewY:w}=n;c&&(r=`perspective(${c}px) ${r}`),l&&(r+=`rotate(${l}deg) `),p&&(r+=`rotateX(${p}deg) `),g&&(r+=`rotateY(${g}deg) `),v&&(r+=`skewX(${v}deg) `),w&&(r+=`skewY(${w}deg) `)}const d=t.x.scale*s.x,u=t.y.scale*s.y;return(d!==1||u!==1)&&(r+=`scale(${d}, ${u})`),r||"none"}const Hd=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Vx=Hd.length,jl=t=>typeof t=="string"?parseFloat(t):t,bl=t=>typeof t=="number"||ae.test(t);function $x(t,s,n,r,a,o){a?(t.opacity=Se(0,n.opacity??1,Ox(r)),t.opacityExit=Se(s.opacity??1,0,Bx(r))):o&&(t.opacity=Se(s.opacity??1,n.opacity??1,r));for(let i=0;i<Vx;i++){const d=Hd[i];let u=wl(s,d),c=wl(n,d);if(u===void 0&&c===void 0)continue;u||(u=0),c||(c=0),u===0||c===0||bl(u)===bl(c)?(t[d]=Math.max(Se(jl(u),jl(c),r),0),(Ot.test(c)||Ot.test(u))&&(t[d]+="%")):t[d]=c}(s.rotate||n.rotate)&&(t.rotate=Se(s.rotate||0,n.rotate||0,r))}function wl(t,s){return t[s]!==void 0?t[s]:t.borderRadius}const Ox=Wd(0,.5,Vc),Bx=Wd(.5,.95,yt);function Wd(t,s,n){return r=>r<t?0:r>s?1:n(Rn(t,s,r))}function Ux(t,s,n){const r=Be(t)?t:As(t);return r.start(so("",r,s,n)),r.animation}function Vn(t,s,n,r={passive:!0}){return t.addEventListener(s,n,r),()=>t.removeEventListener(s,n)}const _x=(t,s)=>t.depth-s.depth;class qx{constructor(){this.children=[],this.isDirty=!1}add(s){qi(this.children,s),this.isDirty=!0}remove(s){Or(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(_x),this.isDirty=!1,this.children.forEach(s)}}function Gx(t,s){const n=tt.now(),r=({timestamp:a})=>{const o=a-n;o>=s&&(Wt(r),t(o-s))};return we.setup(r,!0),()=>Wt(r)}function Fr(t){return Be(t)?t.get():t}class Kx{constructor(){this.members=[]}add(s){qi(this.members,s);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===s||r===this.lead||r===this.prevLead)continue;const a=r.instance;(!a||a.isConnected===!1)&&!r.snapshot&&(Or(this.members,r),r.unmount())}s.scheduleRender()}remove(s){if(Or(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(s){for(let n=this.members.indexOf(s)-1;n>=0;n--){const r=this.members[n];if(r.isPresent!==!1&&r.instance?.isConnected!==!1)return this.promote(r),!0}return!1}promote(s,n){const r=this.lead;if(s!==r&&(this.prevLead=r,this.lead=s,s.show(),r)){r.updateSnapshot(),s.scheduleRender();const{layoutDependency:a}=r.options,{layoutDependency:o}=s.options;(a===void 0||a!==o)&&(s.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(s.snapshot=r.snapshot,s.snapshot.latestValues=r.animationValues||r.latestValues),s.root?.isUpdating&&(s.isLayoutDirty=!0)),s.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(s=>{s.options.onExitComplete?.(),s.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(s=>s.instance&&s.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const Vr={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Aa=["","X","Y","Z"],zx=1e3;let Hx=0;function Pa(t,s,n,r){const{latestValues:a}=s;a[t]&&(n[t]=a[t],s.setStaticValue(t,0),r&&(r[t]=0))}function Yd(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const n=fd(s);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",we,!(a||o))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&Yd(r)}function Qd({attachResizeListener:t,defaultParent:s,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(i={},d=s?.()){this.id=Hx++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Qx),this.nodes.forEach(sv),this.nodes.forEach(nv),this.nodes.forEach(Zx)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=i,this.root=d?d.root||d:this,this.path=d?[...d.path,d]:[],this.parent=d,this.depth=d?d.depth+1:0;for(let u=0;u<this.path.length;u++)this.path[u].shouldResetTransform=!0;this.root===this&&(this.nodes=new qx)}addEventListener(i,d){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new Ki),this.eventHandlers.get(i).add(d)}notifyListeners(i,...d){const u=this.eventHandlers.get(i);u&&u.notify(...d)}hasListeners(i){return this.eventHandlers.has(i)}mount(i){if(this.instance)return;this.isSVG=lo(i)&&!Wg(i),this.instance=i;const{layoutId:d,layout:u,visualElement:c}=this.options;if(c&&!c.current&&c.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(u||d)&&(this.isLayoutDirty=!0),t){let l,p=0;const g=()=>this.root.updateBlockedByResize=!1;we.read(()=>{p=window.innerWidth}),t(i,()=>{const v=window.innerWidth;v!==p&&(p=v,this.root.updateBlockedByResize=!0,l&&l(),l=Gx(g,250),Vr.hasAnimatedSinceResize&&(Vr.hasAnimatedSinceResize=!1,this.nodes.forEach(Sl)))})}d&&this.root.registerSharedNode(d,this),this.options.animate!==!1&&c&&(d||u)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:p,hasRelativeLayoutChanged:g,layout:v})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const w=this.options.transition||c.getDefaultTransition()||lv,{onLayoutAnimationStart:A,onLayoutAnimationComplete:N}=c.getProps(),I=!this.targetLayout||!zd(this.targetLayout,v),C=!p&&g;if(this.options.layoutRoot||this.resumeFrom||C||p&&(I||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const y={...to(w,"layout"),onPlay:A,onComplete:N};(c.shouldReduceMotion||this.options.layoutRoot)&&(y.delay=0,y.type=!1),this.startAnimation(y),this.setAnimationOrigin(l,C)}else p||Sl(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=v})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(rv),this.animationId++)}getTransformTemplate(){const{visualElement:i}=this.options;return i&&i.getProps().transformTemplate}willUpdate(i=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Yd(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const p=this.path[l];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:d,layout:u}=this.options;if(d===void 0&&!u)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),i&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const u=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),u&&this.nodes.forEach(Jx),this.nodes.forEach(Nl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Cl);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ev),this.nodes.forEach(tv),this.nodes.forEach(Wx),this.nodes.forEach(Yx)):this.nodes.forEach(Cl),this.clearAllSnapshots();const d=tt.now();qe.delta=Bt(0,1e3/60,d-qe.timestamp),qe.timestamp=d,qe.isProcessing=!0,ja.update.process(qe),ja.preRender.process(qe),ja.render.process(qe),qe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,io.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Xx),this.sharedNodes.forEach(av)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,we.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){we.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!st(this.snapshot.measuredBox.x)&&!st(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let u=0;u<this.path.length;u++)this.path[u].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=$e()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:d}=this.options;d&&d.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let d=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(d=!1),d&&this.instance){const u=r(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:u,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:u}}}resetTransform(){if(!a)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,d=this.projectionDelta&&!Kd(this.projectionDelta),u=this.getTransformTemplate(),c=u?u(this.latestValues,""):void 0,l=c!==this.prevTransformTemplateValue;i&&this.instance&&(d||js(this.latestValues)||l)&&(a(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const d=this.measurePageBox();let u=this.removeElementScroll(d);return i&&(u=this.removeTransform(u)),cv(u),{animationId:this.root.animationId,measuredBox:d,layoutBox:u,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return $e();const d=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(dv))){const{scroll:c}=this.root;c&&($t(d.x,c.offset.x),$t(d.y,c.offset.y))}return d}removeElementScroll(i){const d=$e();if(Tt(d,i),this.scroll?.wasRoot)return d;for(let u=0;u<this.path.length;u++){const c=this.path[u],{scroll:l,options:p}=c;c!==this.root&&l&&p.layoutScroll&&(l.wasRoot&&Tt(d,i),$t(d.x,l.offset.x),$t(d.y,l.offset.y))}return d}applyTransform(i,d=!1,u){const c=u||$e();Tt(c,i);for(let l=0;l<this.path.length;l++){const p=this.path[l];!d&&p.options.layoutScroll&&p.scroll&&p!==p.root&&($t(c.x,-p.scroll.offset.x),$t(c.y,-p.scroll.offset.y)),js(p.latestValues)&&Lr(c,p.latestValues,p.layout?.layoutBox)}return js(this.latestValues)&&Lr(c,this.latestValues,this.layout?.layoutBox),c}removeTransform(i){const d=$e();Tt(d,i);for(let u=0;u<this.path.length;u++){const c=this.path[u];if(!js(c.latestValues))continue;let l;c.instance&&(xi(c.latestValues)&&c.updateSnapshot(),l=$e(),Tt(l,c.measurePageBox())),pl(d,c.latestValues,c.snapshot?.layoutBox,l)}return js(this.latestValues)&&pl(d,this.latestValues),d}setTargetDelta(i){this.targetDelta=i,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(i){this.options={...this.options,...i,crossfade:i.crossfade!==void 0?i.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==qe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(i=!1){const d=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=d.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=d.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=d.isSharedProjectionDirty);const u=!!this.resumingFrom||this!==d;if(!(i||u&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:p}=this.options;if(!this.layout||!(l||p))return;this.resolvedRelativeTargetAt=qe.timestamp;const g=this.getClosestProjectingParent();g&&this.linkedParentVersion!==g.layoutVersion&&!g.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&g&&g.layout?this.createRelativeTarget(g,this.layout.layoutBox,g.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=$e(),this.targetWithTransforms=$e()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Dx(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Tt(this.target,this.layout.layoutBox),Ed(this.target,this.targetDelta)):Tt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&g&&!!g.resumingFrom==!!this.resumingFrom&&!g.options.layoutScroll&&g.target&&this.animationProgress!==1?this.createRelativeTarget(g,this.target,g.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||xi(this.parent.latestValues)||Id(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(i,d,u){this.relativeParent=i,this.linkedParentVersion=i.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=$e(),this.relativeTargetOrigin=$e(),zr(this.relativeTargetOrigin,d,u,this.options.layoutAnchor||void 0),Tt(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const i=this.getLead(),d=!!this.resumingFrom||this!==i;let u=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(u=!1),d&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(u=!1),this.resolvedRelativeTargetAt===qe.timestamp&&(u=!1),u)return;const{layout:c,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||l))return;Tt(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,g=this.treeScale.y;ix(this.layoutCorrected,this.treeScale,this.path,d),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=$e());const{target:v}=i;if(!v){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(ll(this.prevProjectionDelta.x,this.projectionDelta.x),ll(this.prevProjectionDelta.y,this.projectionDelta.y)),Cn(this.projectionDelta,this.layoutCorrected,v,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==g||!yl(this.projectionDelta.x,this.prevProjectionDelta.x)||!yl(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",v))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const d=this.getStack();d&&d.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Gs(),this.projectionDelta=Gs(),this.projectionDeltaWithTransform=Gs()}setAnimationOrigin(i,d=!1){const u=this.snapshot,c=u?u.latestValues:{},l={...this.latestValues},p=Gs();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!d;const g=$e(),v=u?u.source:void 0,w=this.layout?this.layout.source:void 0,A=v!==w,N=this.getStack(),I=!N||N.members.length<=1,C=!!(A&&!I&&this.options.crossfade===!0&&!this.path.some(ov));this.animationProgress=0;let y;this.mixTargetDelta=T=>{const L=T/1e3;kl(p.x,i.x,L),kl(p.y,i.y,L),this.setTargetDelta(p),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(zr(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),iv(this.relativeTarget,this.relativeTargetOrigin,g,L),y&&Lx(this.relativeTarget,y)&&(this.isProjectionDirty=!1),y||(y=$e()),Tt(y,this.relativeTarget)),A&&(this.animationValues=l,$x(l,c,this.latestValues,L,C,I)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Wt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=we.update(()=>{Vr.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=As(0)),this.motionValue.jump(0,!1),this.currentAnimation=Ux(this.motionValue,[0,1e3],{...i,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),i.onUpdate&&i.onUpdate(d)},onStop:()=>{},onComplete:()=>{i.onComplete&&i.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const i=this.getStack();i&&i.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(zx),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const i=this.getLead();let{targetWithTransforms:d,target:u,layout:c,latestValues:l}=i;if(!(!d||!u||!c)){if(this!==i&&this.layout&&c&&Zd(this.options.animationType,this.layout.layoutBox,c.layoutBox)){u=this.target||$e();const p=st(this.layout.layoutBox.x);u.x.min=i.target.x.min,u.x.max=u.x.min+p;const g=st(this.layout.layoutBox.y);u.y.min=i.target.y.min,u.y.max=u.y.min+g}Tt(d,u),Lr(d,l),Cn(this.projectionDeltaWithTransform,this.layoutCorrected,d,l)}}registerSharedNode(i,d){this.sharedNodes.has(i)||this.sharedNodes.set(i,new Kx),this.sharedNodes.get(i).add(d);const c=d.options.initialPromotionConfig;d.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(d):void 0})}isLead(){const i=this.getStack();return i?i.lead===this:!0}getLead(){const{layoutId:i}=this.options;return i?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:i}=this.options;return i?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:i}=this.options;if(i)return this.root.sharedNodes.get(i)}promote({needsReset:i,transition:d,preserveFollowOpacity:u}={}){const c=this.getStack();c&&c.promote(this,u),i&&(this.projectionDelta=void 0,this.needsReset=!0),d&&this.setOptions({transition:d})}relegate(){const i=this.getStack();return i?i.relegate(this):!1}resetSkewAndRotation(){const{visualElement:i}=this.options;if(!i)return;let d=!1;const{latestValues:u}=i;if((u.z||u.rotate||u.rotateX||u.rotateY||u.rotateZ||u.skewX||u.skewY)&&(d=!0),!d)return;const c={};u.z&&Pa("z",i,c,this.animationValues);for(let l=0;l<Aa.length;l++)Pa(`rotate${Aa[l]}`,i,c,this.animationValues),Pa(`skew${Aa[l]}`,i,c,this.animationValues);i.render();for(const l in c)i.setStaticValue(l,c[l]),this.animationValues&&(this.animationValues[l]=c[l]);i.scheduleRender()}applyProjectionStyles(i,d){if(!this.instance||this.isSVG)return;if(!this.isVisible){i.visibility="hidden";return}const u=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,i.visibility="",i.opacity="",i.pointerEvents=Fr(d?.pointerEvents)||"",i.transform=u?u(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(i.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,i.pointerEvents=Fr(d?.pointerEvents)||""),this.hasProjected&&!js(this.latestValues)&&(i.transform=u?u({},""):"none",this.hasProjected=!1);return}i.visibility="";const l=c.animationValues||c.latestValues;this.applyTransformsToTarget();let p=Fx(this.projectionDeltaWithTransform,this.treeScale,l);u&&(p=u(l,p)),i.transform=p;const{x:g,y:v}=this.projectionDelta;i.transformOrigin=`${g.origin*100}% ${v.origin*100}% 0`,c.animationValues?i.opacity=c===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:i.opacity=c===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const w in yi){if(l[w]===void 0)continue;const{correct:A,applyTo:N,isCSSVariable:I}=yi[w],C=p==="none"?l[w]:A(l[w],c);if(N){const y=N.length;for(let T=0;T<y;T++)i[N[T]]=C}else I?this.options.visualElement.renderState.vars[w]=C:i[w]=C}this.options.layoutId&&(i.pointerEvents=c===this?Fr(d?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(Nl),this.root.sharedNodes.clear()}}}function Wx(t){t.updateLayout()}function Yx(t){const s=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&s&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:a}=t.options,o=s.source!==t.layout.source;if(a==="size")Vt(l=>{const p=o?s.measuredBox[l]:s.layoutBox[l],g=st(p);p.min=n[l].min,p.max=p.min+g});else if(a==="x"||a==="y"){const l=a==="x"?"y":"x";ji(o?s.measuredBox[l]:s.layoutBox[l],n[l])}else Zd(a,s.layoutBox,n)&&Vt(l=>{const p=o?s.measuredBox[l]:s.layoutBox[l],g=st(n[l]);p.max=p.min+g,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+g)});const i=Gs();Cn(i,n,s.layoutBox);const d=Gs();o?Cn(d,t.applyTransform(r,!0),s.measuredBox):Cn(d,n,s.layoutBox);const u=!Kd(i);let c=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:p,layout:g}=l;if(p&&g){const v=t.options.layoutAnchor||void 0,w=$e();zr(w,s.layoutBox,p.layoutBox,v);const A=$e();zr(A,n,g.layoutBox,v),zd(w,A)||(c=!0),l.options.layoutRoot&&(t.relativeTarget=A,t.relativeTargetOrigin=w,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:d,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:c})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Qx(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Zx(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Xx(t){t.clearSnapshot()}function Nl(t){t.clearMeasurements()}function Jx(t){t.isLayoutDirty=!0,t.updateLayout()}function Cl(t){t.isLayoutDirty=!1}function ev(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function tv(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function Sl(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function sv(t){t.resolveTargetDelta()}function nv(t){t.calcProjection()}function rv(t){t.resetSkewAndRotation()}function av(t){t.removeLeadSnapshot()}function kl(t,s,n){t.translate=Se(s.translate,0,n),t.scale=Se(s.scale,1,n),t.origin=s.origin,t.originPoint=s.originPoint}function Tl(t,s,n,r){t.min=Se(s.min,n.min,r),t.max=Se(s.max,n.max,r)}function iv(t,s,n,r){Tl(t.x,s.x,n.x,r),Tl(t.y,s.y,n.y,r)}function ov(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const lv={duration:.45,ease:[.4,0,.1,1]},Al=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Pl=Al("applewebkit/")&&!Al("chrome/")?Math.round:yt;function Ml(t){t.min=Pl(t.min),t.max=Pl(t.max)}function cv(t){Ml(t.x),Ml(t.y)}function Zd(t,s,n){return t==="position"||t==="preserve-aspect"&&!Mx(vl(s),vl(n),.2)}function dv(t){return t!==t.root&&t.scroll?.wasRoot}const uv=Qd({attachResizeListener:(t,s)=>Vn(t,"resize",s),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Ma={current:void 0},Xd=Qd({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Ma.current){const t=new uv({});t.mount(window),t.setOptions({layoutScroll:!0}),Ma.current=t}return Ma.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),po=h.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function mv(t=!0){const s=h.useContext(_i);if(s===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=s,o=h.useId();h.useEffect(()=>{if(t)return a(o)},[t]);const i=h.useCallback(()=>t&&r&&r(o),[o,r,t]);return!n&&r?[!1,i]:[!0]}const Jd=h.createContext({strict:!1}),Dl={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Il=!1;function hv(){if(Il)return;const t={};for(const s in Dl)t[s]={isEnabled:n=>Dl[s].some(r=>!!n[r])};Pd(t),Il=!0}function eu(){return hv(),sx()}function pv(t){const s=eu();for(const n in t)s[n]={...s[n],...t[n]};Pd(s)}const fv=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Hr(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||fv.has(t)}let tu=t=>!Hr(t);function gv(t){typeof t=="function"&&(tu=s=>s.startsWith("on")?!Hr(s):t(s))}try{gv(require("@emotion/is-prop-valid").default)}catch{}function xv(t,s,n){const r={};for(const a in t)a==="values"&&typeof t.values=="object"||Be(t[a])||(tu(a)||n===!0&&Hr(a)||!s&&!Hr(a)||t.draggable&&a.startsWith("onDrag"))&&(r[a]=t[a]);return r}const ea=h.createContext({});function vv(t,s){if(Jr(t)){const{initial:n,animate:r}=t;return{initial:n===!1||Fn(n)?n:void 0,animate:Fn(r)?r:void 0}}return t.inherit!==!1?s:{}}function yv(t){const{initial:s,animate:n}=vv(t,h.useContext(ea));return h.useMemo(()=>({initial:s,animate:n}),[El(s),El(n)])}function El(t){return Array.isArray(t)?t.join(" "):t}const fo=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function su(t,s,n){for(const r in s)!Be(s[r])&&!Fd(r,n)&&(t[r]=s[r])}function jv({transformTemplate:t},s){return h.useMemo(()=>{const n=fo();return mo(n,s,t),Object.assign({},n.vars,n.style)},[s])}function bv(t,s){const n=t.style||{},r={};return su(r,n,t),Object.assign(r,jv(t,s)),r}function wv(t,s){const n={},r=bv(t,s);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const nu=()=>({...fo(),attrs:{}});function Nv(t,s,n,r){const a=h.useMemo(()=>{const o=nu();return Vd(o,s,Od(r),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};su(o,t.style,t),a.style={...o,...a.style}}return a}const Cv=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function go(t){return typeof t!="string"||t.includes("-")?!1:!!(Cv.indexOf(t)>-1||/[A-Z]/u.test(t))}function Sv(t,s,n,{latestValues:r},a,o=!1,i){const u=(i??go(t)?Nv:wv)(s,r,a,t),c=xv(s,typeof t=="string",o),l=t!==h.Fragment?{...c,...u,ref:n}:{},{children:p}=s,g=h.useMemo(()=>Be(p)?p.get():p,[p]);return h.createElement(t,{...l,children:g})}function kv({scrapeMotionValuesFromProps:t,createRenderState:s},n,r,a){return{latestValues:Tv(n,r,a,t),renderState:s()}}function Tv(t,s,n,r){const a={},o=r(t,{});for(const g in o)a[g]=Fr(o[g]);let{initial:i,animate:d}=t;const u=Jr(t),c=Td(t);s&&c&&!u&&t.inherit!==!1&&(i===void 0&&(i=s.initial),d===void 0&&(d=s.animate));let l=n?n.initial===!1:!1;l=l||i===!1;const p=l?d:i;if(p&&typeof p!="boolean"&&!Xr(p)){const g=Array.isArray(p)?p:[p];for(let v=0;v<g.length;v++){const w=no(t,g[v]);if(w){const{transitionEnd:A,transition:N,...I}=w;for(const C in I){let y=I[C];if(Array.isArray(y)){const T=l?y.length-1:0;y=y[T]}y!==null&&(a[C]=y)}for(const C in A)a[C]=A[C]}}}return a}const ru=t=>(s,n)=>{const r=h.useContext(ea),a=h.useContext(_i),o=()=>kv(t,s,r,a);return n?o():Qn(o)},Av=ru({scrapeMotionValuesFromProps:ho,createRenderState:fo}),Pv=ru({scrapeMotionValuesFromProps:Bd,createRenderState:nu}),Mv=Symbol.for("motionComponentSymbol");function Dv(t,s,n){const r=h.useRef(n);h.useInsertionEffect(()=>{r.current=n});const a=h.useRef(null);return h.useCallback(o=>{o&&t.onMount?.(o);const i=r.current;if(typeof i=="function")if(o){const d=i(o);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):i(o);else i&&(i.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const au=h.createContext({});function $s(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Iv(t,s,n,r,a,o){const{visualElement:i}=h.useContext(ea),d=h.useContext(Jd),u=h.useContext(_i),c=h.useContext(po),l=c.reducedMotion,p=c.skipAnimations,g=h.useRef(null),v=h.useRef(!1);r=r||d.renderer,!g.current&&r&&(g.current=r(t,{visualState:s,parent:i,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:l,skipAnimations:p,isSVG:o}),v.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const w=g.current,A=h.useContext(au);w&&!w.projection&&a&&(w.type==="html"||w.type==="svg")&&Ev(g.current,n,a,A);const N=h.useRef(!1);h.useInsertionEffect(()=>{w&&N.current&&w.update(n,u)});const I=n[pd],C=h.useRef(!!I&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(I)&&window.MotionHasOptimisedAnimation?.(I));return Sc(()=>{v.current=!0,w&&(N.current=!0,window.MotionIsMounted=!0,w.updateFeatures(),w.scheduleRenderMicrotask(),C.current&&w.animationState&&w.animationState.animateChanges())}),h.useEffect(()=>{w&&(!C.current&&w.animationState&&w.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(I)}),C.current=!1),w.enteringChildren=void 0)}),w}function Ev(t,s,n,r){const{layoutId:a,layout:o,drag:i,dragConstraints:d,layoutScroll:u,layoutRoot:c,layoutAnchor:l,layoutCrossfade:p}=s;t.projection=new n(t.latestValues,s["data-framer-portal-id"]?void 0:iu(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!i||d&&$s(d),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:p,layoutScroll:u,layoutRoot:c,layoutAnchor:l})}function iu(t){if(t)return t.options.allowProjection!==!1?t.projection:iu(t.parent)}function Da(t,{forwardMotionProps:s=!1,type:n}={},r,a){r&&pv(r);const o=n?n==="svg":go(t),i=o?Pv:Av;function d(c,l){let p;const g={...h.useContext(po),...c,layoutId:Rv(c)},{isStatic:v}=g,w=yv(c),A=i(c,v);if(!v&&typeof window<"u"){Lv();const N=Fv(g);p=N.MeasureLayout,w.visualElement=Iv(t,A,g,a,N.ProjectionNode,o)}return e.jsxs(ea.Provider,{value:w,children:[p&&w.visualElement?e.jsx(p,{visualElement:w.visualElement,...g}):null,Sv(t,c,Dv(A,w.visualElement,l),A,v,s,o)]})}d.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const u=h.forwardRef(d);return u[Mv]=t,u}function Rv({layoutId:t}){const s=h.useContext(Cc).id;return s&&t!==void 0?s+"-"+t:t}function Lv(t,s){h.useContext(Jd).strict}function Fv(t){const s=eu(),{drag:n,layout:r}=s;if(!n&&!r)return{};const a={...n,...r};return{MeasureLayout:n?.isEnabled(t)||r?.isEnabled(t)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function Vv(t,s){if(typeof Proxy>"u")return Da;const n=new Map,r=(o,i)=>Da(o,i,t,s),a=(o,i)=>r(o,i);return new Proxy(a,{get:(o,i)=>i==="create"?r:(n.has(i)||n.set(i,Da(i,void 0,t,s)),n.get(i))})}const $v=(t,s)=>s.isSVG??go(t)?new yx(s):new hx(s,{allowProjection:t!==h.Fragment});class Ov extends hs{constructor(s){super(s),s.animationState||(s.animationState=Cx(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Xr(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:n}=this.node.prevProps||{};s!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Bv=0;class Uv extends hs{constructor(){super(...arguments),this.id=Bv++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===r)return;if(s&&r===!1){if(this.isExitComplete){const{initial:o,custom:i}=this.node.getProps();if(typeof o=="string"){const d=Ts(this.node,o,i);if(d){const{transition:u,transitionEnd:c,...l}=d;for(const p in l)this.node.getValue(p)?.jump(l[p])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!s);n&&!s&&a.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:s,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),s&&(this.unmount=s(this.id))}unmount(){}}const _v={animation:{Feature:Ov},exit:{Feature:Uv}};function er(t){return{point:{x:t.pageX,y:t.pageY}}}const qv=t=>s=>oo(s)&&t(s,er(s));function Sn(t,s,n,r){return Vn(t,s,qv(n),r)}const ou=({current:t})=>t?t.ownerDocument.defaultView:null,Rl=(t,s)=>Math.abs(t-s);function Gv(t,s){const n=Rl(t.x,s.x),r=Rl(t.y,s.y);return Math.sqrt(n**2+r**2)}const Ll=new Set(["auto","scroll"]);class lu{constructor(s,n,{transformPagePoint:r,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=v=>{this.handleScroll(v.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Cr(this.lastRawMoveEventInfo,this.transformPagePoint));const v=Ia(this.lastMoveEventInfo,this.history),w=this.startEvent!==null,A=Gv(v.offset,{x:0,y:0})>=this.distanceThreshold;if(!w&&!A)return;const{point:N}=v,{timestamp:I}=qe;this.history.push({...N,timestamp:I});const{onStart:C,onMove:y}=this.handlers;w||(C&&C(this.lastMoveEvent,v),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,v)},this.handlePointerMove=(v,w)=>{this.lastMoveEvent=v,this.lastRawMoveEventInfo=w,this.lastMoveEventInfo=Cr(w,this.transformPagePoint),we.update(this.updatePoint,!0)},this.handlePointerUp=(v,w)=>{this.end();const{onEnd:A,onSessionEnd:N,resumeAnimation:I}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&I&&I(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Ia(v.type==="pointercancel"?this.lastMoveEventInfo:Cr(w,this.transformPagePoint),this.history);this.startEvent&&A&&A(v,C),N&&N(v,C)},!oo(s))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=i,this.contextWindow=a||window;const u=er(s),c=Cr(u,this.transformPagePoint),{point:l}=c,{timestamp:p}=qe;this.history=[{...l,timestamp:p}];const{onSessionStart:g}=n;g&&g(s,Ia(c,this.history)),this.removeListeners=Zn(Sn(this.contextWindow,"pointermove",this.handlePointerMove),Sn(this.contextWindow,"pointerup",this.handlePointerUp),Sn(this.contextWindow,"pointercancel",this.handlePointerUp)),d&&this.startScrollTracking(d)}startScrollTracking(s){let n=s.parentElement;for(;n;){const r=getComputedStyle(n);(Ll.has(r.overflowX)||Ll.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(s){const n=this.scrollPositions.get(s);if(!n)return;const r=s===window,a=r?{x:window.scrollX,y:window.scrollY}:{x:s.scrollLeft,y:s.scrollTop},o={x:a.x-n.x,y:a.y-n.y};o.x===0&&o.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(s,a),we.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Wt(this.updatePoint)}}function Cr(t,s){return s?{point:s(t.point)}:t}function Fl(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Ia({point:t},s){return{point:t,delta:Fl(t,cu(s)),offset:Fl(t,Kv(s)),velocity:zv(s,.1)}}function Kv(t){return t[0]}function cu(t){return t[t.length-1]}function zv(t,s){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const a=cu(t);for(;n>=0&&(r=t[n],!(a.timestamp-r.timestamp>mt(s)));)n--;if(!r)return{x:0,y:0};r===t[0]&&t.length>2&&a.timestamp-r.timestamp>mt(s)*2&&(r=t[1]);const o=vt(a.timestamp-r.timestamp);if(o===0)return{x:0,y:0};const i={x:(a.x-r.x)/o,y:(a.y-r.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function Hv(t,{min:s,max:n},r){return s!==void 0&&t<s?t=r?Se(s,t,r.min):Math.max(t,s):n!==void 0&&t>n&&(t=r?Se(n,t,r.max):Math.min(t,n)),t}function Vl(t,s,n){return{min:s!==void 0?t.min+s:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Wv(t,{top:s,left:n,bottom:r,right:a}){return{x:Vl(t.x,n,a),y:Vl(t.y,s,r)}}function $l(t,s){let n=s.min-t.min,r=s.max-t.max;return s.max-s.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function Yv(t,s){return{x:$l(t.x,s.x),y:$l(t.y,s.y)}}function Qv(t,s){let n=.5;const r=st(t),a=st(s);return a>r?n=Rn(s.min,s.max-r,t.min):r>a&&(n=Rn(t.min,t.max-a,s.min)),Bt(0,1,n)}function Zv(t,s){const n={};return s.min!==void 0&&(n.min=s.min-t.min),s.max!==void 0&&(n.max=s.max-t.min),n}const bi=.35;function Xv(t=bi){return t===!1?t=0:t===!0&&(t=bi),{x:Ol(t,"left","right"),y:Ol(t,"top","bottom")}}function Ol(t,s,n){return{min:Bl(t,s),max:Bl(t,n)}}function Bl(t,s){return typeof t=="number"?t:t[s]||0}const Jv=new WeakMap;class ey{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=$e(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=s}start(s,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=p=>{n&&this.snapToCursor(er(p).point),this.stopAnimation()},i=(p,g)=>{const{drag:v,dragPropagation:w,onDragStart:A}=this.getProps();if(v&&!w&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Dg(v),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=g,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Vt(I=>{let C=this.getAxisMotionValue(I).get()||0;if(Ot.test(C)){const{projection:y}=this.visualElement;if(y&&y.layout){const T=y.layout.layoutBox[I];T&&(C=st(T)*(parseFloat(C)/100))}}this.originPoint[I]=C}),A&&we.update(()=>A(p,g),!1,!0),mi(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},d=(p,g)=>{this.latestPointerEvent=p,this.latestPanInfo=g;const{dragPropagation:v,dragDirectionLock:w,onDirectionLock:A,onDrag:N}=this.getProps();if(!v&&!this.openDragLock)return;const{offset:I}=g;if(w&&this.currentDirection===null){this.currentDirection=sy(I),this.currentDirection!==null&&A&&A(this.currentDirection);return}this.updateAxis("x",g.point,I),this.updateAxis("y",g.point,I),this.visualElement.render(),N&&we.update(()=>N(p,g),!1,!0)},u=(p,g)=>{this.latestPointerEvent=p,this.latestPanInfo=g,this.stop(p,g),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new lu(s,{onSessionStart:o,onStart:i,onMove:d,onSessionEnd:u,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:r,contextWindow:ou(this.visualElement),element:this.visualElement.current})}stop(s,n){const r=s||this.latestPointerEvent,a=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!r)return;const{velocity:i}=a;this.startAnimation(i);const{onDragEnd:d}=this.getProps();d&&we.postRender(()=>d(r,a))}cancel(){this.isDragging=!1;const{projection:s,animationState:n}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(s,n,r){const{drag:a}=this.getProps();if(!r||!Sr(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let i=this.originPoint[s]+r[s];this.constraints&&this.constraints[s]&&(i=Hv(i,this.constraints[s],this.elastic[s])),o.set(i)}resolveConstraints(){const{dragConstraints:s,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;s&&$s(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&r?this.constraints=Wv(r.layoutBox,s):this.constraints=!1,this.elastic=Xv(n),a!==this.constraints&&!$s(s)&&r&&this.constraints&&!this.hasMutatedConstraints&&Vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Zv(r.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:n}=this.getProps();if(!s||!$s(s))return!1;const r=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=ox(r,a.root,this.visualElement.getTransformPagePoint());let i=Yv(a.layout.layoutBox,o);if(n){const d=n(rx(i));this.hasMutatedConstraints=!!d,d&&(i=Dd(d))}return i}startAnimation(s){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:d}=this.getProps(),u=this.constraints||{},c=Vt(l=>{if(!Sr(l,n,this.currentDirection))return;let p=u&&u[l]||{};(i===!0||i===l)&&(p={min:0,max:0});const g=a?200:1e6,v=a?40:1e7,w={type:"inertia",velocity:r?s[l]:0,bounceStiffness:g,bounceDamping:v,timeConstant:750,restDelta:1,restSpeed:10,...o,...p};return this.startAxisValueAnimation(l,w)});return Promise.all(c).then(d)}startAxisValueAnimation(s,n){const r=this.getAxisMotionValue(s);return mi(this.visualElement,s),r.start(so(s,r,0,n,this.visualElement,!1))}stopAnimation(){Vt(s=>this.getAxisMotionValue(s).stop())}getAxisMotionValue(s){const n=`_drag${s.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(s,(r.initial?r.initial[s]:void 0)||0)}snapToCursor(s){Vt(n=>{const{drag:r}=this.getProps();if(!Sr(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(n);if(a&&a.layout){const{min:i,max:d}=a.layout.layoutBox[n],u=o.get()||0;o.set(s[n]-Se(i,d,.5)+u)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!$s(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Vt(i=>{const d=this.getAxisMotionValue(i);if(d&&this.constraints!==!1){const u=d.get();a[i]=Qv({min:u,max:u},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),Vt(i=>{if(!Sr(i,s,null))return;const d=this.getAxisMotionValue(i),{min:u,max:c}=this.constraints[i];d.set(Se(u,c,a[i]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Jv.set(this.visualElement,this);const s=this.visualElement.current,n=Sn(s,"pointerdown",c=>{const{drag:l,dragListener:p=!0}=this.getProps(),g=c.target,v=g!==s&&Vg(g);l&&p&&!v&&this.start(c)});let r;const a=()=>{const{dragConstraints:c}=this.getProps();$s(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),r||(r=ty(s,c.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,i=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),we.read(a);const d=Vn(window,"resize",()=>this.scalePositionWithinConstraints()),u=o.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:l})=>{this.isDragging&&l&&(Vt(p=>{const g=this.getAxisMotionValue(p);g&&(this.originPoint[p]+=c[p].translate,g.set(g.get()+c[p].translate))}),this.visualElement.render())}));return()=>{d(),n(),i(),u&&u(),r&&r()}}getProps(){const s=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:i=bi,dragMomentum:d=!0}=s;return{...s,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:o,dragElastic:i,dragMomentum:d}}}function Ul(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function ty(t,s,n){const r=Qo(t,Ul(n)),a=Qo(s,Ul(n));return()=>{r(),a()}}function Sr(t,s,n){return(s===!0||s===t)&&(n===null||n===t)}function sy(t,s=10){let n=null;return Math.abs(t.y)>s?n="y":Math.abs(t.x)>s&&(n="x"),n}class ny extends hs{constructor(s){super(s),this.removeGroupControls=yt,this.removeListeners=yt,this.controls=new ey(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||yt}update(){const{dragControls:s}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};s!==n&&(this.removeGroupControls(),s&&(this.removeGroupControls=s.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Ea=t=>(s,n)=>{t&&we.update(()=>t(s,n),!1,!0)};class ry extends hs{constructor(){super(...arguments),this.removePointerDownListener=yt}onPointerDown(s){this.session=new lu(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ou(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:Ea(s),onStart:Ea(n),onMove:Ea(r),onEnd:(o,i)=>{delete this.session,a&&we.postRender(()=>a(o,i))}}}mount(){this.removePointerDownListener=Sn(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Ra=!1;class ay extends h.Component{componentDidMount(){const{visualElement:s,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:o}=s;o&&(n.group&&n.group.add(o),r&&r.register&&a&&r.register(o),Ra&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Vr.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:n,visualElement:r,drag:a,isPresent:o}=this.props,{projection:i}=r;return i&&(i.isPresent=o,s.layoutDependency!==n&&i.setOptions({...i.options,layoutDependency:n}),Ra=!0,a||s.layoutDependency!==n||n===void 0||s.isPresent!==o?i.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?i.promote():i.relegate()||we.postRender(()=>{const d=i.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:s,layoutAnchor:n}=this.props,{projection:r}=s;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),io.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=s;Ra=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function du(t){const[s,n]=mv(),r=h.useContext(Cc);return e.jsx(ay,{...t,layoutGroup:r,switchLayoutGroup:h.useContext(au),isPresent:s,safeToRemove:n})}const iy={pan:{Feature:ry},drag:{Feature:ny,ProjectionNode:Xd,MeasureLayout:du}};function _l(t,s,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,o=r[a];o&&we.postRender(()=>o(s,er(s)))}class oy extends hs{mount(){const{current:s}=this.node;s&&(this.unmount=Eg(s,(n,r)=>(_l(this.node,r,"Start"),a=>_l(this.node,a,"End"))))}unmount(){}}class ly extends hs{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Zn(Vn(this.node.current,"focus",()=>this.onFocus()),Vn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ql(t,s,n){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),o=r[a];o&&we.postRender(()=>o(s,er(s)))}class cy extends hs{mount(){const{current:s}=this.node;if(!s)return;
2const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=Og(s,(a,o)=>(ql(this.node,o,"Start"),(i,{success:d})=>ql(this.node,i,d?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:r?.tap===!1})}unmount(){}}const wi=new WeakMap,La=new WeakMap,dy=t=>{const s=wi.get(t.target);s&&s(t)},uy=t=>{t.forEach(dy)};function my({root:t,...s}){const n=t||document;La.has(n)||La.set(n,{});const r=La.get(n),a=JSON.stringify(s);return r[a]||(r[a]=new IntersectionObserver(uy,{root:t,...s})),r[a]}function hy(t,s,n){const r=my(s);return wi.set(t,n),r.observe(t),()=>{wi.delete(t),r.unobserve(t)}}const py={some:0,all:1};class fy extends hs{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:s={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:o}=s,i={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:py[a]},d=u=>{const{isIntersecting:c}=u;if(this.isInView===c||(this.isInView=c,o&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:l,onViewportLeave:p}=this.node.getProps(),g=c?l:p;g&&g(u)};this.stopObserver=hy(this.node.current,i,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:n}=this.node;["amount","margin","root"].some(gy(s,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function gy({viewport:t={}},{viewport:s={}}={}){return n=>t[n]!==s[n]}const xy={inView:{Feature:fy},tap:{Feature:cy},focus:{Feature:ly},hover:{Feature:oy}},vy={layout:{ProjectionNode:Xd,MeasureLayout:du}},yy={..._v,...xy,...iy,...vy},uu=Vv(yy,$v);function mu(t){const s=Qn(()=>As(t)),{isStatic:n}=h.useContext(po);if(n){const[,r]=h.useState(t);h.useEffect(()=>s.on("change",r),[])}return s}function hu(t,s){const n=mu(s()),r=()=>n.set(s());return r(),Sc(()=>{const a=()=>we.preRender(r,!1,!0),o=t.map(i=>i.on("change",a));return()=>{o.forEach(i=>i()),Wt(r)}}),n}function jy(t){Nn.current=[],t();const s=hu(Nn.current,t);return Nn.current=void 0,s}function by(t,s,n,r){if(typeof t=="function")return jy(t);const o=typeof s=="function"?s:Yg(s,n,r),i=Array.isArray(t)?Gl(t,o):Gl([t],([u])=>o(u)),d=Array.isArray(t)?void 0:t.accelerate;return d&&!d.isTransformed&&typeof s!="function"&&Array.isArray(n)&&r?.clamp!==!1&&(i.accelerate={...d,times:s,keyframes:n,isTransformed:!0}),i}function Gl(t,s){const n=Qn(()=>[]);return hu(t,()=>{n.length=0;const r=t.length;for(let a=0;a<r;a++)n[a]=t[a].get();return s(n)})}const pu=h.createContext(null);function wy(t,s,n,r){if(!r)return t;const a=t.findIndex(l=>l.value===s);if(a===-1)return t;const o=r>0?1:-1,i=t[a+o];if(!i)return t;const d=t[a],u=i.layout,c=Se(u.min,u.max,.5);return o===1&&d.layout.max+n>c||o===-1&&d.layout.min+n<c?Sp(t,a,a+o):t}function Ny({children:t,as:s="ul",axis:n="y",onReorder:r,values:a,...o},i){const d=Qn(()=>uu[s]),u=[],c=h.useRef(!1),l=h.useRef(null),p={axis:n,groupRef:l,registerItem:(w,A)=>{const N=u.findIndex(I=>w===I.value);N!==-1?u[N].layout=A[n]:u.push({value:w,layout:A[n]}),u.sort(Cy)},updateOrder:(w,A,N)=>{if(c.current)return;const I=wy(u,w,A,N);if(u!==I){c.current=!0;const C=[...a];for(let y=0;y<I.length;y++)if(u[y].value!==I[y].value){const T=a.indexOf(u[y].value),L=a.indexOf(I[y].value);T!==-1&&L!==-1&&([C[T],C[L]]=[C[L],C[T]]);break}r(C)}}};h.useEffect(()=>{c.current=!1});const g=w=>{l.current=w,typeof i=="function"?i(w):i&&(i.current=w)},v={overflowAnchor:"none",...o.style};return e.jsx(d,{...o,style:v,ref:g,ignoreStrict:!0,children:e.jsx(pu.Provider,{value:p,children:t})})}const xo=h.forwardRef(Ny);function Cy(t,s){return t.layout.min-s.layout.min}const kr=50,Kl=25,Sy=new Set(["auto","scroll"]),kn=new WeakMap,Tn=new WeakMap;let xn=null;function ky(){if(xn){const t=Ni(xn,"y");t&&(Tn.delete(t),kn.delete(t));const s=Ni(xn,"x");s&&s!==t&&(Tn.delete(s),kn.delete(s)),xn=null}}function Ty(t,s){const n=getComputedStyle(t),r=s==="x"?n.overflowX:n.overflowY,a=t===document.body||t===document.documentElement;return Sy.has(r)||a}function Ni(t,s){let n=t?.parentElement;for(;n;){if(Ty(n,s))return n;n=n.parentElement}return null}function Ay(t,s,n){const r=s.getBoundingClientRect(),a=n==="x"?Math.max(0,r.left):Math.max(0,r.top),o=n==="x"?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),i=t-a,d=o-t;if(i<kr){const u=1-i/kr;return{amount:-Kl*u*u,edge:"start"}}else if(d<kr){const u=1-d/kr;return{amount:Kl*u*u,edge:"end"}}return{amount:0,edge:null}}function Py(t,s,n,r){if(!t)return;xn=t;const a=Ni(t,n);if(!a)return;const o=s-(n==="x"?window.scrollX:window.scrollY),{amount:i,edge:d}=Ay(o,a,n);if(d===null){Tn.delete(a),kn.delete(a);return}const u=Tn.get(a),c=a===document.body||a===document.documentElement;if(u!==d){if(!(d==="start"&&r<0||d==="end"&&r>0))return;Tn.set(a,d);const p=n==="x"?a.scrollWidth-(c?window.innerWidth:a.clientWidth):a.scrollHeight-(c?window.innerHeight:a.clientHeight);kn.set(a,p)}if(i>0){const l=kn.get(a);if((n==="x"?c?window.scrollX:a.scrollLeft:c?window.scrollY:a.scrollTop)>=l)return}n==="x"?c?window.scrollBy({left:i}):a.scrollLeft+=i:c?window.scrollBy({top:i}):a.scrollTop+=i}function zl(t,s=0){return Be(t)?t:mu(s)}function My({children:t,style:s={},value:n,as:r="li",onDrag:a,onDragEnd:o,layout:i=!0,...d},u){const c=Qn(()=>uu[r]),l=h.useContext(pu),p={x:zl(s.x),y:zl(s.y)},g=by([p.x,p.y],([I,C])=>I||C?1:"unset"),{axis:v,registerItem:w,updateOrder:A,groupRef:N}=l;return e.jsx(c,{drag:v,...d,dragSnapToOrigin:!0,style:{...s,x:p.x,y:p.y,zIndex:g},layout:i,onDrag:(I,C)=>{const{velocity:y,point:T}=C,L=p[v].get();A(n,L,y[v]),Py(N.current,T[v],v,y[v]),a&&a(I,C)},onDragEnd:(I,C)=>{ky(),o&&o(I,C)},onLayoutMeasure:I=>{w(n,I)},ref:u,ignoreStrict:!0,children:t})}const vo=h.forwardRef(My),Dy=3200,Iy=5e3,Ey=1e4,Ry=1e4;function fu(t){let s=0,n=0,r=0;for(const o of t.lineup??[])o.effectiveRole==="tour_manager"?n++:o.effectiveRole==="support"?r++:s++;const a=r>0?t.openersDrivingCents??0:0;return s*Iy+n*Ey+r*Ry+a}
2function Ly(t){return t.openersOverride??fu(t)}function $n(t){const s=new Date(t.date).getTime();return Number.isNaN(s)?!1:s<Date.now()-10800*1e3}function On(t){return t!=null&&t!==0?t:null}function gu(t){return t.venueSold!=null?t.venueSold:t.venueTix!=null&&t.venueTix>0?t.venueTix*Dy:null}function Fy(t){const s=gu(t),n=t.grossSales??null;return s==null&&n==null?null:(s??0)+(n??0)}function Ci(t){const s=t.venuePercentBps??0;if(!(t.venueExpenseThreshold!=null)&&s===0)return null;const r=t.venueExpenseThreshold??0;if(s===0)return r;const a=Fy(t);return a==null?null:r+Math.max(0,Math.round((a-r)*s/1e4))}function Vy(t){return($n(t)?On(t.venueCost):null)??Ci(t)}function xu(t){const s=gu(t),n=Vy(t),r=t.venueBonus??null;return s==null&&n==null&&r==null?null:(s??0)-(n??0)+(r??0)}function $y(t){return($n(t)?On(t.venuePaid):null)??xu(t)}function vu(t){const s=$y(t),n=t.grossSales??null;return s==null&&n==null?null:(s??0)+(n??0)}function Oy(t){return($n(t)?On(t.myGross):null)??vu(t)}function By(t){const s=Oy(t);if(s==null)return null;const n=t.travelEffectiveCents??t.travel??0;return s-n-Ly(t)-(t.fbAds??0)}const Hl=.01,Wl=.05,Yl=.3333,Fa=1e4,Uy=2500,_y=18;function qy(t,s){if(s===null)return null;if(!Number.isFinite(s)||s<=0)throw new Error("Diesel price must be a positive finite number");return!Number.isFinite(t)||t<=0?0:Math.round(t/_y*s*100)}function Gy(t){const s=r=>(r.venue?.trim()||r.venueAddress?.trim()||r.showTime?.trim()?4:0)+((r.shows?.length??0)>0?2:0)+(r.hotelAddress?.trim()?1:0),n=new Map;for(const r of t){const a=r.date.slice(0,10),o=n.get(a);(!o||s(r)>s(o))&&n.set(a,r)}return[...n.values()].sort((r,a)=>new Date(r.date).getTime()-new Date(a.date).getTime())}const Ky=new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"});function zy(t){if(!t)return"";const s=new Date(t);return Number.isNaN(s.getTime())?"":Ky.format(s)}function Hy(t){const s=t.map(i=>zy(i.date)).filter(i=>i!=="");if(s.length===0)return 0;const n=i=>Date.parse(`${i}T00:00:00Z`),r=s.map(n),a=Math.min(...r),o=Math.max(...r);return Math.round((o-a)/864e5)+1}function Wy(t,s){if(s<=0)return[];const n=Math.floor(t/s),r=new Array(s).fill(n);return r[s-1]+=t-n*s,r}function Yy(t,s,n){const r=new Map;for(const i of s)if(i.hotelAddress)for(const d of i.shows??[])r.set(d.id,i.hotelAddress);const a=new Map;for(const i of n)i.minutes!=null&&a.set(`${i.origin}\0${i.destination}`,i.minutes);const o=new Map;for(let i=1;i<t.length;i++){const d=r.get(t[i-1].id),u=r.get(t[i].id);if(!d||!u||d===u)continue;const c=a.get(`${d}\0${u}`);c!=null&&o.set(t[i].id,Math.floor(c/120)*Uy)}return o}function Ww(t,s,n,r,a,o){const i=new Map(s.map(R=>[R.id,R.priceCents??0])),d=new Map(s.map(R=>[R.id,R.ownerActId??null])),u=new Set(s.filter(R=>R.ownerActId==null&&!R.ownerGuest).map(R=>R.id)),c=R=>(R.cashTips??[]).reduce((re,H)=>re+(H.amountCents??0),0);let l=0,p=0;for(const R of t){p+=(R.tipsCents??0)+c(R);for(const re of R.merchSales??[])re.quantity!=null&&u.has(re.merchId)&&(l+=re.quantity*(i.get(re.merchId)??0))}const g=Yy(t,r,a);let v=0;for(const R of g.values())v+=R;const w=R=>By({...R,openersDrivingCents:g.get(R.id)??0});let A=0;for(const R of t)A+=w(R)??0;const N=Math.max(0,Math.round(A*Hl)),I=Math.round(l*Wl),C=Math.round(p*Yl),y=Hy(t),T=t.map(R=>{let re=0;for(const H of R.merchSales??[])H.quantity!=null&&u.has(H.merchId)&&(re+=H.quantity*(i.get(H.merchId)??0));return{bonus:Math.max(0,Math.round((w(R)??0)*Hl)),merchBonus:Math.round(re*Wl),tips:Math.round(((R.tipsCents??0)+c(R))*Yl),driving:g.get(R.id)??0}});if(T.length>0){const R=T.length-1,re=oe=>T.reduce((te,ce)=>te+ce[oe],0);let H=N-re("bonus");for(let oe=R;oe>=0&&H!==0;oe--){const te=Math.max(0,T[oe].bonus+H);H+=T[oe].bonus-te,T[oe].bonus=te}T[R].merchBonus+=I-re("merchBonus"),T[R].tips+=C-re("tips")}const L=y*Fa,O=Wy(L,t.length),q=new Map(n.map(R=>[R.id,R.category??null])),z=new Map,x=new Map,j=new Map,E=new Map,W=(R,re)=>{const H=(R.lineup??[]).find(oe=>oe.supportActId===re);return H?H.effectiveRole:q.get(re)};for(const R of t){let re=0,H=0;
2for(const oe of R.supportActs??[]){const te=W(R,oe.id);te!=="support"&&te!=="tour_manager"||(z.set(oe.id,(z.get(oe.id)??0)+1),x.set(oe.id,`${oe.firstName} ${oe.lastName}`.trim()),te==="support"?re++:te==="tour_manager"&&H++)}j.set(R.id,re),E.set(R.id,H)}const ie=[];for(const[R,re]of z){const H=q.get(R);if(H!=="tour_manager"&&H!=="support")continue;const oe=H,te=oe==="tour_manager"?L:re*Fa,ce=oe==="support"?v:0;let V=0,ue=0;const $=[];t.forEach((Q,de)=>{const ke=T[de],Ut=(Q.supportActs??[]).some(_e=>_e.id===R),lt=W(Q,R),Lt=Ut&&(lt==="support"||lt==="tour_manager"),jt=oe==="tour_manager"?O[de]:Lt?Fa:0;let bt=0,_t=0;const ct=oe==="tour_manager"?E.get(Q.id)??0:j.get(Q.id)??0;for(const _e of Q.merchSales??[]){if(_e.quantity==null)continue;const qt=i.get(_e.merchId)??0,Ae=oe==="tour_manager"?_e.qtyCashTm??0:_e.qtyCashSupport??0;d.get(_e.merchId)===R?bt+=(_e.quantity-Ae)*qt:Ae&&Lt&&ct>0&&(_t+=Math.round(Ae*qt/ct))}for(const _e of Q.cashTips??[])_e.collectorActId===R&&(_t+=_e.amountCents??0);V+=bt,ue+=_t,$.push({showId:Q.id,date:Q.date,venue:Q.venue??"",base:jt,bonus:ke.bonus,merchBonus:ke.merchBonus,tips:ke.tips,merchOwn:bt,cashHeld:_t,driving:oe==="support"?ke.driving:0})});const se=o.get(R),X=se?.miscCents??0,D=se?.paidCents??0,J=se?.miscNote??null,fe=te+N+I+C+V+ce+X,P=fe-D-ue;ie.push({actId:R,name:x.get(R)??`#${R}`,category:oe,showCount:re,base:te,bonus:N,merchBonus:I,tips:C,merchOwn:V,driving:ce,misc:X,miscNote:J,cashHeld:ue,total:fe,paid:D,owed:P,perShow:$})}return ie.sort((R,re)=>R.category!==re.category?R.category==="tour_manager"?-1:1:R.name.localeCompare(re.name)),{people:ie,runProfit:A,steveMerchRevenue:l,runTips:p,runDriving:v,daySpan:y}}function Ql(t){const s=t.trim();if(!s)return null;const n=s.replace(/^\$\s*/,"");if(!/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d{1,2})?$/.test(n))return;const r=Math.round(Number(n.replace(/,/g,""))*100);return Number.isSafeInteger(r)?r:void 0}function Yw(t,s){return{venue:t.venue,city:t.city,region:t.region,regionLabel:t.regionLabel??"",isDigital:t.isDigital??!1,title:t.title??"",date:t.date,status:t.status,address:t.address??"",ticketUrl:t.ticketUrl??"",meetGreetUrl:t.meetGreetUrl??"",note:t.note??"",capacity:t.capacity??null,ourTix:t.ourTix??null,venueTix:t.venueTix??null,meetGreet:t.meetGreet??null,travel:t.travel??null,openers:t.openers??null,openersOverride:t.openersOverride??null,fbAds:t.fbAds??null,venueCost:t.venueCost??null,venuePercentBps:t.venuePercentBps??null,venuePercentNote:t.venuePercentNote??null,venueMethodNote:t.venueMethodNote??null,venueExpenseThreshold:t.venueExpenseThreshold??null,venueBonus:t.venueBonus??null,venueSold:t.venueSold??null,venuePaid:t.venuePaid??null,myGross:t.myGross??null,deposit:t.deposit??null,grossSales:t.grossSales??null,venuePhone:t.venuePhone??"",unpaid:t.unpaid??!1,merchSales:(t.merchSales??[]).map(n=>({merchId:n.merchId,quantity:n.quantity??null,qtyCard:n.qtyCard??null,qtyCash:n.qtyCash??null,qtyCashTm:n.qtyCashTm??null,qtyCashSupport:n.qtyCashSupport??null})),cashTips:(t.cashTips??[]).map(n=>({collectorActId:n.collectorActId??null,amountCents:n.amountCents})),...s}}const Qy=2880*60*1e3;function Zy(t){return t.isDigital?`${t.title?.trim()||"Untitled show"} (digital)`:t.venue}function Xy(t,s,n=Date.now()){if(s==="all")return!0;const r=new Date(t).getTime()>=n-Qy;return s==="upcoming"?r:!r}function Jy(t){return[...t].sort((s,n)=>new Date(s.date).getTime()-new Date(n.date).getTime())}function ej({showIds:t}){const[s,n]=h.useState(!1),[r,a]=h.useState(null),[o,i]=h.useState([]),[d,u]=h.useState(!1),[c,l]=h.useState(""),p=nt(),g=sm(),v=nm(),w=g.isPending||v.isPending,A=async()=>{l(""),a(null),u(!1);const N=[...t];i(N);try{a(await g.mutateAsync({data:{showIds:N}}))}catch{l("Preview failed. This action requires administrator access. Retry before approving any changes.")}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{variant:"outline",onClick:()=>{n(!0),a(null),u(!1),l("")},children:"Review Eventbrite sales"}),e.jsx(Ze,{open:s,onOpenChange:n,children:e.jsxs(Xe,{className:"max-w-3xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Historical Eventbrite sales review"}),e.jsx(at,{children:"Review the currently filtered shows (maximum 500). Dry runs do not change sales. Only proven sync writes for verified third-party events can be restored. Manual or untraceable historical figures require individual review."})]}),e.jsx(F,{onClick:A,disabled:w||!t.length||t.length>500,children:g.isPending?"Preparing preview…":`Preview ${t.length} shows`}),t.length>500&&e.jsx("p",{children:"Filter the list to 500 shows or fewer first."}),c&&e.jsx("p",{role:"status",children:c}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-h-80 space-y-3 overflow-y-auto",children:[r.items.length===0&&e.jsx("p",{children:"No eligible linked shows in this selection."}),r.items.map(N=>e.jsxs("div",{className:"rounded border p-3 text-sm",children:[e.jsxs("p",{className:"font-medium",children:[N.venue," · ",N.date.slice(0,10)," · ",N.disposition.replaceAll("_"," ")]}),e.jsx("p",{children:N.reason}),Object.entries(N.changes).map(([I,C])=>e.jsxs("p",{children:[I,": ",String(C.from??"blank")," → ",String(C.to??"blank")]},I))]},N.showId))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Money changes are shown in cents; counts are tickets. No changes are made to review-only rows."}),e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:d,disabled:w,onChange:N=>u(N.target.checked)}),"I approve only the exact correctable changes shown above."]}),e.jsx(F,{disabled:!d||w||!r.items.some(N=>N.disposition==="correctable"),onClick:async()=>{try{await v.mutateAsync({data:{showIds:o,planId:r.planId,approved:!0}}),a(null),u(!1),l("Approved corrections applied. Run a fresh preview to review remaining rows."),await p.invalidateQueries({queryKey:Qe()})}catch{a(null),u(!1),l("Correction failed or the preview is stale. Run a new preview; no approval has been retained.")}},children:v.isPending?"Applying…":"Apply approved corrections"})]})]})})]})}function yu({gummies:t,food:s,washerDryer:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`text-sm ${t?"text-green-600":"text-muted-foreground"}`,children:t?"Gummies":"No Gummies"}),e.jsx("div",{className:`text-sm ${s?"text-green-600":"text-muted-foreground"}`,children:s?"Food":"No Food"}),n?e.jsx("div",{className:"text-sm text-green-600",children:"Washer / Dryer"}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No Washer / Dryer"})]})}
vendor: 4,944 bytes, line 2
2var ta="Popover",[ju]=om(ta,[pc]),tr=pc(),[tj,ps]=ju(ta),bu=t=>{const{__scopePopover:s,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:i=!1}=t,d=tr(s),u=h.useRef(null),[c,l]=h.useState(!1),[p,g]=rm({prop:r,defaultProp:a??!1,onChange:o,caller:ta});return e.jsx(am,{...d,children:e.jsx(tj,{scope:s,contentId:Ss(),triggerRef:u,open:p,onOpenChange:g,onOpenToggle:h.useCallback(()=>g(v=>!v),[g]),hasCustomAnchor:c,onCustomAnchorAdd:h.useCallback(()=>l(!0),[]),onCustomAnchorRemove:h.useCallback(()=>l(!1),[]),modal:i,children:n})})};bu.displayName=ta;var wu="PopoverAnchor",sj=h.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=ps(wu,n),o=tr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:d}=a;return h.useEffect(()=>(i(),()=>d()),[i,d]),e.jsx(hc,{...o,...r,ref:s})});sj.displayName=wu;var Nu="PopoverTrigger",Cu=h.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=ps(Nu,n),o=tr(n),i=uc(s,a.triggerRef),d=e.jsx(mc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Pu(a.open),...r,ref:i,onClick:vn(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?d:e.jsx(hc,{asChild:!0,...o,children:d})});Cu.displayName=Nu;var yo="PopoverPortal",[nj,rj]=ju(yo,{forceMount:void 0}),Su=t=>{const{__scopePopover:s,forceMount:n,children:r,container:a}=t,o=ps(yo,s);return e.jsx(nj,{scope:s,forceMount:n,children:e.jsx(fc,{present:n||o.open,children:e.jsx(im,{asChild:!0,container:a,children:r})})})};Su.displayName=yo;var Xs="PopoverContent",ku=h.forwardRef((t,s)=>{const n=rj(Xs,t.__scopePopover),{forceMount:r=n.forceMount,...a}=t,o=ps(Xs,t.__scopePopover);return e.jsx(fc,{present:r||o.open,children:o.modal?e.jsx(ij,{...a,ref:s}):e.jsx(oj,{...a,ref:s})})});ku.displayName=Xs;var aj=dm("PopoverContent.RemoveScroll"),ij=h.forwardRef((t,s)=>{const n=ps(Xs,t.__scopePopover),r=h.useRef(null),a=uc(s,r),o=h.useRef(!1);return h.useEffect(()=>{const i=r.current;if(i)return lm(i)},[]),e.jsx(cm,{as:aj,allowPinchZoom:!0,children:e.jsx(Tu,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:vn(t.onCloseAutoFocus,i=>{i.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:vn(t.onPointerDownOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,c=d.button===2||u;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:vn(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),oj=h.forwardRef((t,s)=>{const n=ps(Xs,t.__scopePopover),r=h.useRef(!1),a=h.useRef(!1);return e.jsx(Tu,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const i=o.target;n.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),Tu=h.forwardRef((t,s)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:i,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:c,onInteractOutside:l,...p}=t,g=ps(Xs,n),v=tr(n);return um(),e.jsx(mm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(hm,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:c,onDismiss:()=>g.onOpenChange(!1),children:e.jsx(pm,{"data-state":Pu(g.open),role:"dialog",id:g.contentId,...v,...p,ref:s,style:{...p.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)"}})})})}),Au="PopoverClose",lj=h.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=ps(Au,n);return e.jsx(mc.button,{type:"button",...r,ref:s,onClick:vn(t.onClick,()=>a.onOpenChange(!1))})});lj.displayName=Au;var cj="PopoverArrow",dj=h.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=tr(n);return e.jsx(fm,{...a,...r,ref:s})});dj.displayName=cj;function Pu(t){return t?"open":"closed"}var uj=bu,mj=Cu,hj=Su,Mu=ku;const sa=uj,na=mj,sr=h.forwardRef(({className:t,align:s="center",sideOffset:n=4,...r},a)=>e.jsx(hj,{children:e.jsx(Mu,{ref:a,align:s,sideOffset:n,className:ht("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground 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]:sli
vendor: 14,376 bytes, line 2
2de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",t),...r})}));sr.displayName=Mu.displayName;var Zl=1,pj=.9,fj=.8,gj=.17,Va=.1,$a=.999,xj=.9999,vj=.99,yj=/[\\\/_+.#"@\[\(\{&]/,jj=/[\\\/_+.#"@\[\(\{&]/g,bj=/[\s-]/,Du=/[\s-]/g;function Si(t,s,n,r,a,o,i){if(o===s.length)return a===t.length?Zl:vj;var d=`${a},${o}`;if(i[d]!==void 0)return i[d];for(var u=r.charAt(o),c=n.indexOf(u,a),l=0,p,g,v,w;c>=0;)p=Si(t,s,n,r,c+1,o+1,i),p>l&&(c===a?p*=Zl:yj.test(t.charAt(c-1))?(p*=fj,v=t.slice(a,c-1).match(jj),v&&a>0&&(p*=Math.pow($a,v.length))):bj.test(t.charAt(c-1))?(p*=pj,w=t.slice(a,c-1).match(Du),w&&a>0&&(p*=Math.pow($a,w.length))):(p*=gj,a>0&&(p*=Math.pow($a,c-a))),t.charAt(c)!==s.charAt(o)&&(p*=xj)),(p<Va&&n.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&n.charAt(c-1)!==r.charAt(o))&&(g=Si(t,s,n,r,c+1,o+2,i),g*Va>p&&(p=g*Va)),p>l&&(l=p),c=n.indexOf(u,c+1);return i[d]=l,l}function Xl(t){return t.toLowerCase().replace(Du," ")}function wj(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Si(t,s,Xl(t),Xl(s),0,0,{})}var fn='[cmdk-group=""]',Oa='[cmdk-group-items=""]',Nj='[cmdk-group-heading=""]',Iu='[cmdk-item=""]',Jl=`${Iu}:not([aria-disabled="true"])`,ki="cmdk-item-select",Os="data-value",Cj=(t,s,n)=>wj(t,s,n),Eu=h.createContext(void 0),nr=()=>h.useContext(Eu),Ru=h.createContext(void 0),jo=()=>h.useContext(Ru),Lu=h.createContext(void 0),Fu=h.forwardRef((t,s)=>{let n=Bs(()=>{var $,se;return{search:"",value:(se=($=t.value)!=null?$:t.defaultValue)!=null?se:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Bs(()=>new Set),a=Bs(()=>new Map),o=Bs(()=>new Map),i=Bs(()=>new Set),d=Vu(t),{label:u,children:c,value:l,onValueChange:p,filter:g,shouldFilter:v,loop:w,disablePointerSelection:A=!1,vimBindings:N=!0,...I}=t,C=Ss(),y=Ss(),T=Ss(),L=h.useRef(null),O=Lj();Ps(()=>{if(l!==void 0){let $=l.trim();n.current.value=$,q.emit()}},[l]),Ps(()=>{O(6,ie)},[]);let q=h.useMemo(()=>({subscribe:$=>(i.current.add($),()=>i.current.delete($)),snapshot:()=>n.current,setState:($,se,X)=>{var D,J,fe,P;if(!Object.is(n.current[$],se)){if(n.current[$]=se,$==="search")W(),j(),O(1,E);else if($==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Q=document.getElementById(T);Q?Q.focus():(D=document.getElementById(C))==null||D.focus()}if(O(7,()=>{var Q;n.current.selectedItemId=(Q=R())==null?void 0:Q.id,q.emit()}),X||O(5,ie),((J=d.current)==null?void 0:J.value)!==void 0){let Q=se??"";(P=(fe=d.current).onValueChange)==null||P.call(fe,Q);return}}q.emit()}},emit:()=>{i.current.forEach($=>$())}}),[]),z=h.useMemo(()=>({value:($,se,X)=>{var D;se!==((D=o.current.get($))==null?void 0:D.value)&&(o.current.set($,{value:se,keywords:X}),n.current.filtered.items.set($,x(se,X)),O(2,()=>{j(),q.emit()}))},item:($,se)=>(r.current.add($),se&&(a.current.has(se)?a.current.get(se).add($):a.current.set(se,new Set([$]))),O(3,()=>{W(),j(),n.current.value||E(),q.emit()}),()=>{o.current.delete($),r.current.delete($),n.current.filtered.items.delete($);let X=R();O(4,()=>{W(),X?.getAttribute("id")===$&&E(),q.emit()})}),group:$=>(a.current.has($)||a.current.set($,new Set),()=>{o.current.delete($),a.current.delete($)}),filter:()=>d.current.shouldFilter,label:u||t["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:C,inputId:T,labelId:y,listInnerRef:L}),[]);function x($,se){var X,D;let J=(D=(X=d.current)==null?void 0:X.filter)!=null?D:Cj;return $?J($,n.current.search,se):0}function j(){if(!n.current.search||d.current.shouldFilter===!1)return;let $=n.current.filtered.items,se=[];n.current.filtered.groups.forEach(D=>{let J=a.current.get(D),fe=0;J.forEach(P=>{let Q=$.get(P);fe=Math.max(Q,fe)}),se.push([D,fe])});let X=L.current;re().sort((D,J)=>{var fe,P;let Q=D.getAttribute("id"),de=J.getAttribute("id");return((fe=$.get(de))!=null?fe:0)-((P=$.get(Q))!=null?P:0)}).forEach(D=>{let J=D.closest(Oa);J?J.appendChild(D.parentElement===J?D:D.closest(`${Oa} > *`)):X.appendChild(D.parentElement===X?D:D.closest(`${Oa} > *`))}),se.sort((D,J)=>J[1]-D[1]).forEach(D=>{var J;let fe=(J=L.current)==null?void 0:J.querySelector(`${fn}[${Os}="${encodeURIComponent(D[0])}"]`);fe?.parentElement.appendChild(fe)})}function E(){let $=re().find(X=>X.getAttribute("aria-disabled")!=="true"),se=$?.getAttribute(Os);q.setState("value",se||void 0)}function W(){var $,se,X,D;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let J=0;for(let fe of r.current){let P=(se=($=o.current.get(fe))==null?void 0:$.value)!=null?se:"",Q=(D=(X=o.current.get(fe))==null?void 0:X.keywords)!=null?D:[],de=x(P,Q);n.current.filtered.items.set(fe,de),de>0&&J++}for(let[fe,P]of a.current)for(let Q of P)if(n.current.filtered.items.get(Q)>0){n.current.filtered.groups.add(fe);break}n.current.filtered.count=J}function ie(){var $,se,X;let D=R();D&&((($=D.parentElement)==null?void 0:$.firstChild)===D&&((X=(se=D.closest(fn))==null?void 0:se.querySelector(Nj))==null||X.scrollIntoView({block:"nearest"})),D.scrollIntoView({block:"nearest"}))}function R(){var $;return($=L.current)==null?void 0:$.querySelector(`${Iu}[aria-selected="true"]`)}function re(){var $;return Array.from((($=L.current)==null?void 0:$.querySelectorAll(Jl))||[])}function H($){let se=re()[$];se&&q.setState("value",se.getAttribute(Os))}function oe($){var se;let X=R(),D=re(),J=D.findIndex(P=>P===X),fe=D[J+$];(se=d.current)!=null&&se.loop&&(fe=J+$<0?D[D.length-1]:J+$===D.length?D[0]:D[J+$]),fe&&q.setState("value",fe.getAttribute(Os))}function te($){let se=R(),X=se?.closest(fn),D;for(;X&&!D;)X=$>0?Ej(X,fn):Rj(X,fn),D=X?.querySelector(Jl);D?q.setState("value",D.getAttribute(Os)):oe($)}let ce=()=>H(re().length-1),V=$=>{$.preventDefault(),$.metaKey?ce():$.altKey?te(1):oe(1)},ue=$=>{$.preventDefault(),$.metaKey?H(0):$.altKey?te(-1):oe(-1)};return h.createElement(ms.div,{ref:s,tabIndex:-1,...I,"cmdk-root":"",onKeyDown:$=>{var se;(se=I.onKeyDown)==null||se.call(I,$);let X=$.nativeEvent.isComposing||$.keyCode===229;if(!($.defaultPrevented||X))switch($.key){case"n":case"j":{N&&$.ctrlKey&&V($);break}case"ArrowDown":{V($);break}case"p":case"k":{N&&$.ctrlKey&&ue($);break}case"ArrowUp":{ue($);break}case"Home":{$.preventDefault(),H(0);break}case"End":{$.preventDefault(),ce();break}case"Enter":{$.preventDefault();let D=R();if(D){let J=new Event(ki);D.dispatchEvent(J)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:z.inputId,id:z.labelId,style:Vj},u),ra(t,$=>h.createElement(Ru.Provider,{value:q},h.createElement(Eu.Provider,{value:z},$))))}),Sj=h.forwardRef((t,s)=>{var n,r;let a=Ss(),o=h.useRef(null),i=h.useContext(Lu),d=nr(),u=Vu(t),c=(r=(n=u.current)==null?void 0:n.forceMount)!=null?r:i?.forceMount;Ps(()=>{if(!c)return d.item(a,i?.id)},[c]);let l=$u(a,o,[t.value,t.children,o],t.keywords),p=jo(),g=ds(O=>O.value&&O.value===l.current),v=ds(O=>c||d.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);h.useEffect(()=>{let O=o.current;if(!(!O||t.disabled))return O.addEventListener(ki,w),()=>O.removeEventListener(ki,w)},[v,t.onSelect,t.disabled]);function w(){var O,q;A(),(q=(O=u.current).onSelect)==null||q.call(O,l.current)}function A(){p.setState("value",l.current,!0)}if(!v)return null;let{disabled:N,value:I,onSelect:C,forceMount:y,keywords:T,...L}=t;return h.createElement(ms.div,{ref:Dn(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!N,"aria-selected":!!g,"data-disabled":!!N,"data-selected":!!g,onPointerMove:N||d.getDisablePointerSelection()?void 0:A,onClick:N?void 0:w},t.children)}),kj=h.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...o}=t,i=Ss(),d=h.useRef(null),u=h.useRef(null),c=Ss(),l=nr(),p=ds(v=>a||l.filter()===!1?!0:v.search?v.filtered.groups.has(i):!0);Ps(()=>l.group(i),[]),$u(i,d,[t.value,t.heading,u]);let g=h.useMemo(()=>({id:i,forceMount:a}),[a]);return h.createElement(ms.div,{ref:Dn(d,s),...o,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ra(t,v=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Lu.Provider,{value:g},v))))}),Tj=h.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=h.useRef(null),o=ds(i=>!i.search);return!n&&!o?null:h.createElement(ms.div,{ref:Dn(a,s),...r,"cmdk-separator":"",role:"separator"})}),Aj=h.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,o=jo(),i=ds(c=>c.search),d=ds(c=>c.selectedItemId),u=nr();return h.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),h.createElement(ms.input,{ref:s,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":d,id:u.inputId,type:"text",value:a?t.value:i,onChange:c=>{a||o.setState("search",c.target.value),n?.(c.target.value)}})}),Pj=h.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,o=h.useRef(null),i=h.useRef(null),d=ds(c=>c.selectedItemId),u=nr();return h.useEffect(()=>{if(i.current&&o.current){let c=i.current,l=o.current,p,g=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let v=c.offsetHeight;l.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return g.observe(c),()=>{cancelAnimationFrame(p),g.unobserve(c)}}},[]),h.createElement(ms.div,{ref:Dn(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":r,id:u.listId},ra(t,c=>h.createElement("div",{ref:Dn(i,u.listInnerRef),"cmdk-list-sizer":""},c)))}),Mj=h.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:o,container:i,...d}=t;return h.createElement(gm,{open:n,onOpenChange:r},h.createElement(xm,{container:i},h.createElement(vm,{"cmdk-overlay":"",className:a}),h.createElement(ym,{"aria-label":t.label,"cmdk-dialog":"",className:o},h.createElement(Fu,{ref:s,...d}))))}),Dj=h.forwardRef((t,s)=>ds(n=>n.filtered.count===0)?h.createElement(ms.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Ij=h.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...o}=t;return h.createElement(ms.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},ra(t,i=>h.createElement("div",{"aria-hidden":!0},i)))}),ot=Object.assign(Fu,{List:Pj,Item:Sj,Input:Aj,Group:kj,Separator:Tj,Dialog:Mj,Empty:Dj,Loading:Ij});function Ej(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function Rj(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function Vu(t){let s=h.useRef(t);return Ps(()=>{s.current=t}),s}var Ps=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Bs(t){let s=h.useRef();return s.current===void 0&&(s.current=t()),s}function ds(t){let s=jo(),n=()=>t(s.snapshot());return h.useSyncExternalStore(s.subscribe,n,n)}function $u(t,s,n,r=[]){let a=h.useRef(),o=nr();return Ps(()=>{var i;let d=(()=>{var c;for(let l of n){if(typeof l=="string")return l.trim();if(typeof l=="object"&&"current"in l)return l.current?(c=l.current.textContent)==null?void 0:c.trim():a.current}})(),u=r.map(c=>c.trim());o.value(t,d,u),(i=s.current)==null||i.setAttribute(Os,d),a.current=d}),a}var Lj=()=>{let[t,s]=h.useState(),n=Bs(()=>new Map);return Ps(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function Fj(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function ra({asChild:t,children:s},n){return t&&h.isValidElement(s)?h.cloneElement(Fj(s),{ref:s.ref},n(s.props.children)):n(s)}var Vj={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const rr=h.forwardRef(({className:t,...s},n)=>e.jsx(ot,{ref:n,className:ht("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));rr.displayName=ot.displayName;const ar=h.forwardRef(({className:t,...s},n)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Ms,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(ot.Input,{ref:n,className:ht("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));ar.displayName=ot.Input.displayName;const ir=h.forwardRef(({className:t,...s},n)=>e.jsx(ot.List,{ref:n,className:ht("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ir.displayName=ot.List.displayName;const or=h.forwardRef((t,s)=>e.jsx(ot.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));or.displayName=ot.Empty.displayName;const aa=h.forwardRef(({className:t,...s},n)=>e.jsx(ot.Group,{ref:n,className:ht("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));aa.displayName=ot.Group.displayName;const $j=h.forwardRef(({className:t,...s},n)=>e.jsx(ot.Separator,{ref:n,className:ht("-mx-1 h-px bg-border",t),...s}));$j.displayName=ot.Separator.displayName;const os=h.forwardRef(({className:t,...s},n)=>e.jsx(ot.Item,{ref:n,className:ht("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-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...s}));os.displayName=ot.Item.displayName;const Oj=["United States","Canada","United Kingdom","Ireland","Australia","New Zealand","Germany","Netherlands","Belgium","France","Spain","Italy","Sweden","Norway","Denmark","Finland","Switzerland","Austria","Mexico"],Bj=["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","N
2orth Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","Washington DC","West Virginia","Wisconsin","Wyoming"],Uj=["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"],_j={"United States":Bj,Canada:Uj};function qj(t){return t?_j[t]??null:null}const Gj=h.lazy(()=>us(()=>import("./admin-report-CADr6cPP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35])).then(t=>({default:t.ReportPanel}))),Kj=h.lazy(()=>us(()=>import("./admin-runs-BrNFyAwt.js"),__vite__mapDeps([36,1,2,3,4,5,6,7,19,25,14,20,13,15,22,8,9,10,12,34,16,17,18,21,23,24,11,26,27,28,29,30,31,32,33,35])).then(t=>({default:t.RunsPanel}))),zj=h.lazy(()=>us(()=>import("./admin-threads-B6ykSR_3.js"),__vite__mapDeps([37,1,2,17,18,38,25,14,5,20,7,4,39,12,32,11,31,40,26,41,34])).then(t=>({default:t.ThreadsPanel}))),Hj=h.lazy(()=>us(()=>import("./admin-threads-B6ykSR_3.js"),__vite__mapDeps([37,1,2,17,18,38,25,14,5,20,7,4,39,12,32,11,31,40,26,41,34])).then(t=>({default:t.VideoMemesPanel}))),Wj=h.lazy(()=>us(()=>import("./admin-membership-Ctm5Fqor.js"),__vite__mapDeps([42,1,2,7,20,19,24,43,13,14,15,5,38,22,4,44,45,11,10,27,30,46,34,16,17,18,3,6,21,8,9,23,25,26,28,29,31,32,33,35])).then(t=>({default:t.MembershipPanel}))),Ou=h.lazy(()=>us(()=>import("./admin-booking-BJvhmlKK.js"),__vite__mapDeps([47,1,2,10,4,48,12,28,26,13,14,15,5,32,49,16,17,18,3,6,7,19,20,21,8,9,22,23,24,25,11,27,29,30,31,33,34,35])).then(t=>({default:t.BookingPanel}))),Yj=h.lazy(()=>us(()=>import("./ticketing-admin-BUziw4g2.js"),__vite__mapDeps([50,1,2,43,7,19,21,14,24,20,13,15,5,22,51,52,53,49,44,28,34]))),Qj=h.lazy(()=>us(()=>import("./admin-kindness-DZb_s7dz.js"),__vite__mapDeps([54,1,2,55,56,19,7,20,43,24,25,14,5,22,57,32,15]))),lr="/".replace(/\/$/,"");function Bu(t){return t?t.startsWith("/objects/")?`${lr}/api/storage${t}`:t:null}function Ue(t){return`${t.firstName} ${t.lastName}`.trim()}function Uu(t){return t==="tour_manager"?"Tour Manager":t==="local_guest"?"Local Guest":"Support Act"}function Ba(t){const s=new Date(t);return Number.isNaN(s.getTime())?"":s.toLocaleDateString("en-US",{timeZone:"America/New_York",month:"short",day:"numeric"})}const Zj=2880*60*1e3;function Xj(t){const s=new Date(t).getTime();return Number.isNaN(s)?!1:Date.now()-s>Zj}function Jj(t){return`${t.firstName.charAt(0)}${t.lastName.charAt(0)}`.toUpperCase()}function _u(t){if(!t)return"";const s=new Date(t);return Number.isNaN(s.getTime())?"":s.toLocaleDateString(void 0,{timeZone:"America/New_York",month:"short",day:"numeric"})}function eb(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).formatToParts(s),r=o=>n.find(i=>i.type===o)?.value??"",a=r("hour")==="24"?"00":r("hour");return`${r("year")}-${r("month")}-${r("day")}T${a}:${r("minute")}`}function tb(t){const s=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/);return s?Zh({year:Number(s[1]),month:Number(s[2]),day:Number(s[3]),hour:Number(s[4]),minute:Number(s[5])},"America/New_York").toISOString():""}function An(t){const s=new Date(t);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString("en-US",{timeZone:"America/New_York",hour:"numeric",minute:"2-digit"})}function Ua(t,s){const n=r=>{const[a,o,i]=r.slice(0,10).split("-").map(Number);return Date.UTC(a,(o??1)-1,i??1)};return n(s)-n(t)===864e5}function Mt(t){if(t==null)return null;const s=String(t).trim();return s?s.replace(/\b(\d{1,2})(?::([0-5]\d))?\s*([AaPp])\.?\s*[Mm]\.?\b/g,(n,r,a,o)=>{const i=a&&a!=="00"?`:${a}`:"";return`${Number(r)}${i}${o.toUpperCase()}M`}):null}function sb(t){const s=t.trim().match(/(\d{1,2})(?::([0-5]\d))?\s*([AaPp][Mm]?)?/);if(!s)return null;let n=Number(s[1]);const r=s[2]?Number(s[2]):0,a=s[3]?.toLowerCase();if(a){const o=a.startsWith("p");n===12?n=o?12:0:o&&(n+=12)}return n>23||r>59?null:n*60+r}function nb(t){const s=(t%1440+1440)%1440;let n=Math.floor(s/60);const r=s%60,a=n>=12?"PM":"AM";return n%=12,n===0&&(n=12),`${n}:${r.toString().padStart(2,"0")} ${a}`}function bs(t,s){const n=sb(t);return n==null?null:nb(n+s)}function Ks(t,s,n){if(s)return"";const r=t?.trim();return r?bs(r,n)??"":""}function rb(t){if(!t)return null;const s=t.toLowerCase();return s.includes("king")?"K":s.includes("queen")?"Q":s.includes("double")?"D":s.includes("twin")?"T":null}function ab(t){if(t.hotelRooms&&t.hotelRooms.length>0)return t.hotelRooms.map(o=>({confirmationCode:o.confirmationCode??"",roomType:o.roomType??"",cost:o.costCents!=null?(o.costCents/100).toFixed(2):""}));const s=[t.roomOne,t.roomTwo,t.roomThree],n=Math.max(t.totalRooms??0,s.filter(o=>o?.trim()).length);if(!(n>0||!!t.hotelConfirmationCode?.trim()||t.hotelCostCents!=null))return[];const a=Math.max(n,1);return Array.from({length:a},(o,i)=>({confirmationCode:i===0?t.hotelConfirmationCode??"":"",roomType:s[i]??"",cost:i===0&&t.hotelCostCents!=null?(t.hotelCostCents/100).toFixed(2):""}))}function qu(t){if(t.hotelRooms&&t.hotelRooms.length>0)return t.hotelRooms;const s=[t.roomOne,t.roomTwo,t.roomThree],n=Math.max(t.totalRooms??0,s.filter(o=>o?.trim()).length);if(!(n>0||!!t.hotelConfirmationCode?.trim()||t.hotelCostCents!=null))return[];const a=Math.max(n,1);return Array.from({length:a},(o,i)=>({confirmationCode:i===0?t.hotelConfirmationCode??null:null,roomType:s[i]??null,costCents:i===0?t.hotelCostCents??null:null}))}function ib(t){return t.reduce((n,r)=>{const a=Number(r.cost.replace(/[$,]/g,""));return Number.isFinite(a)?n+a:n}
2,0).toLocaleString("en-US",{style:"currency",currency:"USD"})}function Ws(t){const n=(t.hotelRooms&&t.hotelRooms.length>0?t.hotelRooms.map(o=>o.roomType):[t.roomOne,t.roomTwo,t.roomThree]).map(rb).filter(o=>o!=null),r=t.hotelRooms?.length??0,a=Math.max(r,t.totalRooms??0,n.length);return a===0?null:n.length?`${a} (${n.join(", ")})`:String(a)}function Gu(){const t=new Date,s=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())}`}const ec={venue:"",city:"",region:"",regionLabel:"",isDigital:!1,title:"",date:"",status:"scheduled",address:"",ticketUrl:"",meetGreetUrl:"",note:"",capacity:null,ourTix:null,venueTix:null,meetGreet:null,travel:null,openers:null,openersOverride:null,fbAds:null,venueCost:null,venuePercentBps:null,venuePercentNote:null,venueMethodNote:null,venueExpenseThreshold:null,venueBonus:null,venueSold:null,venuePaid:null,myGross:null,deposit:null,grossSales:null,venuePhone:"",unpaid:!1,merchSales:[],cashTips:[]},ob=["Tickets & Capacity","Financials"],lb=[{key:"capacity",label:"Capacity",group:"Tickets & Capacity"},{key:"ourTix",label:"Our Tix",group:"Tickets & Capacity"},{key:"venueTix",label:"Venue Tix",group:"Tickets & Capacity"},{key:"meetGreet",label:"Meet & Greet",group:"Tickets & Capacity"},{key:"travel",label:"Travel $",group:"Financials",money:!0},{key:"openersOverride",label:"Openers $",group:"Financials",money:!0},{key:"fbAds",label:"FB Ads $",group:"Financials",money:!0},{key:"venueCost",label:"Final Venue Cost $",group:"Financials",money:!0},{key:"venueSold",label:"Venue Sold $",group:"Financials",money:!0},{key:"venuePaid",label:"Final Venue Paid $",group:"Financials",money:!0},{key:"myGross",label:"Final My Gross $",group:"Financials",money:!0},{key:"deposit",label:"Deposit $",group:"Financials",money:!0}];function Dt(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t/100)}const cb=3200;function Ku(t){return t.ourTix==null&&t.venueTix==null?null:(t.ourTix??0)+(t.venueTix??0)}function db(t){return t.eventbriteOwnershipStatus==="owned"}function ub(t){if(t.grossSales!=null)return{cents:t.grossSales,estimated:!1};if(t.eventbriteOwnershipStatus!=="third_party")return null;const s=t.venueTix;return s==null||s<=0?null:{cents:s*cb,estimated:!0}}function mb({show:t}){const s=Ku(t),n=t.eventbriteCapacity??t.capacity,r=ub(t);if(s==null&&n==null&&r==null)return e.jsx("span",{className:"text-muted-foreground",children:"—"});const a=n!=null&&n>0&&s!=null?s/n:null,o=a==null?"text-muted-foreground":a<.5?"text-red-600":a>.7?"text-green-600":"text-foreground";return e.jsxs("div",{className:"text-right text-sm tabular-nums",children:[e.jsxs("div",{className:"font-semibold",children:[s??0,n!=null?`/${n}`:""]}),a!=null?e.jsxs("div",{className:`text-xs font-medium ${o}`,children:[Math.round(a*100),"%"]}):null]})}function zu({canImpersonate:t=!1}){const{signOut:s}=Li(),{user:n}=Nm();return e.jsx("header",{className:"border-b bg-background sticky top-0 z-40",children:e.jsxs("div",{className:"container mx-auto px-4 md:px-6 h-16 flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:gap-4",children:[e.jsxs(Ys,{href:"/",className:"font-display font-black text-lg tracking-tighter uppercase text-primary",children:["Steve",e.jsx("span",{className:"hidden sm:inline",children:" Hofstetter"})]}),e.jsx(it,{variant:"outline",className:"uppercase tracking-wide",children:"Admin"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 sm:gap-3",children:[t?e.jsx(fw,{}):null,e.jsx(F,{variant:"ghost",size:"sm",asChild:!0,className:"h-9 w-9 p-0 sm:w-auto sm:px-3",children:e.jsxs(Ys,{href:"/",children:[e.jsx(Nc,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"sr-only sm:not-sr-only",children:"View site"})]})}),n?.primaryEmailAddress?e.jsx("span",{className:"hidden sm:inline text-sm text-muted-foreground",children:n.primaryEmailAddress.emailAddress}):null,e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>s({redirectUrl:lr||"/"}),className:"h-9 w-9 p-0 sm:w-auto sm:px-3",children:[e.jsx(xp,{className:"h-4 w-4 sm:hidden"}),e.jsx("span",{className:"sr-only sm:not-sr-only",children:"Sign out"})]})]})]})})}function hb({venues:t,isLoading:s,onSelect:n}){const[r,a]=h.useState(!1);return e.jsxs(sa,{open:r,onOpenChange:a,children:[e.jsx(na,{asChild:!0,children:e.jsxs(F,{type:"button",variant:"outline",role:"combobox","aria-expanded":r,className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Hs,{className:"h-4 w-4"}),s?"Loading venues...":"Prefill from a past venue"]}),e.jsx(Yn,{className:"h-4 w-4 opacity-50 shrink-0"})]})}),e.jsx(sr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(rr,{children:[e.jsx(ar,{placeholder:"Search venues..."}),e.jsxs(ir,{children:[e.jsx(or,{children:"No venues found."}),e.jsx(aa,{children:t.map((o,i)=>e.jsx(os,{value:`${o.venue} ${o.city} ${o.regionLabel}`,onSelect:()=>{n(o),a(!1)},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.venue}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.city,o.regionLabel?`, ${o.regionLabel}`:"",o.address?` · ${o.address}`:""]})]})},`${o.venue}-${o.city}-${i}`))})]})]})})]})}function Tr({label:t,sortKey:s,current:n,dir:r,onSort:a,align:o}){const i=n===s;return e.jsx(U,{className:o==="right"?"text-right":void 0,"aria-sort":i?r==="asc"?"ascending":"descending":"none",children:e.jsxs("button",{type:"button","aria-label":`Sort by ${t}`,onClick:()=>a(s),className:`inline-flex items-center gap-1 select-none hover:text-foreground transition-colors ${o==="right"?"flex-row-reverse":""} ${i?"text-foreground font-semibold":""}`,children:[t,i?r==="asc"?e.jsx(Oi,{className:"h-3.5 w-3.5"}):e.jsx(It,{className:"h-3.5 w-3.5"}):e.jsx(Yn,{className:"h-3.5 w-3.5 opacity-40"})]})})}
2const pb=[["albums","album set","album sets"],["grape","grape expectations"],["baseball","a girl can like baseball"],["stickers"],["gummies","purple hempathy"],["audio book","audiobook","audiobooks","audio books"]];function tc(t){const s=o=>(o??"").trim().toLowerCase(),n=s(t.nickname),r=s(t.name),a=pb.findIndex(o=>o.includes(n)||o.includes(r));return a===-1?Number.POSITIVE_INFINITY:a}function fb({active:t=!0,lineupImportRequest:s=0}){const{toast:n}=Ye(),r=nt(),{data:a,isLoading:o}=Wr({query:{queryKey:Qe(),enabled:t}}),{data:i=[],isLoading:d}=Cm({query:{queryKey:To(),enabled:t}}),{data:u=[]}=Bn({query:{queryKey:za(),enabled:t}}),{data:c=[]}=Fi({query:{queryKey:Vi(),enabled:t}}),l=h.useMemo(()=>[...c].filter(m=>m.currentlySelling).sort((m,b)=>{const G=tc(m),ye=tc(b);if(G!==ye)return G-ye;const ve=m.position??0,je=b.position??0;return ve!==je?ve-je:m.name.localeCompare(b.name)}),[c]),{data:p=[]}=Sm({query:{queryKey:Vh(),enabled:t}}),[g,v]=h.useState(null),w=h.useMemo(()=>new Map(p.map(m=>[m.ticketUrl,m.totalClicks])),[p]),[A,N]=h.useState(!1),[I,C]=h.useState(null),[y,T]=h.useState(ec),[L,O]=h.useState(""),q=h.useMemo(()=>{const m=c.filter(b=>!b.currentlySelling&&(y.merchSales??[]).some(G=>G.merchId===b.id&&((G.quantity??0)!==0||[G.qtyCard,G.qtyCash,G.qtyCashTm,G.qtyCashSupport].some(ye=>(ye??0)!==0)))).sort((b,G)=>b.name.localeCompare(G.name));return[...l,...m]},[l,c,y.merchSales]),[z,x]=h.useState(!1),[j,E]=h.useState(null),[W,ie]=h.useState(""),[R,re]=h.useState("all"),[H,oe]=h.useState("upcoming"),[te,ce]=h.useState(null),[V,ue]=h.useState("asc"),[$,se]=h.useState(!1),[X,D]=h.useState(null),[J,fe]=h.useState(!1),[P,Q]=h.useState(null),de=km({mutation:{onSuccess:async m=>{await r.invalidateQueries({queryKey:Qe()}),n({title:"Eventbrite sync complete",description:`${m.updated} show${m.updated===1?"":"s"} updated · ${m.linked} linked · ${m.errors} error${m.errors===1?"":"s"}`})},onError:m=>{n({title:"Eventbrite sync failed",description:m instanceof Error&&m.message?m.message:"Could not refresh Eventbrite ticket data. Try again.",variant:"destructive"})}}}),[ke,Ut]=h.useState(!1),[lt,Lt]=h.useState(!1),[jt,bt]=h.useState(null),[_t,ct]=h.useState(null),[_e,qt]=h.useState(""),[Ae,Gt]=h.useState(null),[oa,la]=h.useState(""),[fs,ca]=h.useState(!1),Ds=h.useRef(null),an=async m=>{const b=m.trim();if(!b){ct("Choose a CSV file or paste some rows first.");return}Lt(!0),ct(null),bt(null),Gt(null);try{const G=await bo({csv:b,dryRun:!0,createMissing:fs});Gt(G),la(b)}catch(G){const ye=G instanceof Error&&G.message?G.message:"Preview failed. Check the file and try again.";ct(ye),n({title:"Preview failed",variant:"destructive"})}finally{Lt(!1)}},Is=async()=>{const m=oa.trim();if(m){Lt(!0),ct(null);try{const b=await bo({csv:m,dryRun:!1,createMissing:fs});bt(b),Gt(null),r.invalidateQueries({queryKey:Qe()}),n({title:"Import complete",description:`${b.updated} updated · ${b.created} created · ${b.skipped.length} skipped`})}catch(b){const G=b instanceof Error&&b.message?b.message:"Import failed. Check the file and try again.";ct(G),n({title:"Import failed",variant:"destructive"})}finally{Lt(!1)}}},da=async m=>{if(!m)return;const b=await m.text();await an(b)},[ua,Es]=h.useState(!1),[Yt,Kt]=h.useState(!1),[Rs,Ls]=h.useState(""),[cr,ma]=h.useState(""),[dr,Qt]=h.useState(null),[Ke,gs]=h.useState(null),[on,ln]=h.useState(null),[wt,Nt]=h.useState(null),ha=async()=>{const m=Rs.trim(),b=Number(cr);if(!m){Qt("Paste the sheet rows first.");return}if(!Number.isInteger(b)||b<2e3||b>2100){Qt("Enter the year these shows happened (the sheet's dates have no year).");return}Kt(!0),Qt(null),Nt(null),gs(null);try{const G=await wo({text:m,year:b,dryRun:!0});gs(G),ln({text:m,year:b})}catch(G){const ye=G instanceof Error&&G.message?G.message:"Preview failed. Check the paste and try again.";Qt(ye),n({title:"Preview failed",variant:"destructive"})}finally{Kt(!1)}},pa=async()=>{if(on){Kt(!0),Qt(null);try{const m=await wo({...on,dryRun:!1});Nt(m),gs(null),r.invalidateQueries({queryKey:Qe()}),n({title:"Merch import complete",description:`${m.updated} show${m.updated===1?"":"s"} updated · ${m.skipped.length} row${m.skipped.length===1?"":"s"} skipped`})}catch(m){const b=m instanceof Error&&m.message?m.message:"Import failed. Check the paste and try again.";Qt(b),n({title:"Import failed",variant:"destructive"})}finally{Kt(!1)}}},[cn,dn]=h.useState(!1),[Zt,Xt]=h.useState(!1),[xs,un]=h.useState(""),[vs,ur]=h.useState("guest"),Ct={guest:{noun:"Local guest",nounPlural:"Local guests"},support:{noun:"Support act",nounPlural:"Support acts"}
2,tour_manager:{noun:"Tour manager",nounPlural:"Tour managers"}},[Fs,Jt]=h.useState(null),[ze,es]=h.useState(null),[dt,mn]=h.useState(null),[St,Vs]=h.useState(null),[fa,f]=h.useState("guest");h.useEffect(()=>{s&&(Vs(null),es(null),Jt(null),dn(!0))},[s]);const S=async()=>{const m=xs.trim();if(!m){Jt("Paste the sheet rows first.");return}Xt(!0),Jt(null),Vs(null),es(null);try{const b=await No({text:m,role:vs,dryRun:!0});es(b),mn({text:m,role:vs})}catch(b){const G=b instanceof Error&&b.message?b.message:"Preview failed. Check the paste and try again.";Jt(G),n({title:"Preview failed",variant:"destructive"})}finally{Xt(!1)}},k=async()=>{if(dt){Xt(!0),Jt(null);try{const m=await No({...dt,dryRun:!1});Vs(m),f(dt.role),es(null),r.invalidateQueries({queryKey:Qe()}),r.invalidateQueries({queryKey:za()});const b=Ct[dt.role].noun;n({title:`${Ct[dt.role].nounPlural} imported`,description:`${m.attached} ${m.attached===1?b:Ct[dt.role].nounPlural.toLowerCase()} attached · ${m.skipped.length} row${m.skipped.length===1?"":"s"} skipped`})}catch(m){const b=m instanceof Error&&m.message?m.message:"Import failed. Check the paste and try again.";Jt(b),n({title:"Import failed",variant:"destructive"})}finally{Xt(!1)}}},M=async()=>{se(!0),D("Looking up venue phone numbers...");let m=0,b=0;try{let G=null;for(let ve=0;ve<500;ve++){const je=await hh(G!=null?{after:G}:void 0);if(m+=je.filled,b=je.remaining,D(`Filled ${m} venues so far...`),je.processed===0||je.cursor==null)break;G=je.cursor}r.invalidateQueries({queryKey:Qe()}),D(null);const ye=m>0?`Filled ${m} venue phone numbers`:"No new phone numbers found";n({title:b>0?`${ye}; ${b} still without a number`:ye})}catch{D(null),n({title:"Could not fill venue phone numbers. Try again.",variant:"destructive"})}finally{se(!1)}},K=async()=>{fe(!0),Q("Looking up venue addresses...");let m=0,b=0;try{let G=null;for(let ve=0;ve<500;ve++){const je=await ph(G!=null?{after:G}:void 0);if(m+=je.filled,b=je.remaining,Q(`Filled ${m} addresses so far...`),je.processed===0||je.cursor==null)break;G=je.cursor}r.invalidateQueries({queryKey:Qe()}),Q(null);const ye=m>0?`Filled ${m} venue addresses`:"No new addresses found";n({title:b>0?`${ye}; ${b} still without an address`:ye})}catch{Q(null),n({title:"Could not fill venue addresses. Try again.",variant:"destructive"})}finally{fe(!1)}},B=m=>{te===m?ue(b=>b==="asc"?"desc":"asc"):(ce(m),ue("asc"))},Y=()=>{r.invalidateQueries({queryKey:Qe()}),r.invalidateQueries({queryKey:To()})},me=Tm({mutation:{onSuccess:()=>{Y(),N(!1),n({title:"Show created"})},onError:()=>n({title:"Could not save show",variant:"destructive"})}}),ge=Am({mutation:{onSuccess:()=>{Y(),N(!1),n({title:"Show updated"})},onError:()=>n({title:"Could not save show",variant:"destructive"})}}),Te=Pm({mutation:{onSuccess:()=>{Y(),n({title:"Ticket date refreshed"})},onError:()=>n({title:"Could not refresh date",variant:"destructive"})}}),kt=m=>{m.key!=="Enter"||I==null||(m.preventDefault(),Te.mutate({id:I}))},mr=Mm({mutation:{onSuccess:()=>{Y(),E(null),n({title:"Show deleted"})},onError:()=>n({title:"Could not delete show",variant:"destructive"})}}),hr=()=>{C(null),O(""),T({...ec,date:`${Gu()}T20:00`}),x(!1),He([]),N(!0)},pr=m=>{C(m.id),O(m.venueExpenseThreshold==null?"":String(m.venueExpenseThreshold/100)),T({venue:m.venue,city:m.city,region:m.region,regionLabel:m.regionLabel??"",isDigital:m.isDigital??!1,title:m.title??"",date:eb(m.date),status:m.status,address:m.address??"",ticketUrl:m.ticketUrl??"",meetGreetUrl:m.meetGreetUrl??"",note:m.note??"",capacity:m.capacity??null,ourTix:m.ourTix??null,venueTix:m.venueTix??null,meetGreet:m.meetGreet??null,travel:m.travel??null,openers:m.openers??null,openersOverride:m.openersOverride??null,fbAds:m.fbAds??null,venueCost:m.venueCost??null,venuePercentBps:m.venuePercentBps??null,venuePercentNote:m.venuePercentNote??null,venueMethodNote:m.venueMethodNote??null,venueExpenseThreshold:m.venueExpenseThreshold??null,venueBonus:m.venueBonus??null,venueSold:m.venueSold??null,venuePaid:m.venuePaid??null,myGross:m.myGross??null,deposit:m.deposit??null,grossSales:m.grossSales??null,venuePhone:m.venuePhone??"",unpaid:m.unpaid??!1,merchSales:(m.merchSales??[]).map(b=>({merchId:b.merchId,quantity:b.quantity??null,qtyCard:b.qtyCard??null,qtyCash:b.qtyCash??null,qtyCashTm:b.qtyCashTm??null,qtyCashSupport:b.qtyCashSupport??null})),cashTips:(m.cashTips??[]).map(b=>({collectorActId:b.collectorActId??null,amountCents:b.amountCents}))}),x(!!m.region&&!hn(m.region)),He([]),N(!0)},fr=(m,b,G)=>{T(ye=>{const ve=(ye.merchSales??[]).find(zt=>zt.merchId===m),je={merchId:m,qtyCard:ve?.qtyCard??null,qtyCash:ve?.qtyCash??null,qtyCashTm:ve?.qtyCashTm??null,qtyCashSupport:ve?.qtyCashSupport??null,[b]:G},rt=[je.qtyCard,je.qtyCash,je.qtyCashTm,je.qtyCashSupport],Fe=rt.some(zt=>zt!=null),Ft=Fe?rt.reduce((zt,tm)=>zt+(tm??0),0):null,pt=(ye.merchSales??[]).filter(zt=>zt.merchId!==m);return{...ye,merchSales:Fe?[...pt,{...je,quantity:Ft}]:pt}})},[Ee,He]=h.useState([]),gr=()=>{T(m=>({...m,cashTips:[...m.cashTips??[],{collectorActId:null,amountCents:0}]}))},xr=(m,b)=>{T(G=>{const ye=[...G.cashTips??[]];return ye[m]?(ye[m]={...ye[m],...b},{...G,cashTips:ye}):G})},ga=m=>{T(b=>{const G=[...b.cashTips??[]];return G.splice(m,1),{...b,cashTips:G}})},xa=()=>{const m=Ql(L);if(m===void 0||m!=null&&m<0){n({title:"Enter a valid venue expense amount",variant:"destructive"});return}const b={...y,date:y.date?tb(y.date):""};I!=null?ge.mutate({id:I,data:b}):me.mutate({data:b})},vr=m=>{T(b=>({...b,venue:m.venue,city:m.city,region:m.region,regionLabel:m.regionLabel,address:m.address??""})),x(!!m.region&&!hn(m.region))},va=m=>{if(m==="__custom__"){x(!0);return}if(x(!1),m===""){T(G=>({...G,region:"",regionLabel:""}));return}const b=hn(m);b&&T(G=>({...G,region:b.code,regionLabel:b.label}))},yr=me.isPending||ge.isPending,ee=h.useMemo(()=>{const m=new Map;for(const b of a??[])b.region&&m.set(b.region,b.regionLabel||b.region);return[...m.entries()].sort((b,G)=>b[1].localeCompare(G[1]))},[a]),pe=h.useMemo(()=>{const m=Date.now(),b=W.trim().toLowerCase(),G=(a??[]).filter(ve=>
2!(!Xy(ve.date,H,m)||R!=="all"&&ve.region!==R||b&&!`${ve.venue} ${ve.city} ${ve.regionLabel??""}`.toLowerCase().includes(b)));if(te===null)return H==="upcoming"?Jy(G):G.sort((ve,je)=>new Date(je.date).getTime()-new Date(ve.date).getTime());const ye=V==="asc"?1:-1;return G.sort((ve,je)=>{let rt=0;switch(te){case"date":rt=new Date(ve.date).getTime()-new Date(je.date).getTime();break;case"venue":rt=ve.venue.localeCompare(je.venue);break;case"city":rt=ve.city.localeCompare(je.city)||(ve.regionLabel??"").localeCompare(je.regionLabel??"");break;case"clicks":{const Fe=ve.ticketUrl?w.get(ve.ticketUrl)??0:-1,Ft=je.ticketUrl?w.get(je.ticketUrl)??0:-1;rt=Fe-Ft;break}}return rt*ye})},[a,W,R,H,te,V,w]),Re=W.trim()!==""||R!=="all"||H!=="upcoming",We=()=>{ie(""),re("all"),oe("upcoming")},Ne="h-9 rounded-md border border-input bg-background px-3 text-sm";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Tour dates"}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[X&&e.jsx("span",{className:"text-sm text-muted-foreground",children:X}),P&&e.jsx("span",{className:"text-sm text-muted-foreground",children:P})]}),e.jsxs("div",{className:"grid w-full grid-cols-2 gap-2 sm:grid-cols-3 lg:flex lg:w-auto lg:flex-wrap lg:justify-end",children:[e.jsx(ej,{showIds:pe.map(m=>m.id)}),e.jsxs(F,{className:"w-full lg:w-auto",variant:"outline",onClick:()=>de.mutate({data:{}}),disabled:de.isPending,children:[de.isPending&&e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}),de.isPending?"Syncing Eventbrite...":"Sync Eventbrite"]}),e.jsxs(F,{className:"w-full lg:w-auto",variant:"outline",onClick:M,disabled:$,children:[$?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Hs,{className:"h-4 w-4 mr-1"}),"Fill venue phones"]}),e.jsxs(F,{className:"w-full lg:w-auto",variant:"outline",onClick:K,disabled:J,children:[J?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Hs,{className:"h-4 w-4 mr-1"}),"Fill addresses"]}),e.jsxs(F,{className:"w-full lg:w-auto",variant:"outline",onClick:()=>{bt(null),ct(null),Ut(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-1"})," Import CSV"]}),e.jsxs(F,{className:"col-span-2 w-full sm:col-span-1 lg:w-auto",onClick:hr,children:[e.jsx(gt,{className:"h-4 w-4 mr-1"})," Add show"]})]})]})]}),e.jsx(Ze,{open:ke,onOpenChange:Ut,children:e.jsxs(Xe,{className:"max-w-4xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Import ticket & financial numbers"}),e.jsx(at,{children:"Upload or paste a CSV. You'll get a preview of exactly which show each row will update or create — review it, then confirm. Nothing is written until you confirm."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(Z,{htmlFor:"import-file",children:"CSV file"}),e.jsx(ne,{id:"import-file",ref:Ds,type:"file",accept:".csv,text/csv",disabled:lt,onChange:m=>{da(m.target.files?.[0]),m.target.value=""}})]}),e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(Z,{htmlFor:"import-paste",children:"…or paste CSV rows"}),e.jsx(Pt,{id:"import-paste",rows:6,placeholder:"Show date/time,Venue,Capacity,Our tickets,...",value:_e,disabled:lt,onChange:m=>qt(m.target.value),className:"font-mono text-xs"}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(F,{size:"sm",disabled:lt||!_e.trim(),onClick:()=>{an(_e)},children:[lt?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(jn,{className:"h-4 w-4 mr-1"}),"Preview pasted rows"]})})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border p-3",children:[e.jsx(In,{id:"import-create-missing",checked:fs,disabled:lt,onCheckedChange:m=>{ca(m===!0),Gt(null),bt(null)}}),e.jsxs("div",{className:"grid gap-0.5 leading-tight",children:[e.jsx(Z,{htmlFor:"import-create-missing",className:"cursor-pointer",children:"Create new shows for unmatched rows"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Rows with 
2no existing show become new shows. Requires"," ",e.jsx("strong",{children:"City"})," and ",e.jsx("strong",{children:"Region"}),' columns in the CSV (Region can be a state like "NY", a province, or a country). New past dates are marked as past shows.']})]})]}),_t&&e.jsx("p",{className:"text-sm text-destructive",children:_t}),Ae&&e.jsxs("div",{className:"grid gap-3 rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-medium",children:["Preview · ",Ae.updated," will update ·"," ",Ae.created," will create ·"," ",Ae.skipped.length," row",Ae.skipped.length===1?"":"s"," skipped"]}),e.jsxs(F,{size:"sm",disabled:lt||Ae.updated+Ae.created===0,onClick:()=>{Is()},children:[lt?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Confirm import"]})]}),Ae.preview.some(m=>m.via==="time")&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:["⚠ Rows marked ",e.jsx("strong",{children:"time-only"})," matched a show whose venue name is different — they were attached purely because the showtime lined up. Double-check these before confirming."]}),Ae.preview.length>0&&e.jsx("div",{className:"max-h-72 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"Your CSV row"}),e.jsx(U,{children:"Matches show"}),e.jsx(U,{children:"Match"}),e.jsx(U,{children:"Changes"})]})}),e.jsx(De,{children:Ae.preview.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.venue||"—"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.date,m.time!=="—"?` · ${m.time}`:""]})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.show.venue}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.show.city,", ",m.show.region.toUpperCase()," ·"," ",m.show.date," · ",m.show.time]})]}),e.jsx(_,{children:e.jsx(it,{variant:m.via==="exact"?"secondary":m.via==="fuzzy"?"outline":"destructive",children:m.via==="time"?"time-only":m.via})}),e.jsx(_,{className:"text-xs text-muted-foreground",children:[...m.changes.map(b=>`${b.label}: ${b.value}`),...m.merch.map(b=>`${b.name}: ${b.quantity}`)].join(" · ")||"—"})]},m.row))})]})}),Ae.creates.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:["New shows to create (",Ae.creates.length,")"]}),e.jsx("div",{className:"max-h-72 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"New show"}),e.jsx(U,{children:"Location"}),e.jsx(U,{children:"Values"})]})}),e.jsx(De,{children:Ae.creates.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.venue||"—"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.date,m.time!=="—"?` · ${m.time}`:""," ·"," ",m.status]})]}),e.jsxs(_,{className:"text-xs text-muted-foreground",children:[m.city,", ",m.region.toUpperCase()]}),e.jsx(_,{className:"text-xs text-muted-foreground",children:[...m.changes.map(b=>`${b.label}: ${b.value}`),...m.merch.map(b=>`${b.name}: ${b.quantity}`)].join(" · ")||"—"})]},m.row))})]})})]}),Ae.skipped.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:["Skipped (",Ae.skipped.length,")"]}),e.jsx("div",{className:"max-h-48 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"Date"}),e.jsx(U,{children:"Venue"}),e.jsx(U,{children:"Reason"})]})}),e.jsx(De,{children:Ae.skipped.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsx(_,{children:m.date||"—"}),e.jsx(_,{children:m.venue||"—"}),e.jsx(_,{className:"text-muted-foreground",children:m.reason})]},m.row))})]})})]})]}),jt&&e.jsxs("div",{className:"grid gap-2 rounded-md border p-3 text-sm",children:[e.jsxs("p",{className:"font-medium",children:["✓ ",jt.updated," updated · ",jt.created," ","created · ",jt.skipped.length," row",jt.skipped.length===1?"":"s"," skipped"]}),jt.skipped.length>0&&e.jsx("div",{className:"max-h-60 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-12",children:"Row"}),e.jsx(U,{children:"Date"}),e.jsx(U,{children:"Venue"}),e.jsx(U,{children:"Reason"})]})}),e.jsx(De,{children:jt.skipped.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsx(_,{children:m.date||"—"}),e.jsx(_,{children:m.venue||"—"}),e.jsx(_,{className:"text-muted-foreground",children:m.reason})]},m.row))})]})})]})]}),e.jsx(ut,{children:e.jsx(F,{variant:"outline",onClick:()=>Ut(!1),children:"Close"})})]})}),e.jsx(Ze,{open:ua,onOpenChange:Es,children:e.jsxs(Xe,{className:"max-w-4xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Import merch sheet"}),e.jsx(at,{children:"Paste rows from the tour merch spreadsheet (Date/Time, Venue, City, then one column per item). Quantities are your total sales — cash is worked out as total minus the Square card count. Nothing is written until you confirm the preview."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(Z,{htmlFor:"merch-import-paste",children:"Sheet rows"}),e.jsx(Pt,{id:"merch-import-paste",rows:6,placeholder:"Date/Time	Venue	City, ST	Albums	Reddit	...",value:Rs,disabled:Yt,onChange:m=>{Ls(m.target.value),gs(null),ln(null)},className:"font-mono text-xs"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(Z,{htmlFor:"merch-import-year",children:"Year"}),e.jsx(ne,{id:"merch-import-year",type:"number",className:"w-28",placeholder:"2024",value:cr,disabled:Yt,onChange:m=>{ma(m.target.value),gs(null),ln(null)}})]}),e.jsx("p",{className:"pb-2 text-xs text-muted-foreground",children:"The sheet's dates have no year, so pick the year these shows happened."}),e.jsx("div",{className:"ml-auto pb-0.5",children:e.jsxs(F,{size:"sm",disabled:Yt||!Rs.trim(),onClick:()=>{ha()},children:[Yt?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(jn,{className:"h-4 w-4 mr-1"}),"Preview"]})})]}),dr&&e.jsx("p",{className:"text-sm text-destructive",children:dr}),Ke&&e.jsxs("div",{className:"grid gap-3 rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-medium",children:["Preview · ",
2Ke.updated," show",Ke.updated===1?"":"s"," will update ·"," ",Ke.skipped.length," row",Ke.skipped.length===1?"":"s"," skipped"]}),e.jsxs(F,{size:"sm",disabled:Yt||Ke.updated===0,onClick:()=>{pa()},children:[Yt?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Confirm import"]})]}),Ke.unmatchedColumns.length>0&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:["⚠ Columns ignored (no matching merch item):"," ",Ke.unmatchedColumns.join(", ")]}),Ke.preview.some(m=>m.via==="time")&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:["⚠ Rows marked ",e.jsx("strong",{children:"time-only"})," matched a show whose venue name is different — double-check these before confirming."]}),Ke.preview.length>0&&e.jsx("div",{className:"max-h-72 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"Your sheet row"}),e.jsx(U,{children:"Matches show"}),e.jsx(U,{children:"Match"}),e.jsx(U,{children:"Merch (total · card / cash)"})]})}),e.jsx(De,{children:Ke.preview.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.venue||"—"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.date,m.time!=="—"?` · ${m.time}`:""]})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.show.venue}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.show.city,", ",m.show.region.toUpperCase()," ·"," ",m.show.date," · ",m.show.time]})]}),e.jsx(_,{children:e.jsx(it,{variant:m.via==="exact"?"secondary":m.via==="fuzzy"?"outline":"destructive",children:m.via==="time"?"time-only":m.via})}),e.jsxs(_,{className:"text-xs text-muted-foreground",children:[m.merch.map(b=>`${b.name}: ${b.quantity} (${b.card} card / ${b.cash} cash)`).join(" · ")||"—",m.warnings.length>0&&e.jsx("div",{className:"mt-1 text-amber-600 dark:text-amber-500",children:m.warnings.map((b,G)=>e.jsxs("div",{children:["⚠ ",b]},G))})]})]},m.row))})]})}),Ke.skipped.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:["Skipped (",Ke.skipped.length,")"]}),e.jsx("div",{className:"max-h-48 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"Date"}),e.jsx(U,{children:"Venue"}),e.jsx(U,{children:"Reason"})]})}),e.jsx(De,{children:Ke.skipped.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsx(_,{children:m.date||"—"}),e.jsx(_,{children:m.venue||"—"}),e.jsx(_,{className:"text-muted-foreground",children:m.reason})]},m.row))})]})})]})]}),wt&&e.jsxs("div",{className:"grid gap-2 rounded-md border p-3 text-sm",children:[e.jsxs("p",{className:"font-medium",children:["✓ ",wt.updated," show",wt.updated===1?"":"s"," updated ·"," ",wt.skipped.length," row",wt.skipped.length===1?"":"s"," skipped"]}),wt.skipped.length>0&&e.jsx("div",{className:"max-h-60 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-12",children:"Row"}),e.jsx(U,{children:"Date"}),e.jsx(U,{children:"Venue"}),e.jsx(U,{children:"Reason"})]})}),e.jsx(De,{children:wt.skipped.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsx(_,{children:m.date||"—"}),e.jsx(_,{children:m.venue||"—"}),e.jsx(_,{className:"text-muted-foreground",children:m.reason})]},m.row))})]})})]})]}),e.jsx(ut,{children:e.jsx(F,{variant:"outline",onClick:()=>Es(!1),children:"Close"})})]})}),e.jsx(Ze,{open:cn,onOpenChange:dn,children:e.jsxs(Xe,{className:"max-w-4xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Import lineup by date"}),e.jsx(at,{children:"Paste rows straight from your sheet — no header row needed. Four tab-separated columns: Date/Time, Venue, City, Local Guest (a header row still works too). Several names per cell are fine, separated by commas or slashes. Pick whether everyone in this paste joins as a local guest, support act, or tour manager. Rows attach by date alone; when a date has more than one show, everyone in the row is added to all of them (the Venue and City columns are ignored). Names already in your roster are matched; names that aren't are created as new local guests and attached. Support acts and tour managers are one-per-show, so a spot that's already filled is flagged. Nothing is written until you confirm the preview."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(Z,{htmlFor:"guest-import-paste",children:"Sheet rows"}),e.jsx(Pt,{id:"guest-import-paste",rows:6,placeholder:"Date/Time	Venue	City, ST	Local Guest",value:xs,disabled:Zt,onChange:m=>{un(m.target.value),es(null),mn(null)},className:"font-mono text-xs"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(Z,{htmlFor:"guest-import-role",children:"Add everyone as"}),e.jsxs(ns,{value:vs,disabled:Zt,onValueChange:m=>{ur(m),es(null),mn(null)},children:[e.jsx(rs,{id:"guest-import-role",className:"w-40",children:e.jsx(as,{})}),e.jsxs(is,{children:[e.jsx(Ge,{value:"guest",children:"Local guest"}),e.jsx(Ge,{value:"support",children:"Support act"}),e.jsx(Ge,{value:"tour_manager",children:"Tour manager"})]})]})]}),e.jsx("p",{className:"pb-2 text-xs text-muted-foreground",children:"Dates without a year (e.g. 5/11) assume the current year; write it out (5/11/2024) for older shows."}),e.jsx("div",{className:"ml-auto pb-0.5",children:e.jsxs(F,{size:"sm",disabled:Zt||!xs.trim(),onClick:()=>{S()},children:[Zt?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(jn,{className:"h-4 w-4 mr-1"}),"Preview"]})})]}),Fs&&e.jsx("p",{className:"text-sm text-destructive",children:Fs}),ze&&e.jsxs("div",{className:"grid gap-3 rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-medium",children:["Preview · ",ze.attached," ",(ze.attached===1?Ct[dt?.role??"guest"].noun:Ct[dt?.role??"guest"].nounPlural).toLowerCase()," ","will attach · ",ze.skipped.length," row",ze.skipped.length===1?"":"s"," skipped"]}),e.jsxs(F,{size:"sm",disabled:Zt||ze.attached===0,onClick:()=>{k()},children:[Zt?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Confirm import"]}
2)]}),ze.unmatchedNames.length>0&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:["⚠ Names not in your roster — they'll be created as new local guests when you confirm:"," ",ze.unmatchedNames.join(", ")]}),ze.preview.some(m=>m.guests.some(b=>b.status==="roletaken"))&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:["⚠ Names marked ",e.jsx("strong",{children:"(spot taken)"})," were skipped — that show already has a"," ",Ct[dt?.role??"guest"].noun.toLowerCase(),". Each show holds only one support act and one tour manager."]}),ze.preview.length>0&&e.jsx("div",{className:"max-h-72 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"Your sheet row"}),e.jsx(U,{children:"Matches show"}),e.jsx(U,{children:"Match"}),e.jsx(U,{children:"Guests"})]})}),e.jsx(De,{children:ze.preview.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.venue||"—"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.date,m.time!=="—"?` · ${m.time}`:""]})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-medium",children:m.show.venue}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.show.city,", ",m.show.region.toUpperCase()," ·"," ",m.show.date," · ",m.show.time]})]}),e.jsx(_,{children:e.jsx(it,{variant:m.via==="date"||m.via==="exact"?"secondary":m.via==="fuzzy"?"outline":"destructive",children:m.via==="time"?"time-only":m.via==="date"?"date":m.via})}),e.jsx(_,{className:"text-xs",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:m.guests.map((b,G)=>e.jsxs(it,{variant:b.status==="add"||b.status==="create"?"secondary":b.status==="already"?"outline":"destructive",title:b.status==="notfound"?"This name has no letters to match or create":b.status==="create"?"Not in your roster — will be created as a new local guest":b.status==="ambiguous"?"More than one act has this name":b.status==="already"?"Already on this show":b.status==="roletaken"?`That ${Ct[dt?.role??"guest"].noun.toLowerCase()} spot is already filled on this show`:"Will be attached",children:[b.name,b.status==="already"?" ✓":b.status==="create"?" (new)":b.status==="notfound"?" (not found)":b.status==="ambiguous"?" (ambiguous)":b.status==="roletaken"?" (spot taken)":""]},G))})})]},`${m.row}-${m.show.id}`))})]})}),ze.skipped.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:["Skipped (",ze.skipped.length,")"]}),e.jsx("div",{className:"max-h-48 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-10",children:"Row"}),e.jsx(U,{children:"Date"}),e.jsx(U,{children:"Venue"}),e.jsx(U,{children:"Reason"})]})}),e.jsx(De,{children:ze.skipped.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsx(_,{children:m.date||"—"}),e.jsx(_,{children:m.venue||"—"}),e.jsx(_,{className:"text-muted-foreground",children:m.reason})]},m.row))})]})})]})]}),St&&e.jsxs("div",{className:"grid gap-2 rounded-md border p-3 text-sm",children:[e.jsxs("p",{className:"font-medium",children:["✓ ",St.attached," ",(St.attached===1?Ct[fa].noun:Ct[fa].nounPlural).toLowerCase()," ","attached · ",St.skipped.length," row",St.skipped.length===1?"":"s"," skipped"]}),St.unmatchedNames.length>0&&e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:["Created as new local guests:"," ",St.unmatchedNames.join(", ")]}),St.skipped.length>0&&e.jsx("div",{className:"max-h-60 overflow-auto rounded border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{className:"w-12",children:"Row"}),e.jsx(U,{children:"Date"}),e.jsx(U,{children:"Venue"}),e.jsx(U,{children:"Reason"})]})}),e.jsx(De,{children:St.skipped.map(m=>e.jsxs(he,{children:[e.jsx(_,{children:m.row}),e.jsx(_,{children:m.date||"—"}),e.jsx(_,{children:m.venue||"—"}),e.jsx(_,{className:"text-muted-foreground",children:m.reason})]},m.row))})]})})]})]}),e.jsx(ut,{children:e.jsx(F,{variant:"outline",onClick:()=>dn(!1),children:"Close"})})]})}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border bg-card p-3 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(Ms,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ne,{placeholder:"Search venue or city...",className:"pl-9",value:W,onChange:m=>ie(m.target.value)})]}),e.jsxs("select",{"aria-label":"Filter by time",className:Ne,value:H,onChange:m=>oe(m.target.value),children:[e.jsx("option",{value:"upcoming",children:"Upcoming"}),e.jsx("option",{value:"past",children:"Past"}),e.jsx("option",{value:"all",children:"All dates"})]}),e.jsxs("select",{"aria-label":"Filter by region",className:Ne,value:R,onChange:m=>re(m.target.value),children:[e.jsx("option",{value:"all",children:"All regions"}),ee.map(([m,b])=>e.jsx("option",{value:m,children:b},m))]}),e.jsxs("select",{"aria-label":"Sort shows",className:ht(Ne,"md:hidden"),value:te?`${te}-${V}`:"default",onChange:m=>{const b=m.target.value;if(b==="default"){ce(null);return}const[G,ye]=b.split("-");ce(G),ue(ye)},children:[e.jsx("option",{value:"default",children:"Sort: Default"}),e.jsx("option",{value:"date-asc",children:"Date: Soonest first"}),e.jsx("option",{value:"date-desc",children:"Date: Latest first"}),e.jsx("option",{value:"venue-asc",children:"Venue: A–Z"}),e.jsx("option",{value:"venue-desc",children:"Venue: Z–A"}),e.jsx("option",{value:"city-asc",children:"City: A–Z"}),e.jsx("option",{value:"city-desc",children:"City: Z–A"}),e.jsx("option",{value:"clicks-desc",children:"Clicks: Most first"}),e.jsx("option",{value:"clicks-asc",children:"Clicks: Fewest first"})]}),Re?e.jsxs(F,{variant:"ghost",size:"sm",onClick:We,className:"text-muted-foreground",children:[e.jsx(en,{className:"h-4 w-4 mr-1"})," Clear"]}):null,e.jsxs("span",{className:"text-xs text-muted-foreground sm:ml-auto",children:[pe.length," of ",(a??[]).length," shows"]})]}),o?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-w-0 md:overflow-hidden md:rounded-lg md:border",children:e.jsxs(Pe,{className:"block w-full md:table",children:[e.jsx(Me,{className:"hidden md:table-header-group",children:e.jsxs(he,{children:[e.jsx(Tr,{label:"Date",sortKey:"date",current:te,dir:V,onSort:B}),e.jsx(Tr,{label:"Venue",sortKey:"venue",current:te,dir:V,onSort:B}),e.jsx(Tr,{label:"City",sortKey:"city",current:te,dir:V,onSort:B}),e.jsx(Tr,{label:"Clicks",sortKey:"clicks",current:te,dir:V,onSort:B,align:"right"}),e.jsx(U,{className:"text-right",children:"Sold"}),e.jsx(U,{className:"text-right",children:"Tix Updated"}),e.jsx(U,{className:"text-right",children:"M&G"}),e.jsx(U,{className:"text-right",children:"Actions"})]})}),e.jsxs(De,{className:"block space-y-3 md:table-row-group md:space-y-0",children:[pe.map(m=>e.jsxs(he,{className:"block overflow-hidden rounded-lg border bg-card shadow-sm md:table-row md:rounded-none md:border-x-0 md:border-t-0 md:shadow-none",children:[e.jsxs(_,{className:"flex items-center justify-between gap-4 whitespace-nowrap border-b px-4 py-3 md:table-cell md:border-b-0 md:px-2 md:py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"Date"}),new Date(m.date).toLocaleDateString("en-US",{timeZone:"America/Ne
2w_York",month:"numeric",day:"numeric",year:"2-digit"})]}),e.jsxs(_,{className:"flex items-start justify-between gap-4 border-b px-4 py-3 text-right font-medium md:table-cell md:border-b-0 md:px-2 md:py-2 md:text-left",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"Venue"}),Zy(m)]}),e.jsxs(_,{className:"flex items-start justify-between gap-4 border-b px-4 py-3 text-right md:table-cell md:border-b-0 md:px-2 md:py-2 md:text-left",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"City"}),e.jsxs("span",{children:[m.city,m.region?`, ${m.region.toUpperCase()}`:""]})]}),e.jsxs(_,{className:"flex items-center justify-between gap-4 border-b px-4 py-3 text-right font-semibold tabular-nums md:table-cell md:border-b-0 md:px-2 md:py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"Clicks"}),m.ticketUrl?w.get(m.ticketUrl)??0:"—"]}),e.jsxs(_,{className:"flex items-center justify-between gap-4 border-b px-4 py-3 text-right md:table-cell md:border-b-0 md:px-2 md:py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"Sold"}),e.jsx(mb,{show:m})]}),e.jsxs(_,{className:"flex items-center justify-between gap-4 whitespace-nowrap border-b px-4 py-3 text-right md:table-cell md:border-b-0 md:px-2 md:py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"Tix updated"}),(()=>{const b=gc(m.ticketsUpdatedAt);return b?e.jsx("span",{className:ht("font-medium",b.className),children:b.label}):e.jsx("span",{className:"text-muted-foreground",children:"—"})})()]}),e.jsxs(_,{className:"flex items-center justify-between gap-4 border-b px-4 py-3 text-right tabular-nums md:table-cell md:border-b-0 md:px-2 md:py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground md:hidden",children:"Meet & greet"}),m.meetGreet??"—"]}),e.jsxs(_,{className:"flex items-center justify-end gap-1 px-3 py-2 text-right md:table-cell md:px-2",children:[e.jsxs(F,{variant:"ghost",size:"sm","aria-label":"Manage support acts",title:"Support",onClick:()=>v(m),children:[e.jsx(Bi,{className:"h-4 w-4"}),e.jsx("span",{className:"md:hidden",children:"Support"}),m.supportActs&&m.supportActs.length>0?e.jsx("span",{className:"ml-0.5 text-xs font-semibold",children:m.supportActs.length}):null]}),e.jsxs(F,{variant:"ghost",size:"sm","aria-label":"Edit show",onClick:()=>pr(m),children:[e.jsx(En,{className:"h-4 w-4"}),e.jsx("span",{className:"md:hidden",children:"Edit"})]}),e.jsxs(F,{variant:"ghost",size:"sm","aria-label":"Delete show",onClick:()=>E(m.id),children:[e.jsx(ls,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"sr-only",children:"Delete"})]})]})]},m.id)),pe.length===0?e.jsx(he,{children:e.jsx(_,{colSpan:8,className:"block py-8 text-center text-muted-foreground md:table-cell",children:(a??[]).length===0?"No shows yet. Add your first tour date.":"No shows match these filters."})}):null]})]})}),e.jsx(Ze,{open:A,onOpenChange:N,children:e.jsxs(Xe,{className:"max-h-[90vh] overflow-y-auto",children:[e.jsxs(Je,{children:[e.jsx(et,{children:I!=null?"Edit show":"Add show"}),e.jsx(at,{children:"Tour date details shown on the public site."})]}),e.jsxs("div",{className:"grid gap-4 py-2",children:[I==null?e.jsxs("div",{className:"grid gap-2 rounded-lg border border-dashed bg-muted/30 p-3",children:[e.jsx(Z,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Quick add from a past venue"}),e.jsx(hb,{venues:i,isLoading:d,onSelect:vr})]}):null,e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-muted/30 p-3",children:[e.jsxs("div",{className:"grid gap-0.5",children:[e.jsx(Z,{htmlFor:"isDigital",children:"Digital show"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Online event — shows as "Online", no physical venue or region.'})]}),e.jsx($r,{id:"isDigital",checked:!!y.isDigital,onCheckedChange:m=>T({...y,isDigital:m})})]}),y.isDigital&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"title",children:"Event name"}),e.jsx(ne,{id:"title",placeholder:"e.g. New Year's Eve Livestream",value:y.title??"",onChange:m=>T({...y,title:m.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Shown with "Online" on the calendar.'})]}),!y.isDigital&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"venue",children:"Venue"}),e.jsx(ne,{id:"venue",value:y.venue,onChange:m=>T({...y,venue:m.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[!y.isDigital&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"city",children:"City"}),e.jsx(ne,{id:"city",value:y.city,onChange:m=>T({...y,city:m.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"date",children:"Date & time"}),e.jsx(ne,{id:"date",type:"datetime-local",value:y.date,onChange:m=>T({...y,date:m.target.value})})]})]}),!y.isDigital&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"region",children:"Region"}),e.jsxs("select",{id:"region",className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:z?"__custom__":hn(y.region)?.code??"",onChange:m=>va(m.target.value),children:[e.jsx("option",{value:"",children:"Select region…"}),zh.map(m=>e.jsx("optgroup",{label:m.kind==="US State"?"US States":m.kind==="Canadian Province"?"Canadian Provinces":"Countries",children:m.regions.map(b=>e.jsx("option",{value:b.code,children:b.label},b.code))},m.kind)),e.jsx("option",{value:"__custom__",children:"Other / custom…"})]}),!z&&(()=>{const m=hn(y.region);return m?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Code ",e.jsx("code",{className:"font-mono",children:m.code})," ·"," ",m.kind]}):null})()]}),z&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"regionCode",children:"Region code"}),e.jsx(ne,{id:"regionCode",placeholder:"ny, canada...",value:y.region,onChange:m=>T({...y,region:m.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Short key used for timezones & filtering. Use a state / province code or a country name."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"regionLabel",children:"Region label"}),e.jsx(ne,{id:"regionLabel",placeholder:"New York",value:y.regionLabel,onChange:m=>T({...y,regionLabel:m.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display name shown on the site."})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"ticketUrl",children:"Ticket URL"}),e.jsx(ne,{id:"ticketUrl",placeholder:"https://...",value:y.ticketUrl??"",onChange:m=>T({...y,ticketUrl:m.target.value})})]})}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"meetGreetUrl",children:"Meet And Greet URL"}),e.jsx(ne,{id:"meetGreetUrl",placeholder:"https://... (optional)",value:y.meetGreetUrl??"",onChange:m=>T({...y,meetGreetUrl:m.target.value})})]}),!y.isDigital&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"address",children:"Venue address"}),e.jsx(ne,{id:"address",placeholder:"123 Main St, City, ST 00000",value:y.address??"",onChange:m=>T({...y,address:m.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"venuePhone",children:"Venue phone"}),e.jsx(ne,{id:"venuePhone",placeholder:"Auto-filled from Google if left blank",value:y.venuePhone??"",onChange:m=>T({...y,venuePhone:m.target.value})})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"note",children:"Note"}),e.jsx(Pt,{id:"note",value:y.note??"",onChange:m=>T({...y,note:m.target.value})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Internal tracking"}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Optional internal numbers. Leave a field blank if unused."}),ob.map(m=>e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:m}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:lb.filter(b=>b.group===m).map(b=>{const G=b.key==="venueCost"||b.key==="venuePaid"||b.key==="myGross",ye=G?b.key==="venueCost"?Ci(y):b.key==="venuePaid"?xu(y):vu(y):null,ve=G&&$n(y),je=ve&&On(y[b.key])!=null,rt=G&&!ve,Fe=G?je?y[b.key]:ye:y[b.key],Ft=b.key==="openersOverride"&&I!=null?(()=>{const pt=a?.find(zt=>zt.id===I);return pt?fu(pt):null})():null;return e.jsxs("div",{className:"grid gap-1",children:[e.jsx(Z,{htmlFor:`show-${b.key}`,className:"text-xs",children:b.label}),e.jsx(ne,{id:`show-${b.key}`,type:"number",step:b.money?"0.01":"1",readOnly:rt,placeholder:Ft!=null?`Auto: ${(Ft/100).toLocaleStr
2ing("en-US",{style:"currency",currency:"USD"})}`:void 0,className:rt?"bg-muted text-muted-foreground":void 0,title:G?ve?"Calculated automatically; type a value to override it for this past show, or clear it to go back to the calculation.":"Calculated automatically from the venue settings. Becomes editable once the show is in the past.":b.key==="ourTix"||b.key==="venueTix"?"Press Enter to refresh the updated date, even if the number hasn't changed.":void 0,onKeyDown:b.key==="ourTix"||b.key==="venueTix"?kt:void 0,value:Fe==null?"":b.money?Fe/100:Fe,onChange:pt=>{rt||T({...y,[b.key]:pt.target.value===""?null:b.money?Math.round(Number(pt.target.value)*100):Number(pt.target.value)})}})]},b.key)})})]},m)),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(Z,{htmlFor:"show-grossSales",className:"text-xs",children:"Our Sales $"}),e.jsx(ne,{id:"show-grossSales",type:"number",step:"1",min:"0",placeholder:"Estimated at $32 / ticket",title:"Press Enter to refresh the updated date, even if the number hasn't changed.",onKeyDown:kt,value:y.grossSales==null?"":y.grossSales/100,onChange:m=>T({...y,grossSales:m.target.value===""?null:Math.round(Number(m.target.value)*100)})}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Whole dollars. Auto-filled from Eventbrite for linked shows; otherwise estimated at $32 × tickets sold until you enter the real figure."})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Venue cost"}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Venue expense and % are the deal terms, not the final settlement. Deal cost = expense + % × max(0, total ticket sales − expense). Blank or 0% means expense only. Venue Paid = Venue Sold − effective Venue Cost + Venue +; My Gross = Venue Paid + Our Sales. On past shows, nonzero manual Cost, Paid, and Gross entries take precedence over their respective calculations. Clear a manual entry to return to the calculation. Future shows use the live calculation; stored manual entries remain dormant."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-1",children:[e.jsx(Z,{htmlFor:"show-venueExpenseThreshold",className:"text-xs",children:"Venue expense $"}),e.jsx(ne,{id:"show-venueExpenseThreshold",type:"text",inputMode:"decimal",placeholder:"Taken off the top before % applies",value:L,onChange:m=>{const b=m.target.value;O(b);const G=Ql(b);G!==void 0&&(G==null||G>=0)&&T(ye=>({...ye,venueExpenseThreshold:G}))}})]}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(Z,{htmlFor:"show-venueBonus",className:"text-xs",children:"Venue +"}),e.jsx(ne,{id:"show-venueBonus",type:"number",step:"1",placeholder:"Bonus (+) or extra expense (−), added to Venue Paid",value:y.venueBonus==null?"":y.venueBonus/100,onChange:m=>T({...y,venueBonus:m.target.value===""?null:Math.round(Number(m.target.value)*100)})})]}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(Z,{htmlFor:"show-venuePercent",className:"text-xs",children:"Venue % of sales"}),e.jsx(ne,{id:"show-venuePercent",type:"number",step:"0.01",min:"0",placeholder:"Blank or 0 = expense only",value:y.venuePercentBps==null?"":y.venuePercentBps/100,onChange:m=>T({...y,venuePercentBps:m.target.value===""?null:Math.round(Number(m.target.value)*100)})})]}),e.jsxs("div",{className:"grid gap-1 sm:col-span-2",children:[e.jsx(Z,{htmlFor:"show-venuePercentNote",className:"text-xs",children:"Venue Note"}),e.jsx(Pt,{id:"show-venuePercentNote",rows:2,placeholder:"Notes about the venue arrangement (split terms, payout timing, etc.)",value:y.venuePercentNote??"",onChange:m=>T({...y,venuePercentNote:m.target.value===""?null:m.target.value})})]})]}),(y.venueExpenseThreshold!=null||y.venuePercentBps!=null)&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:(()=>{const m=Ci(y);return m==null?"Enter Ticket Sales above to compute the percentage-based cost.":$n(y)?`Deal cost: ${Dt(m)} — final Venue Cost: ${Dt(On(y.venueCost)??m)}.`:`Calculated deal cost: ${Dt(m)} — fills Venue Cost above automatically.`})()})]}),(()=>{const m=(a??[]).find(ve=>ve.id===I);if(!m||!m.eventbriteSyncedAt)return null;const b=m.ourTix,G=m.eventbriteCapacity??m.capacity,ye=G!=null&&G>0&&b!=null?b/G:null;return e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Eventbrite sales"}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Read-only; refreshed automatically. Our Tix and Capacity above are filled from this."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sold"}),e.jsx("p",{className:"font-semibold tabular-nums",children:b??0})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Capacity"}),e.jsx("p",{className:"font-semibold tabular-nums",children:G??"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"% Sold"}),e.jsx("p",{className:"font-semibold tabular-nums",children:ye!=null?`${Math.round(ye*100)}%`:"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Gross"}),e.jsx("p",{className:"font-semibold tabular-nums",children:m.grossSales!=null?Dt(m.grossSales):"—"})]})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Last synced"," ",new Date(m.eventbriteSyncedAt).toLocaleStr
2ing()]})]})})(),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Merch sold"}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Units sold at this show by payment method; the total is the sum of the four methods. Manage the catalog and ownership in the Show Merch tab."}),q.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No merch items are marked as currently selling."}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"hidden gap-2 sm:grid sm:grid-cols-[1fr_repeat(5,minmax(0,3.5rem))]",children:[e.jsx("span",{}),["Card","Cash","Cash TM","Cash Sup","Total"].map(m=>e.jsx("span",{className:"text-center text-[11px] text-muted-foreground",children:m},m))]}),q.map(m=>{const b=y.merchSales?.find(Fe=>Fe.merchId===m.id),G=m.ownerActId==null?null:u.find(Fe=>Fe.id===m.ownerActId),ye=m.ownerActId!=null?G?`${G.firstName} ${G.lastName}`:"Support / tour manager":m.ownerGuest?"Guest":null,ve=[b?.qtyCard??null,b?.qtyCash??null,b?.qtyCashTm??null,b?.qtyCashSupport??null],je=ve.some(Fe=>Fe!=null)?ve.reduce((Fe,Ft)=>Fe+(Ft??0),0):null,rt=["qtyCard","qtyCash","qtyCashTm","qtyCashSupport"];return e.jsxs("div",{className:"grid grid-cols-2 items-center gap-2 sm:grid-cols-[1fr_repeat(5,minmax(0,3.5rem))]",children:[e.jsxs("div",{className:"col-span-2 sm:col-span-1",children:[e.jsxs("p",{className:"text-xs font-medium",children:[m.name,m.currentlySelling?null:e.jsx("span",{className:"ml-1 font-normal text-[11px] text-muted-foreground",children:"(discontinued)"})]}),ye?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:ye}):null]}),rt.map((Fe,Ft)=>e.jsx(ne,{"aria-label":`${m.name} ${Fe}`,type:"number",step:"any",min:"0",className:"h-8 px-2 text-sm",value:ve[Ft]??"",onChange:pt=>fr(m.id,Fe,pt.target.value===""?null:Number(pt.target.value))},Fe)),e.jsx("div",{className:"text-center text-sm font-medium tabular-nums",children:je??"—"})]},m.id)})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Cash tips"}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Cash tips collected at this show, split across the people who collected them. These add to the run-payout tips pool and to the collector's held cash. (Card tips sync from Square separately.)"}),e.jsxs("div",{className:"space-y-2",children:[(y.cashTips??[]).map((m,b)=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,7rem)_1fr_auto] items-center gap-2",children:[e.jsx(ne,{"aria-label":`Cash tip amount ${b+1}`,type:"number",step:"0.01",min:"0",inputMode:"decimal",placeholder:"0.00",className:"h-8 px-2 text-sm",value:m.amountCents===0?"":m.amountCents/100,onChange:G=>xr(b,{amountCents:G.target.value===""?0:Math.round(Number(G.target.value)*100)})}),e.jsxs(ns,{value:m.collectorActId==null?"steve":String(m.collectorActId),onValueChange:G=>xr(b,{collectorActId:G==="steve"?null:Number(G)}),children:[e.jsx(rs,{"aria-label":`Cash tip collector ${b+1}`,className:"h-8 text-sm",children:e.jsx(as,{})}),e.jsxs(is,{children:[e.jsx(Ge,{value:"steve",children:"Steve"}),u.filter(G=>G.category==="support"||G.category==="tour_manager").map(G=>e.jsxs(Ge,{value:String(G.id),children:[G.firstName," ",G.lastName,G.category==="tour_manager"?" (TM)":""]},G.id))]})]}),e.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground","aria-label":`Remove cash tip ${b+1}`,onClick:()=>ga(b),children:e.jsx(ls,{className:"h-4 w-4"})})]},b)),e.jsxs(F,{type:"button",variant:"outline",size:"sm",onClick:gr,children:[e.jsx(gt,{className:"mr-1 h-4 w-4"})," Add cash tip"]})]})]})]}),e.jsxs(ut,{children:[e.jsx(F,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(F,{onClick:xa,disabled:yr,children:yr?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})}),e.jsx(Un,{open:j!=null,onOpenChange:m=>!m&&E(null),children:e.jsxs(_n,{children:[e.jsxs(qn,{children:[e.jsx(Gn,{children:"Delete this show?"}),e.jsx(Kn,{children:"This permanently removes the tour date from the site."})]}),e.jsxs(zn,{children:[e.jsx(Hn,{children:"Cancel"}),e.jsx(Wn,{onClick:()=>j!=null&&mr.mutate({id:j}),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Hb,{show:g,acts:u,lineup:a?.find(m=>m.id===g?.id)?.lineup??[],onOpenChange:m=>!m&&v(null)})]})}function gb({title:t,description:s,bullets:n}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:t}),e.jsxs("div",{className:"border rounded-lg p-8 bg-card space-y-5 max-w-2xl",children:[e.jsx("p",{className:"text-muted-foreground",children:s}),e.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground list-disc pl-5",children:n.map(a=>e.jsx("li",{children:a},a))}),e.jsx(F,{asChild:!0,children:e.jsxs("a",{href:"https://login.bigcommerce.com/",target:"_blank",rel:"noopener noreferrer",children:["Open BigCommerce admin",e.jsx(np,{className:"h-4 w-4 ml-2"})]})})]})]})}function xb(){const{toast:t}=Ye(),s=nt(),{data:n=[],isLoading:r}=vc(void 0,{query:{queryKey:Ha()}}),{data:a,isLoading:o}=yh({query:{queryKey:So()}}),i=h.useMemo(()=>new Map(n.map(N=>[N.handle,N])),[n]),d=h.useMemo(()=>(a?.handles??[]).filter(N=>i.has(N)),[a,i]),[u,c]=h.useState([]),[l,p]=h.useState(!1);h.useEffect(()=>{l||!a||n.length===0||(c(a.handles.filter(N=>i.has(N))),p(!0))},[l,a,n,i]);const g=l&&u.join(",")!==d.join(","),v=n.filter(N=>!u.includes(N.handle)),w=jh({mutation:{onSuccess:()=>{s.invalidateQueries({queryKey:So()}),t({title:"Featured merch saved"})},onError:()=>t({title:"Could not save featured merch",variant:"destructive"})}}),A=r||o;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Featured Merch"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 max-w-2xl",children:"Choose which products appear in the Featured Merch section on the homepage, and drag to set their order. Price
2s, images, and stock stay in sync with BigCommerce."})]}),e.jsxs(F,{onClick:()=>w.mutate({data:{handles:u}}),disabled:!g||w.isPending,children:[w.isPending?e.jsx(le,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Save order"]})]}),A?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"})," Loading products..."]}):e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2 max-w-5xl",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground",children:["Featured (",u.length,") — drag to reorder"]}),u.length===0?e.jsx("div",{className:"border border-dashed rounded-lg p-6 text-sm text-muted-foreground",children:'No featured products selected. Add some from the right. If left empty, the homepage falls back to BigCommerce "featured"-tagged products.'}):e.jsx(xo,{axis:"y",values:u,onReorder:c,className:"space-y-2",children:u.map((N,I)=>{const C=i.get(N);return C?e.jsxs(vo,{value:N,className:"flex items-center gap-3 rounded-lg border bg-card p-2 cursor-grab active:cursor-grabbing",children:[e.jsx(Ui,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"w-5 text-center text-xs font-bold text-muted-foreground",children:I+1}),e.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded bg-secondary",children:C.imageUrl?e.jsx("img",{src:C.imageUrl,alt:C.title,className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-bold",children:C.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[C.category," · $",C.price.toFixed(2)]})]}),e.jsx(F,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(u.filter(y=>y!==N)),children:e.jsx(en,{className:"h-4 w-4"})})]},N):null})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground",children:["All products (",v.length,")"]}),v.length===0?e.jsx("div",{className:"border border-dashed rounded-lg p-6 text-sm text-muted-foreground",children:"Every product is featured."}):e.jsx("div",{className:"space-y-2",children:v.map(N=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-2",children:[e.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded bg-secondary",children:N.imageUrl?e.jsx("img",{src:N.imageUrl,alt:N.title,className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-bold",children:N.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.category," · $",N.price.toFixed(2)]})]}),e.jsxs(F,{type:"button",variant:"outline",size:"sm",onClick:()=>c([...u,N.handle]),children:[e.jsx(sp,{className:"h-4 w-4 mr-1"})," Feature"]})]},N.handle))})]})]})]})}const Ar=["album","book","shirt","sticker"],_a={album:"Albums",book:"Books",shirt:"Shirts",sticker:"Stickers"};function vb(t){return[...t].sort((s,n)=>{const r=Ar.indexOf(s),a=Ar.indexOf(n),o=r===-1?Ar.length:r,i=a===-1?Ar.length:a;return o!==i?o-i:s.localeCompare(n)})}function yb(){const{toast:t}=Ye(),s=nt(),{data:n=[],isLoading:r}=vc(void 0,{query:{queryKey:Ha()}}),{data:a,isLoading:o}=bh({query:{queryKey:ko()}}),i=h.useMemo(()=>new Map(n.map(y=>[y.handle,y])),[n]),d=h.useMemo(()=>(y,T)=>{const L=new Map,O=[];y.forEach((z,x)=>{const j=i.get(z);if(!j)return;const E=j.category||"other";L.has(E)||L.set(E,[]),L.get(E).push(z),x<T&&!O.includes(E)&&O.push(E)});const q=vb([...L.keys()].filter(z=>!O.includes(z)));return[...O,...q].flatMap(z=>L.get(z))},[i]),u=h.useMemo(()=>{const y=(a?.handles??[]).filter(O=>i.has(O)),T=new Set(y),L=n.map(O=>O.handle).filter(O=>!T.has(O));return d([...y,...L],y.length)},[a,n,i,d]),[c,l]=h.useState([]),[p,g]=h.useState(!1);h.useEffect(()=>{p||!a||n.length===0||(l(u),g(!0))},[p,a,n,u]);const v=h.useMemo(()=>{const y=new Map;for(const T of c){const L=i.get(T);if(!L)continue;const O=L.category||"other";y.has(O)||y.set(O,[]),y.get(O).push(T)}return[...y.keys()].map(T=>({cat:T,handles:y.get(T)}))},[c,i]);function w(y,T){const L=new Map(v.map(O=>[O.cat,O.handles]));L.set(y,T),l(v.flatMap(O=>L.get(O.cat)))}function A(y,T){const L=v.findIndex(z=>z.cat===y),O=L+T;if(L===-1||O<0||O>=v.length)return;const q=[...v];[q[L],q[O]]=[q[O],q[L]],l(q.flatMap(z=>z.handles))}const N=p&&c.join(",")!==u.join(","),I=wh({mutation:{onSuccess:()=>{s.invalidateQueries({queryKey:ko()}),s.invalidateQueries({queryKey:Ha()}),t({title:"Store order saved"})},onError:()=>t({title:"Could not save store order",variant:"destructive"})}}),C=r||o;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Store Order"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 max-w-2xl",children:"Drag products to set the order they appear in the Merch store, and use the arrows to reorder the categories themselves. Items stay in this order when shoppers filter by a category. Prices, images, and stock stay in sync with BigCommerce."})]}),e.jsxs(F,{onClick:()=>I.mutate({data:{handles:c}}),disabled:!N||I.isPending,children:[I.isPending?e.jsx(le,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Save order"]}
2)]}),C?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"})," Loading products..."]}):v.length===0?e.jsx("div",{className:"border border-dashed rounded-lg p-6 text-sm text-muted-foreground",children:"No products found. Add products in your BigCommerce admin and they will appear here."}):e.jsx("div",{className:"grid gap-8 md:grid-cols-2 max-w-5xl",children:v.map((y,T)=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground",children:[T+1,". ",_a[y.cat]??y.cat," (",y.handles.length,") — drag to reorder"]}),e.jsx(F,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:T===0,onClick:()=>A(y.cat,-1),"aria-label":`Move ${_a[y.cat]??y.cat} earlier`,children:e.jsx(cp,{className:"h-3.5 w-3.5"})}),e.jsx(F,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:T===v.length-1,onClick:()=>A(y.cat,1),"aria-label":`Move ${_a[y.cat]??y.cat} later`,children:e.jsx(op,{className:"h-3.5 w-3.5"})})]}),e.jsx(xo,{axis:"y",values:y.handles,onReorder:L=>w(y.cat,L),className:"space-y-2",children:y.handles.map((L,O)=>{const q=i.get(L);return q?e.jsxs(vo,{value:L,className:"flex items-center gap-3 rounded-lg border bg-card p-2 cursor-grab active:cursor-grabbing",children:[e.jsx(Ui,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"w-5 text-center text-xs font-bold text-muted-foreground",children:O+1}),e.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded bg-secondary",children:q.imageUrl?e.jsx("img",{src:q.imageUrl,alt:q.title,className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-bold",children:q.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["$",q.price.toFixed(2)]})]})]},L):null})})]},y.cat))})]})}function jb(){return e.jsxs("div",{className:"space-y-10",children:[e.jsx(xb,{}),e.jsx(yb,{}),e.jsx(gb,{title:"Manage merch in BigCommerce",description:"Products, prices, images, and inventory are managed in your BigCommerce admin and sync automatically to the store.",bullets:["Add or edit products, prices, and photos in BigCommerce.","Update stock levels and a product sells out automatically on the site.","Changes appear on the storefront without any extra steps."]})]})}function Js({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[t&&e.jsx("h4",{className:"font-display text-xs font-bold uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("dl",{className:"space-y-1.5",children:s})]})}function xt({value:t,name:s}){return t==null||String(t).trim()===""?e.jsx("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-xs font-semibold text-amber-700 ring-1 ring-amber-500/30 dark:text-amber-400",children:s?`${s} Missing`:"Missing"}):e.jsx(e.Fragment,{children:t})}function bb(t){return t&&t.replace(/,?\s*(USA|United States)\.?\s*$/i,"").trim()||null}const wb={street:"St",avenue:"Ave",boulevard:"Blvd",road:"Rd",drive:"Dr",lane:"Ln",court:"Ct",place:"Pl",square:"Sq",terrace:"Ter",parkway:"Pkwy",circle:"Cir",highway:"Hwy",plaza:"Plz",trail:"Trl",turnpike:"Tpke",expressway:"Expy",suite:"Ste"};function Nb(t){return t.replace(/\b[A-Za-z]+\b/g,s=>wb[s.toLowerCase()]??s)}function zs(t){const s=bb(t);if(!s)return null;const n=s.split(",").map(a=>a.trim()).filter(Boolean),r=n.length-1;return n.map((a,o)=>{let i=Nb(a);const d=n.length>1||/\s+\d{5}(?:-\d{4})?$/.test(i);return o===r&&d&&(i=i.replace(/^(.+?)(\s+\d{5}(?:-\d{4})?)?$/,(u,c,l)=>{const p=Kh[c.trim().toLowerCase()];return p?`${p}${l??""}`:u})),i}).join(", ")}function ia(t){if(!t)return null;const s=t.trim();if(!s)return null;const n=s.replace(/\D/g,"");return n.length===10?`(${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`:s}function Pn({raw:t,display:s,name:n}){if(!s||s.trim()==="")return e.jsx(xt,{value:null,name:n});const r=t&&t.trim()||s,a=`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(r.trim())}`;return e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"underline decoration-dotted underline-offset-2 transition-colors hover:text-foreground",children:s})}function ws({raw:t,name:s}){const n=ia(t);if(!n)return e.jsx(xt,{value:null,name:s});const r=(t??"").replace(/[^\d+]/g,"");return e.jsx("a",{href:`tel:${r}`,className:"underline decoration-dotted underline-offset-2 transition-colors hover:text-foreground",children:n})}function Cb(t,s){const n=o=>o.replace(/([\\;,:"])/g,"\\$1"),r=n(t),a=s?.trim();return a?`WIFI:T:WPA;S:${r};P:${n(a)};;`:`WIFI:T:nopass;S:${r};;`}function Sb({ssid:t,password:s}){const[n,r]=h.useState(!1),a=t?.trim(),o=s?.trim();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Wifi:"," ",a?e.
2jsx("button",{type:"button",onClick:()=>r(!0),className:"underline decoration-dotted underline-offset-2 transition-colors hover:text-foreground",title:"Show QR code to join",children:a}):e.jsx(xt,{value:null,name:"Wifi"}),o&&e.jsxs(e.Fragment,{children:[" ","· Password:"," ",a?e.jsx("button",{type:"button",onClick:()=>r(!0),className:"underline decoration-dotted underline-offset-2 transition-colors hover:text-foreground",title:"Show QR code to join",children:o}):o]})]}),a&&e.jsx(Ze,{open:n,onOpenChange:r,children:e.jsxs(Xe,{className:"sm:max-w-xs",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Join WiFi"}),e.jsx(at,{children:"Point your phone’s camera at the code to connect."})]}),e.jsxs("div",{className:"flex flex-col items-center gap-3 py-2",children:[e.jsx("div",{className:"rounded-md bg-white p-3",children:e.jsx(_h,{value:Cb(a,o),size:208,level:"M"})}),e.jsxs("div",{className:"text-center text-sm",children:[e.jsx("div",{className:"font-medium",children:a}),o&&e.jsx("div",{className:"text-muted-foreground",children:o})]})]})]})})]})}function Oe({label:t,value:s,required:n=!1}){const r=s==null||String(s).trim()==="";return e.jsxs("div",{className:"grid grid-cols-[96px_1fr] gap-2 text-sm",children:[e.jsx("dt",{className:"text-xs uppercase tracking-wide text-muted-foreground pt-0.5",children:t}),r?n?e.jsx("dd",{className:"justify-self-start rounded bg-amber-500/15 px-1.5 py-0.5 text-xs font-semibold text-amber-700 ring-1 ring-amber-500/30 dark:text-amber-400",children:"Missing"}):e.jsx("dd",{className:"text-muted-foreground",children:"—"}):e.jsx("dd",{className:"break-words",children:s})]})}const kb={confirmationCode:"",roomType:"",cost:""},Tb={method:"",airline:"",departCity:"",departTime:"",layover:"",arriveCity:"",arriveTime:"",number:"",res:""},Ab={company:"",confirmationCode:"",pickupLocation:"",pickupTime:"",dropoffDate:"",dropoffLocation:"",dropoffTime:"",carType:"",cost:""},qa={date:"",dateLabel:"",city:"",venue:"",venueAddress:"",venueCity:"",venuePhone:"",showTime:"",timeChange:"",doors:"",venueAvailable:"",dayOfContact:"",contactNumber:"",venueContactName:"",venueContactEmail:"",venueContactPhone:"",wifi:"",wifiPassword:"",gummies:!1,washerDryer:!1,food:!1,timesConfirmed:!1,hotel:"",hotelAddress:"",hotelPhone:"",hotelWebsiteUrl:"",rooms:[],travelLegs:[],carRentals:[]};function Ti(t){return t.travelLegs??[]}function Pb(t){return!!(t.method||t.airline||t.departCity||t.departTime||t.layover||t.arriveCity||t.arriveTime||t.number||t.res)}function Ai(t){return t.carRentals??[]}function Mb(t){return!!(t.company||t.confirmationCode||t.pickupLocation||t.pickupTime||t.dropoffDate||t.dropoffLocation||t.dropoffTime||t.carType||t.costCents!=null)}function Pr(t){return/train|rail|amtrak|eurostar|via\s*rail/i.test(`${t.method??""} ${t.airline??""}`)}function Hu({legs:t,dateYmd:s}){const[n,r]=h.useState(!1);if(t.length===0)return null;const a=t.every(Pr),o=t.some(Pr),i=a?Po:jp,u=t.map(c=>[c.departCity,c.arriveCity].map(l=>l?.trim()).filter(Boolean).join(" → ")).filter(Boolean).join(", ")||(t.length>1?`${t.length} legs`:a?"Train":"Flight");return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>r(c=>!c),"aria-expanded":n,title:n?"Hide flight / train details":"Show flight / train details",className:"inline-flex max-w-full items-center gap-1.5 rounded-full border bg-background px-2.5 py-1 text-xs font-semibold text-foreground transition-colors hover:bg-muted",children:[e.jsx(i,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),o&&!a&&e.jsx(Po,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:u}),e.jsx(It,{className:ht("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",n&&"rotate-180")})]}),n&&e.jsx("div",{className:"mt-3 grid gap-x-8 gap-y-5 lg:grid-cols-2",children:t.map((c,l)=>{const p=Pr(c)?"Train":"Flight";return e.jsxs(Js,{title:t.length>1?`${p} ${l+1}`:p,children:[e.jsx(Oe,{label:"Flight / Train",value:c.method}),e.jsx(Oe,{label:"Carrier",value:c.airline}),e.jsx(Oe,{label:"From",value:c.departCity}),e.jsx(Oe,{label:"Depart",value:Mt(c.departTime)}),e.jsx(Oe,{label:"Layover",value:c.layover}),e.jsx(Oe,{label:"To",value:c.arriveCity}),e.jsx(Oe,{label:"Arrive",value:Mt(c.arriveTime)}),e.jsx(Oe,{label:"Flight #",value:c.number}),e.jsx(Oe,{label:"Res #",value:c.res}),e.jsx("div",{className:"pt-1",children:e.jsx(Qs,{event:Yh({isTrain:Pr(c),airline:c.airline,departCity:c.departCity,departTime:c.departTime,layover:c.layover,arriveCity:c.arriveCity,arriveTime:c.arriveTime,number:c.number,res:c.res,dateYmd:s}),label:`Add ${p.toLowerCase()} to calendar`,filename:`${p.toLowerCase()}-${c.number??c.departCity??"travel"}`,iconOnly:!0,className:"h-8 w-8"})})]},l)})})]})}function Wu({rentals:t,dateYmd:s}){const[n,r]=h.useState(!1);if(t.length===0)return null;const o=t.map(i=>
2(i.company??i.carType??"").trim()).filter(Boolean).join(", ")||(t.length>1?`${t.length} rentals`:"Rental car");return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>r(i=>!i),"aria-expanded":n,title:n?"Hide rental car details":"Show rental car details",className:"inline-flex max-w-full items-center gap-1.5 rounded-full border bg-background px-2.5 py-1 text-xs font-semibold text-foreground transition-colors hover:bg-muted",children:[e.jsx(up,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:o}),e.jsx(It,{className:ht("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",n&&"rotate-180")})]}),n&&e.jsx("div",{className:"mt-3 grid gap-x-8 gap-y-5 lg:grid-cols-2",children:t.map((i,d)=>e.jsxs(Js,{title:t.length>1?`Rental car ${d+1}`:"Rental car",children:[e.jsx(Oe,{label:"Company",value:i.company}),e.jsx(Oe,{label:"Car",value:i.carType}),e.jsx(Oe,{label:"Pickup",value:i.pickupLocation}),e.jsx(Oe,{label:"Pickup time",value:Mt(i.pickupTime)}),e.jsx(Oe,{label:"Drop-off",value:i.dropoffLocation}),e.jsx(Oe,{label:"Drop-off date",value:i.dropoffDate}),e.jsx(Oe,{label:"Drop-off time",value:Mt(i.dropoffTime)}),e.jsx(Oe,{label:"Res #",value:i.confirmationCode}),e.jsx(Oe,{label:"Cost",value:i.costCents!=null?Dt(i.costCents):null}),e.jsx("div",{className:"pt-1",children:e.jsx(Qs,{event:Qh({company:i.company,carType:i.carType,pickupLocation:i.pickupLocation,pickupTime:i.pickupTime,dropoffDate:i.dropoffDate,dropoffLocation:i.dropoffLocation,dropoffTime:i.dropoffTime,confirmationCode:i.confirmationCode,dateYmd:s}),label:"Add rental to calendar",filename:`rental-${i.company??"car"}`,iconOnly:!0,className:"h-8 w-8"})})]},d))})]})}function Db(t,s){const n=Math.floor(t/60),r=t%60;return n>0?r>0?`${n}h ${r}m`:`${n}h`:`${r}m`}function Ib(t,s){if(t==null)return null;const n=qy(t,s);return n==null?null:`~$${Math.round(n/100)} diesel`}function Eb(t){return t==null?"":t===0?"☀️ Clear":t<=2?"⛅ Partly cloudy":t===3?"☁️ Cloudy":t<=48?"🌫️ Fog":t<=57?"🌧️ Drizzle":t<=67?"🌧️ Rain":t<=77?"❄️ Snow":t<=82?"🌧️ Showers":t<=86?"🌨️ Snow showers":"⛈️ Storms"}function Rb(t){if(!t||t.status!=="ok")return null;const s=Eb(t.weatherCode??null),n=t.tempMaxF!=null&&t.tempMinF!=null?`${t.tempMaxF}°/${t.tempMinF}°`:t.tempMaxF!=null?`${t.tempMaxF}°`:"",r=t.precipChance!=null?`${t.precipChance}% rain`:"";return[[s,n].filter(Boolean).join(" "),r].filter(Boolean).join(" · ")||null}function Yu(){const t=nt(),{toast:s}=Ye(),n=Gh(),{data:r=[],isLoading:a}=Dm(),o=h.useMemo(()=>r.map(f=>({...f,shows:f.shows?.filter(S=>!S.isDigital)??[]})).filter(f=>!f.needsTravelPlans||f.shows.length>0),[r]),{data:i=[]}=Im(),{data:d=[]}=Em(),{data:u=[]}=Wr(),{data:c=[]}=Bn(),{data:l=[]}=Rm(),p=Lm(),[g,v]=h.useState(null),[w,A]=h.useState(""),[N,I]=h.useState("upcoming"),[C,y]=h.useState(!1),[T,L]=h.useState(!1),O=Fm(),[q,z]=h.useState(null),[x,j]=h.useState(qa),[E,W]=h.useState(null),[ie,R]=h.useState(!1),[re,H]=h.useState(!1),[oe,te]=h.useState(null),[ce,V]=h.useState(!1),[ue,$]=h.useState(null),[se,X]=h.useState(!1),[D,J]=h.useState(null),fe=async()=>{const f=x.hotel.trim();if(f===""){s({title:"Enter a hotel name first",variant:"destructive"});return}R(!0);try{const S=x.city.trim()?`${f}, ${x.city.trim()}`:f,k=await vh({q:S});if(!k.found){s({title:"No match found",description:"Try adding the city or a more specific name.",variant:"destructive"});return}const M=k.websiteUrl;j(K=>({...K,hotel:k.name??K.hotel,hotelAddress:k.address??K.hotelAddress,hotelPhone:k.phone??K.hotelPhone,hotelWebsiteUrl:K.hotelWebsiteUrl.trim()?K.hotelWebsiteUrl:M??K.hotelWebsiteUrl})),s({title:"Hotel details filled in"})}catch{s({title:"Lookup failed. Try again.",variant:"destructive"})}finally{R(!1)}},P=async()=>{H(!0),te("Looking up hotel phone numbers and websites...");let f=0,S=0,k=0;try{let M=null;for(let B=0;B<500;B++){const Y=await gh(M?{after:M}:void 0);if(f+=Y.filled,S+=Y.updatedRows,k=Y.remaining,te(`Filled ${S} days so far...`),Y.processed===0||Y.cursor==null)break;M=Y.cursor}
2t.invalidateQueries({queryKey:jr()}),te(null);const K=S>0?`Filled ${S} days (${f} hotels with phone numbers or websites)`:"No new hotel phone numbers or websites found";s({title:k>0?`${K}; ${k} still without a phone or website`:K})}catch{te(null),s({title:"Could not fill hotel phone numbers or websites. Try again.",variant:"destructive"})}finally{H(!1)}},Q=async()=>{V(!0),$("Looking up venue phone numbers...");let f=0,S=0,k=0;try{let M=null;for(let B=0;B<500;B++){const Y=await xh(M?{after:M}:void 0);if(f+=Y.filled,S+=Y.updatedRows,k=Y.remaining,$(`Filled ${S} days so far...`),Y.processed===0||Y.cursor==null)break;M=Y.cursor}t.invalidateQueries({queryKey:jr()}),$(null);const K=S>0?`Filled ${S} days (${f} venues)`:"No new phone numbers found";s({title:k>0?`${K}; ${k} still without a number`:K})}catch{$(null),s({title:"Could not fill venue phone numbers. Try again.",variant:"destructive"})}finally{V(!1)}},de=async()=>{X(!0),J("Calculating drive times...");try{const f=[...o].sort((B,Y)=>new Date(B.date).getTime()-new Date(Y.date).getTime()),S=new Set,k=[];for(let B=1;B<f.length;B++){const Y=f[B-1].hotelAddress?.trim(),me=f[B].hotelAddress?.trim();if(!Y||!me||Y===me)continue;const ge=`${Y}\0${me}`;S.has(ge)||cn.has(ge)||(S.add(ge),k.push({origin:Y,destination:me}))}if(k.length===0){J(null),s({title:"All drive times are already calculated"});return}let M=0;const K=15;for(let B=0;B<k.length;B+=K){const Y=await Co({pairs:k.slice(B,B+K)});M+=Y.computed,J(`Calculated ${M} of ${k.length} legs...`)}t.invalidateQueries({queryKey:ya()}),J(null),s({title:`Calculated ${M} drive legs`})}catch{J(null),s({title:"Could not calculate drive times. Try again.",variant:"destructive"})}finally{X(!1)}},ke=()=>t.invalidateQueries({queryKey:jr()}),Ut=async()=>{const f=t.getQueryData(jr());if(!f)return;const S=t.getQueryData(ya())??[],k=new Set(S.map(Y=>`${Y.origin}\0${Y.destination}`)),M=[...f].sort((Y,me)=>new Date(Y.date).getTime()-new Date(me.date).getTime()),K=new Set,B=[];for(let Y=1;Y<M.length;Y++){const me=M[Y-1].hotelAddress?.trim(),ge=M[Y].hotelAddress?.trim();if(!me||!ge||me===ge)continue;const Te=`${me}\0${ge}`;K.has(Te)||k.has(Te)||(K.add(Te),B.push({origin:me,destination:ge}))}if(B.length!==0)try{for(let me=0;me<B.length;me+=15)await Co({pairs:B.slice(me,me+15)});t.invalidateQueries({queryKey:ya()})}catch{}},lt=Vm({mutation:{onSuccess:async()=>{y(!1),s({title:"Day added"}),await ke(),Ut()},onError:()=>s({title:"Could not save day",variant:"destructive"})}}),Lt=$m({mutation:{onSuccess:async()=>{y(!1),s({title:"Day updated"}),await ke(),Ut()},onError:()=>s({title:"Could not save day",variant:"destructive"})}}),jt=Om({mutation:{onSuccess:()=>{ke(),W(null),s({title:"Day deleted"})},onError:()=>s({title:"Could not delete day",variant:"destructive"})}}),bt=lt.isPending||Lt.isPending,[_t,ct]=h.useState(!1),[_e,qt]=h.useState(""),Ae=h.useRef(null),Gt=Bm(),oa=()=>{qt(""),ct(!0)},[la,fs]=h.useState(!1),[ca,Ds]=h.useState(""),an=h.useRef(null),Is=Um(),da=()=>{Ds(""),fs(!0)},[ua,Es]=h.useState(!1),[Yt,Kt]=h.useState(""),Rs=h.useRef(null),Ls=_m(),cr=()=>{Kt(""),Es(!0)},ma=async f=>{const S=f.trim();if(S)try{const k=await Ls.mutateAsync({data:{emailText:S}}),M=k.costCents!=null?` · ${Dt(k.costCents)}`:"",K=k.sourceCurrency&&k.sourceCurrency!=="USD"?` · converted from ${k.sourceCurrency}`:"";s({title:k.skipped>0?`${k.company??"Rental"} already on file`:`Added ${k.company??"rental car"} to ${k.pickupDate}`,description:`${k.pickupDate}${k.dropoffDate?` → ${k.dropoffDate}`:""}${k.confirmationCode?` · ${k.confirmationCode}`:""}${M}${K}`}),await ke(),Kt(""),requestAnimationFrame(()=>Rs.current?.focus())}catch(k){const M=k instanceof Error&&k.message?k.message:"Could not read that confirmation.";s({title:"Import failed",description:M,variant:"destructive"})}},dr=async f=>{const S=f.trim();if(S)try{const k=await Is.mutateAsync({data:{emailText:S}}),M=k.created+k.updated,K=M===1?"day":"days",B=k.skipped>0?` · ${k.skipped} already on file`:"";s({title:`Added ${k.airline??"travel"} legs to ${M} ${K}`,description:`${k.dates.join(", ")}${k.confirmationCode?` · ${k.confirmationCode}`:""}${B}`}),await ke(),Ds(""),requestAnimationFrame(()=>an.current?.focus())}catch(k){const M=k instanceof Error&&k.message?k.message:"Could not read that confirmation.";s({title:"Import failed",description:M,variant:"destructive"})}},Qt=async f=>{const S=f.trim();if(S)try{const k=await Gt.mutateAsync({data:{emailText:S}}),M=k.created+k.updated,K=k.nights===1?"night":"nights",B=k.perNightCostCents!=null?` · ${Dt(k.perNightCostCents)}/night`:"",Y=k.sourceCurrency&&k.sourceCurrency!=="USD"?` · converted from ${k.sourceCurrency}`:"";s({title:`Added ${k.hotelName??"hotel"} to ${M} ${K}`,description:`${k.checkInDate??""}${k.checkOutDate?` → ${k.checkOutDate}`:""}${B}${Y}`}),await ke(),Ut(),qt(""),requestAnimationFrame(()=>Ae.current?.focus())}catch(k){const M=k instanceof Error&&k.message?k.message:"Could not read that confirmation.";s({title:"Import failed",description:M,variant:"destructive"})}},Ke=()=>{z(null),j({...qa,date:Gu()}),y(!0)},gs=f=>{const S=f.shows?.[0]??null,k=S?An(S.date):"";z(null),j({...qa,date:f.date.slice(0,10),city:S?.city??f.city??"",venue:S?.venue??f.venue??"",showTime:k,doors:k?bs(k,-60)??"":"",venueAvailable:k?bs(k,-120)??"":""}),y(!0)},on=f=>{z(f.id),j({date:f.date.slice(0,10),dateLabel:f.dateLabel??"",city:f.city??"",venue:f.venue??"",venueAddress:f.venueAddress??"",venueCity:f.venueCity??"",venuePhone:f.venuePhone??"",showTime:f.showTime??"",timeChange:f.timeChange??"",doors:f.doors?.trim()?f.doors:Ks(f.showTime,f.timesConfirmed,-60),venueAvailable:f.venueAvailable?.trim()?f.venueAvailable:Ks(f.showTime,f.timesConfirmed,-120),dayOfContact:f.dayOfContact??"",contactNumber:f.contactNumber??"",venueContactName:f.venueContactName??"",venueContactEmail:f.venueContactEmail??"",venueContactPhone:f.venueContactPhone??"",wifi:f.wifi??"",wifiPassword:f.wifiPassword??"",gummies:f.gummies??!1,washerDryer:f.washerDryer??!1,food:f.food??!1,timesConfirmed:f.timesConfirmed??!1,hotel:f.hotel??"",hotelAddress:f.hotelAddress??"",hotelPhone:f.hotelPhone??"",hotelWebsiteUrl:f.hotelWebsiteUrl??"",rooms:ab(f),carRentals:Ai(f).map(S=>({company:S.company??"",confirmationCode:S.confirmationCode??"",pickupLocation:S.pickupLocation??"",pickupTime:S.pickupTime??"",dropoffDate:S.dropoffDate??"",dropoffLocation:S.dropoffLocation??"",dropoffTime:S.dropoffTime??"",carType:S.carType??"",cost:S.costCents!=null?(S.costCents/100).toFixed(2):""})),travelLegs:Ti(f).map(S=>({method:S.method??"",airline:S.airline??"",departCity:S.departCity??"",departTime:S.departTime??"",layover:S.layover??"",arriveCity:S.arriveCity??"",arriveTime:S.arriveTime??"",number:S.number??"",res:S.res??""}))}),y(!0)},ln=()=>
2{if(!x.date){s({title:"Date is required",variant:"destructive"});return}const f=B=>B.trim()===""?null:B.trim(),S=x.travelLegs.map(B=>({method:f(B.method),airline:f(B.airline),departCity:f(B.departCity),departTime:f(B.departTime),layover:f(B.layover),arriveCity:f(B.arriveCity),arriveTime:f(B.arriveTime),number:f(B.number),res:f(B.res)})).filter(Pb),k=[];for(const B of x.rooms){const Y=f(B.confirmationCode),me=f(B.roomType),ge=B.cost.trim();let Te=null;if(ge!==""){const kt=Number(ge.replace(/[$,]/g,""));if(!Number.isFinite(kt)||kt<0){s({title:"Room cost must be a positive dollar amount",variant:"destructive"});return}Te=Math.round(kt*100)}k.push({confirmationCode:Y,roomType:me,costCents:Te})}const M=[];for(const B of x.carRentals){const Y=B.cost.trim();let me=null;if(Y!==""){const Te=Number(Y.replace(/[$,\s]/g,""));if(!Number.isFinite(Te)||Te<0){s({title:"Rental cost must be a positive dollar amount",variant:"destructive"});return}me=Math.round(Te*100)}const ge={company:f(B.company),confirmationCode:f(B.confirmationCode),pickupLocation:f(B.pickupLocation),pickupTime:f(B.pickupTime),dropoffDate:f(B.dropoffDate),dropoffLocation:f(B.dropoffLocation),dropoffTime:f(B.dropoffTime),carType:f(B.carType),costCents:me};Mb(ge)&&M.push(ge)}const K={date:x.date,dateLabel:f(x.dateLabel),city:f(x.city),venue:f(x.venue),venueAddress:f(x.venueAddress),venueCity:f(x.venueCity),venuePhone:f(x.venuePhone),showTime:f(x.showTime),timeChange:f(x.timeChange),hotel:f(x.hotel),hotelAddress:f(x.hotelAddress),hotelPhone:f
2(x.hotelPhone),hotelWebsiteUrl:f(x.hotelWebsiteUrl),hotelRooms:k,venueAvailable:f(x.venueAvailable),doors:f(x.doors),dayOfContact:f(x.dayOfContact),contactNumber:f(x.contactNumber),venueContactName:f(x.venueContactName),venueContactEmail:f(x.venueContactEmail),venueContactPhone:f(x.venueContactPhone),wifi:f(x.wifi),wifiPassword:f(x.wifiPassword),gummies:x.gummies,washerDryer:x.washerDryer,food:x.food,timesConfirmed:x.timesConfirmed,travelLegs:S,carRentals:M};q!=null?Lt.mutate({id:q,data:K}):lt.mutate({data:K})},wt=h.useMemo(()=>{const f=new Date;return f.setHours(0,0,0,0),f.setDate(f.getDate()-1),f.getTime()},[]),Nt=h.useMemo(()=>Gy(o),[o]),ha=h.useMemo(()=>{const f=new Map;for(const S of Nt)f.set(S.date.slice(0,10),S.id);return f},[Nt]),pa=h.useMemo(()=>{const f=K=>K?.trim()||null,S=K=>br(K.hotelAddress)||br(K.venueAddress)||f(K.city),k=Nt,M=new Map;for(let K=0;K<k.length;K++){const B=S(k[K]),Y=K>0?k[K-1]:null,me=Y?S(Y):null,ge=Y?Ua(Y.date,k[K].date):!1;M.set(k[K].id,me&&B&&me!==B&&ge?`${me} → ${B}`:null)}return M},[o]),cn=h.useMemo(()=>{const f=new Map;for(const S of i)f.set(`${S.origin}\0${S.destination}`,{minutes:S.minutes,miles:S.miles});return f},[i]),dn=h.useMemo(()=>{const f=Nt,S=new Map;for(let k=1;k<f.length;k++){if(!Ua(f[k-1].date,f[k].date))continue;const M=f[k-1].hotelAddress?.trim()||null,K=f[k].hotelAddress?.trim()||null;if(!M||!K||M===K)continue;const B=cn.get(`${M}\0${K}`);B&&B.minutes!=null&&S.set(f[k].id,{minutes:B.minutes,miles:B.miles})}return S},[Nt,cn]),Zt=f=>{const S=f.shows?.[0];return f.hotelAddress?.trim()||br(f.venueAddress)||f.city?.trim()||S&&[S.city,S.regionLabel].filter(Boolean).join(", ")||null||null},Xt=h.useMemo(()=>{const f=new Map;for(const S of d)f.set(`${S.locationKey}\0${S.date}`,S);return f},[d]),xs=h.useMemo(()=>{const f=new Map;for(const S of Nt){const k=Zt(S);k&&f.set(S.date.slice(0,10),k)}return f},[Nt]),un=h.useMemo(()=>{const f=new Date(new Date().toISOString().slice(0,10)).getTime(),S=1440*60*1e3,k=[],M=new Set;for(const[K,B]of xs){const Y=Math.round((new Date(K).getTime()-f)/S);if(Y<-7||Y>15)continue;const me=`${B}\0${K}`;M.has(me)||(M.add(me),k.push({locationKey:B,date:K}))}return k},[xs]),vs=h.useRef(!1),ur=h.useRef(new Map);h.useEffect(()=>{if(un.length===0||vs.current)return;const f=360*60*1e3,S=Date.now(),k=un.filter(M=>{const K=`${M.locationKey}\0${M.date}`,B=ur.current.get(K);if(B!=null&&S-B<f)return!1;const Y=Xt.get(K);return Y?S-new Date(Y.updatedAt).getTime()>f:!0});if(k.length!==0){for(const M of k)ur.current.set(`${M.locationKey}\0${M.date}`,S);vs.current=!0,(async()=>{try{for(let K=0;K<k.length;K+=25)await qm({items:k.slice(K,K+25)});t.invalidateQueries({queryKey:Gm()})}catch{}finally{vs.current=!1}})()}},[un,Xt,t]);const Ct=h.useMemo(()=>{const f=M=>{const K=M.shows?.[0],B=br(M.hotelAddress),[Y,me]=B?B.includes(",")?[B.slice(0,B.lastIndexOf(",")).trim(),B.slice(B.lastIndexOf(",")+1).trim()]:[null,B.trim()]:[null,null],ge=K?.region||me,Te=K?.city||Y;return Wh(Te,ge)},S=Nt,k=new Map;for(let M=0;M<S.length;M++){const K=S[M],B=M>0?S[M-1]:null,Y=f(K),me=B?Ua(B.date,K.date):!1,ge=B&&me?f(B):null,Te=!!Y&&!!ge;
2k.set(K.id,{computable:Te,note:Te?Hh(ge,Y,new Date(K.date)):null})}return k},[o]),Fs=h.useMemo(()=>{const f=w.trim().toLowerCase();return o.filter(S=>{const k=new Date(S.date).getTime();return N==="upcoming"&&k<wt||N==="past"&&k>=wt?!1:f?[S.city,S.venue,S.hotel,S.hotelAddress,S.dateLabel].filter(Boolean).some(M=>M.toLowerCase().includes(f)):!0}).sort((S,k)=>{const M=new Date(S.date).getTime(),K=new Date(k.date).getTime();return N==="past"?K-M:M-K})},[o,w,N,wt]),Jt=h.useMemo(()=>{const f=[];for(const S of Fs){const k=S.date.slice(0,10),M=f[f.length-1];M&&M.date===k?M.rows.push(S):f.push({date:k,rows:[S]})}return f},[Fs]),ze=h.useMemo(()=>{const f=(k,M)=>`${k.trim().toLowerCase()}\0${M.trim().toLowerCase()}`,S=new Map;for(const k of o){const M=k.venue?.trim(),K=k.venuePhone?.trim();if(!M||!K)continue;const B=f(M,k.city??"");S.has(B)||S.set(B,K)}return S},[o]),es=h.useMemo(()=>new Map(u.map(f=>[f.id,f])),[u]),dt=h.useMemo(()=>{const f=new Map(c.map(M=>[M.id,M])),S={tour_manager:0,support:1,guest:2},k=new Map;for(const M of u){const K=new Map((M.lineup??[]).map(Y=>[Y.supportActId,Y.effectiveRole])),B=(M.supportActs??[]).map(Y=>{const me=f.get(Y.id);if(!me)return null;const ge=K.get(Y.id)??(me.category==="tour_manager"?"tour_manager":me.category==="support"?"support":"guest");return{act:me,effectiveRole:ge}}).filter(Y=>!!Y);B.length!==0&&(B.sort((Y,me)=>{const ge=S[Y.effectiveRole]??2,Te=S[me.effectiveRole]??2;return ge-Te||Ue(Y.act).localeCompare(Ue(me.act))}),k.set(M.id,B))}return k},[u,c]),mn=h.useMemo(()=>{const f=new Map;for(const S of l)f.set(`${S.showId}:${S.supportActId}`,S);return f},[l]),St=async(f,S)=>{const k=`${f}:${S}`;v(k);try{await p.mutateAsync({showId:f,actId:S}),await t.invalidateQueries({queryKey:Eh()}),s({title:"Confirmation email sent"})}catch(M){s({title:"Could not send confirmation",description:M instanceof Error?M.message:void 0,variant:"destructive"})}finally{v(null)}},Vs=f=>{if(f.length===0)return null;const S=[{key:"tour_manager",label:"Tour Manager"},{key:"support",label:"Support Act"},{key:"guest",label:"Guest"}];return e.jsx("div",{className:"space-y-2 border-t pt-2",children:S.map(({key:k,label:M})=>{const K=f.filter(({effectiveRole:B})=>(B||"guest")===k);return K.length===0?null:e.jsx("div",{className:"space-y-2",children:K.map(({showId:B,act:Y})=>{const me=`${B}:${Y.id}`,ge=mn.get(me),Te=g===me,kt=!!Y.email?.trim();return e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold text-muted-foreground",children:[M,":"]})," ",e.jsx("span",{className:"font-medium",children:Ue(Y)}),Y.email?.trim()&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","·"," ",e.jsx("a",{href:`mailto:${Y.email}`,className:"hover:underline",children:Y.email})]}),Y.cell?.trim()&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· ",e.jsx(ws,{raw:Y.cell})]})]}),Y.category==="local_guest"&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[!ge?.confirmedAt&&e.jsxs(F,{variant:"outline",size:"sm",className:"h-7",disabled:Te||!kt,onClick:()=>St(B,Y.id),children:[Te?e.jsx(le,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(Ka,{className:"h-3.5 w-3.5 mr-1"}),ge?.confirmationSentAt?"Resend confirmation":"Send confirmation"]}),ge?.confirmedAt?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-600",children:[e.jsx(ep,{className:"h-3.5 w-3.5"}),"Confirmed"," ",Ba(ge.confirmedAt)]}):ge?.confirmationSentAt?Xj(ge.confirmationSentAt)?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-red-100 px-2 py-0.5 text-xs font-semibold text-red-700 ring-1 ring-red-300 dark:bg-red-950 dark:text-red-300 dark:ring-red-800",children:[e.jsx(tp,{className:"h-3.5 w-3.5"}),"No reply in 48h+ — sent"," ",Ba(ge.confirmationSentAt)]}):e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Sent"," ",Ba(ge.confirmationSentAt)," ","· awaiting confirmation"]}):kt?null:e.jsx("span",{className:"text-xs text-muted-foreground",children:"No email on file"})]})]},me)})},k)})})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(yc,{open:T,onOpenChange:L,days:O.data??[],isLoading:O.isLoading,isError:O.
2isError}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Itinerary"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(oe||ue||D)&&e.jsx("span",{className:"text-sm text-muted-foreground",children:oe??ue??D}),e.jsxs(F,{variant:"outline",onClick:()=>L(!0),children:[e.jsx(tn,{className:"mr-1 h-4 w-4"}),"Next 14 days"]}),e.jsxs(F,{variant:"outline",onClick:P,disabled:re,children:[re?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Hs,{className:"h-4 w-4 mr-1"}),"Fill hotel phones & websites"]}),e.jsxs(F,{variant:"outline",onClick:Q,disabled:ce,children:[ce?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Hs,{className:"h-4 w-4 mr-1"}),"Fill venue phones"]}),e.jsxs(F,{variant:"outline",onClick:de,disabled:se,children:[se?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Hs,{className:"h-4 w-4 mr-1"}),"Calculate drive times"]}),e.jsxs(Ya,{children:[e.jsx(Qa,{asChild:!0,children:e.jsxs(F,{variant:"outline",children:[e.jsx(gt,{className:"h-4 w-4 mr-1"})," Import",e.jsx(It,{className:"h-4 w-4 ml-1"})]})}),e.jsxs(Za,{align:"end",children:[e.jsx(yn,{onSelect:oa,children:"Hotel confirmation"}),e.jsx(yn,{onSelect:da,children:"Flight confirmation"}),e.jsx(yn,{onSelect:cr,children:"Car rental confirmation"})]})]}),e.jsxs(F,{onClick:Ke,children:[e.jsx(gt,{className:"h-4 w-4 mr-1"})," Add day"]})]})]}),e.jsx($i,{quote:n.data,isError:n.isError,isLoading:n.isLoading}),e.jsx(Ze,{open:_t,onOpenChange:ct,children:e.jsxs(Xe,{className:"max-w-2xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Import hotel confirmation"}),e.jsx(at,{children:"Paste a hotel confirmation email (Marriott, Hilton, etc.). It's read automatically the moment you paste — the hotel, dates, confirmation code, and cost (including the dollar value of any points) land on the itinerary. Multi-night stays are split across every night. Then the box clears for the next one."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Pt,{ref:Ae,rows:8,autoFocus:!0,disabled:Gt.isPending,placeholder:"Paste the full confirmation email here...",value:_e,onChange:f=>qt(f.target.value),onPaste:f=>{const S=f.clipboardData.getData("text");S.trim()&&!Gt.isPending&&(f.preventDefault(),qt(S),Qt(S))}}),Gt.isPending?e.jsxs("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"}),"Reading confirmation and updating the itinerary…"]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: just paste (⌘V / Ctrl+V) — no button to click. CAD, GBP, EUR, NZD & AUD are auto-converted to USD."})]}),e.jsx(ut,{children:e.jsx(F,{variant:"outline",onClick:()=>ct(!1),children:"Done"})})]})}),e.jsx(Ze,{open:la,onOpenChange:fs,children:e.jsxs(Xe,{className:"max-w-2xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Import flight confirmation"}),e.jsx(at,{children:"Paste an airline or train confirmation email. It's read automatically the moment you paste — each travel day lands as a leg on that day's itinerary (created if missing), with the airline, flight numbers, cities, times, and confirmation code. Then the box clears for the next one."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Pt,{ref:an,rows:8,autoFocus:!0,disabled:Is.isPending,placeholder:"Paste the full confirmation email here...",value:ca,onChange:f=>Ds(f.target.value),onPaste:f=>{const S=f.clipboardData.getData("text");S.trim()&&!Is.isPending&&(f.preventDefault(),Ds(S),dr(S))}}),Is.isPending?e.jsxs("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"}),"Reading confirmation and updating the itinerary…"]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: just paste (⌘V / Ctrl+V) — no button to click. Round trips land on both travel days; pasting the same confirmation twice won't double anything."})]}),e.jsx(ut,{children:e.jsx(F,{variant:"outline",onClick:()=>fs(!1),children:"Done"})})]})}),e.jsx(Ze,{open:ua,onOpenChange:Es,children:e.jsxs(Xe,{className:"max-w-2xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Import car rental confirmation"}),e.jsx(at,{children:"Paste a rental car confirmation email (Hertz, Enterprise, etc.). It's read automatically the moment you paste — the company, car, pickup and drop-off details, confirmation number, and total cost land on the pickup day's itinerary (created if missing). Then the box clears for the next one."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Pt,{ref:Rs,rows:8,autoFocus:!0,disabled:Ls.isPending,placeholder:"Paste the full confirmation email here...",value:Yt,onChange:f=>Kt(f.target.value),onPaste:f=>{const S=f.clipboardData.getData("text");S.trim()&&!Ls.isPending&&(f.preventDefault(),Kt(S),ma(S))}}),Ls.isPending?e.jsxs("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"}),"Reading confirmation and updating the itinerary…"]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: just paste (⌘V / Ctrl+V) — no button to click. CAD, GBP, EUR, NZD & AUD are auto-converted to USD; pasting the same confirmation twice won't double anything."})]}),e.jsx(ut,{children:e.jsx(F,{variant:"outline",onClick:()=>Es(!1),children:"Done"})})]})}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border bg-card p-3 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(Ms,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ne,{placeholder:"Search city, venue, or hotel...",className:"pl-9",value:w,onChange:f=>A(f.target.value)})]}),e.jsxs("select",{"aria-label":"Filter by time",className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:N,onChange:f=>I(f.target.value),children:[e.jsx("option",{value:"upcoming",children:"Upcoming"}),e.jsx("option",{value:"past",children:"Past"}),e.jsx("option",{value:"all",children:"All days"})]})]}),a?e.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 mr-2 animate-spin"})," Loading itinerary..."]}):o.length===0?e.jsx("div",{className:"rounded-lg border border-dashed bg-card p-10 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:'No itinerary days yet. Click "Add day" to create the first one.'})}):Fs.length===0?e.jsx("div",{className:"rounded-lg border border-dashed bg-card p-10 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No days match your filters."})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"space-y-3",children:Jt.map(f=>{const S=f.rows,k=S.length>1,M=ha.get(f.date)??S[0].id,K=S.find(ee=>ee.id===M)??S[0],B=pa.get(M)??null,Y=dn.get(M)??null,me=xs.get(f.date)??null,ge=me?Xt.get(`${me}\0${f.date}`):void 0,Te=Ct.get(M),kt=Te?.computable?Te.note:K.timeChange?.trim()||null,[mr,hr,pr]=f.date.split("-"),fr=mr&&hr&&pr?`${Number(hr)}/${Number(pr)}/${mr.slice(2)}`:K.dateLabel;if(S.length===1&&S[0].needsTravelPlans){const ee=S[0],pe=ee.shows?.[0]??null,Re=pe?Mt(An(pe.date)):null,We=zs(pe?.address),Ne=pe?.venuePhone??ze.get(`${(pe?.venue??"").trim().toLowerCase()}\0${(pe?.city??"").trim().toLowerCase()}`)??null;return e.jsx("div",{className:"rounded-lg border border-amber-400 bg-amber-50",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-lg font-bold leading-tight",children:fr}),pe&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[pe.city,", ",pe.regionLabel]}),e.jsx("p",{className:"mt-1 text-sm font-semibold",children:pe?pe.venue:"Show"}),e.jsxs("div",{className:"mt-0.5 space-y-0.5 text-sm text-muted-foreground",children:[e.jsx("p",{children:e.jsx(xt,{value:Re,name:"Start time"})}),e.jsxs("p",{children:[e.jsx(Pn,{raw:pe?.address,display:We,name:"Address"})," · ",e.jsx(ws,{raw:Ne,name:"Phone"})]})]}),e.jsx("p",{className:"mt-2 inline-block rounded bg-amber-200 px-2 py-0.5 text-xs font-bold uppercase tracking-wide text-amber-900",children:"Needs travel plans"}),pe&&e.jsx("div",{className:"mt-3",children:Vs((dt.get(pe.id)??[]).map(m=>({showId:pe.id,act:m.act,effectiveRole:m.effectiveRole})))})]}),e.jsxs(F,{size:"sm",className:"shrink-0",onClick:()=>gs(ee),children:[e.jsx(gt,{className:"h-4 w-4 mr-1"})," Add travel plans"]})]})},f.date)}const Ee=S.find(ee=>!!ee.venue?.trim()||!!ee.venueAddress?.trim()||!!ee.showTime?.trim())??S.find(ee=>(ee.shows?.length??0)>0)??K,He=Ee.shows?.[0]??null,gr=(()=>
2{if(He){const We=He.address?.trim();if(!We)return{raw:null,display:null};const Ne=He.city?.trim(),m=Ne&&!We.toLowerCase().includes(Ne.toLowerCase())?`${We}, ${Ne}`:We;return{raw:m,display:zs(m)}}const ee=Ee.venueAddress?.trim(),pe=Ee.venueCity?.trim(),Re=ee?pe&&!ee.toLowerCase().includes(pe.toLowerCase())?`${ee}, ${pe}`:ee:pe||null;return{raw:Re,display:zs(Re)}})(),xr=S.some(ee=>(ee.shows?.length??0)>0||!!ee.venue?.trim()||!!ee.city?.trim()||!!ee.showTime?.trim()),ga=S.some(ee=>!!ee.hotel?.trim()),xa=!xr&&ga,vr=S.flatMap(Ti),va=vr.length>0,yr=S.flatMap(Ai);return e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b bg-muted/30 px-4 py-3",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5",children:[e.jsx("p",{className:"font-display text-lg font-bold leading-tight",children:fr}),(()=>{const ee=B??(Y?"Hotel → Hotel":null),pe=Y?Db(Y.minutes):null,Re=Y?Ib(Y.miles,n.data?.pricePerGallon??null):null,We=Rb(ge),Ne=[pe,Re,kt,We].filter(
2Boolean);return!ee&&Ne.length===0?null:e.jsxs("p",{className:"font-display text-base font-bold leading-tight",children:[ee,Ne.length>0&&e.jsxs("span",{className:"font-semibold text-muted-foreground",children:[ee?" · ":"",Ne.join(" · ")]})]})})()]})}),!k&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(F,{variant:"ghost",size:"icon","aria-label":"Edit day",onClick:()=>on(S[0]),children:e.jsx(En,{className:"h-4 w-4"})}),e.jsx(F,{variant:"ghost",size:"icon","aria-label":"Delete day",onClick:()=>W(S[0].id),children:e.jsx(ls,{className:"h-4 w-4 text-destructive"})})]})]}),e.jsxs("div",{className:"grid gap-x-8 gap-y-5 p-4 sm:grid-cols-2 lg:grid-cols-2",children:[e.jsx(Js,{children:xa?e.jsx("p",{className:"font-display text-base font-bold uppercase tracking-wide",children:"Day Off"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-0.5 text-sm",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(xt,{value:He?He.venue:Ee.venue,name:"Venue"})}),e.jsxs("p",{className:"text-muted-foreground",children:[e.jsx(Pn,{raw:gr.raw,display:gr.display,name:"Address"})," · ",e.jsx(ws,{raw:He?.venuePhone?.trim()||Ee.venuePhone,name:"Phone"})]})]}),(()=>{const ee=(Ee.showTime??(He?An(He.date):null))?.trim()||null,pe=Mt(Ee.venueAvailable?.trim()||Ks(ee,Ee.timesConfirmed,-120)||null),Re=Mt(Ee.doors?.trim()||Ks(ee,Ee.timesConfirmed,-60)||null),We=Mt(ee),Ne=[pe&&`${pe} Arrive`,Re&&`${Re} Doors`,We&&`${We} Show`].filter(Boolean);return e.jsxs("div",{className:"text-sm font-medium",children:[e.jsx(xt,{value:Ne.length?Ne.join(", "):null,name:"Schedule"}),Ne.length>0&&!Ee.timesConfirmed&&e.jsx("span",{className:"ml-1 text-xs font-normal text-amber-600 dark:text-amber-400",children:"(tentative)"})]})})(),He&&(()=>{const ee=es.get(He.id);if(!ee)return null;const pe=Ku(ee),Re=ee.eventbriteCapacity??ee.capacity,We=db(ee),Ne=Re!=null&&Re>0&&pe!=null?pe/Re:null,m=Ne==null?"":Ne<.5?"text-red-600":Ne>.7?"text-green-600":"",b=We?"We sell tix":ee.eventbriteOwnershipStatus==="third_party"?"Third-party seller":null;return e.jsxs("div",{className:"text-sm font-medium",children:[pe!=null||Re!=null?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-muted-foreground",children:["Sold:"," "]}),e.jsxs("span",{className:"tabular-nums",children:[pe??0,Re!=null?`/${Re}`:""]}),Ne!=null&&e.jsxs("span",{className:`ml-1 tabular-nums ${m}`,children:["(",Math.round(Ne*100),"%)"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"No sales yet"}),ee.meetGreet!=null&&ee.meetGreet>0&&e.jsxs("span",{className:"ml-2 tabular-nums",children:[e.jsxs("span",{className:"text-muted-foreground",children:["M&G:"," "]}),ee.meetGreet]}),b&&e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["· ",b]}),(()=>{const G=gc(ee.ticketsUpdatedAt);return G?e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["· Updated"," ",e.jsx("span",{className:`font-medium tabular-nums ${G.className}`,children:G.label})]}):null})()]})})(),He&&e.jsx(Qs,{event:bc(He),label:"Add show to calendar",filename:`steve-hofstetter-${He.city??"show"}`,iconOnly:!0,className:"mt-1 h-8 w-8"}),e.jsx("div",{className:"text-sm",children:(()=>{const ee=Ee.dayOfContact?.trim(),pe=ia(Ee.contactNumber);return!ee&&!pe?e.jsx(xt,{value:null,name:"Contact"}):e.jsxs(e.Fragment,{children:[ee,ee&&pe?" - ":"",pe&&e.jsx(ws,{raw:Ee.contactNumber})]})})()}),e.jsx(Sb,{ssid:Ee.wifi,password:Ee.wifiPassword}),e.jsx(yu,{gummies:Ee.gummies,food:Ee.food,washerDryer:Ee.washerDryer}),Vs((Ee.shows??[]).flatMap(ee=>(dt.get(ee.id)??[]).map(pe=>({showId:ee.id,act:pe.act,effectiveRole:pe.effectiveRole}))))]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Js,{title:k?"Hotels":void 0,children:S.map((ee,pe)=>e.jsxs("div",{className:pe>0?"border-t pt-3":"",children:[k&&e.jsxs("div",{className:"-mt-1 mb-1 flex items-center justify-end gap-1",children:[e.jsx(F,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Edit hotel",onClick:()=>on(ee),children:e.jsx(En,{className:"h-3.5 w-3.5"})}),e.jsx(F,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Delete hotel",onClick:()=>W(ee.id),children:e.jsx(ls,{className:"h-3.5 w-3.5 text-destructive"})})]}),e.jsxs("div",{className:"space-y-0.5 text-sm",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(xt,{value:ee.hotel,name:"Hotel"})}),Ws(ee)&&e.jsx("p",{className:"text-muted-foreground",children:Ws(ee)}),e.jsx("p",{className:"text-muted-foreground",children:e.jsx(Pn,{raw:ee.hotelAddress,display:zs(ee.hotelAddress),name:"Address"})}),e.jsx("p",{className:"text-muted-foreground",children:e.jsx(ws,{raw:ee.hotelPhone,name:"Phone"})}),(()=>{const Re=qu(ee),Ne=Re.filter(m=>m.confirmationCode?.trim()||m.costCents!=null).length>1;return e.jsxs(e.Fragment,{children:[Re.map((m,b)=>m.confirmationCode?.trim()||m.costCents!=null?e.jsxs("div",{className:"text-muted-foreground",children:[Ne&&e.jsxs("span",{className:"font-medium text-foreground",children:["Room ",b+1,m.roomType?.trim()?` · ${m.roomType}`:"",":"," "]}),m.confirmationCode?.trim()&&e.jsxs("span",{children:["Confirmation:"," ",e.jsx("span",{className:"font-medium text-foreground",children:m.confirmationCode})]}),m.confirmationCode?.trim()&&m.costCents!=null&&" · ",m.costCents!=null&&e.jsxs("span",{children:["Cost:"," ",e.jsx("span",{className:"font-medium text-foreground",children:Dt(m.costCents)})]})]},b):null),Ne&&ee.hotelCostCents!=null&&e.jsxs("p",{className:"text-muted-foreground",children:["Total:"," ",e.jsx("span",{className:"font-medium text-foreground",children:Dt(ee.hotelCostCents)})]})]})})(),ee.hotel?.trim()&&e.jsx("div",{className:"pt-1",children:e.jsx(Qs,{event:wc({hotel:ee.hotel,hotelAddress:ee.hotelAddress,hotelPhone:ee.hotelPhone,confirmationCode:ee.hotelConfirmationCode,rooms:Ws(ee),dateYmd:f.date}),label:"Add hotel to calendar",filename:`hotel-${ee.hotel??"stay"}`,iconOnly:!0,className:"h-8 w-8"})})]})]},ee.id))}),va&&e.jsx(Hu,{legs:vr,dateYmd:f.date}),e.jsx(Wu,{rentals:yr,dateYmd:f.date})]})]})]},f.date)})})}),e.jsx(Ze,{open:C,onOpenChange:y,children:e.jsxs(Xe,{className:"max-h-[90vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:q!=null?"Edit day":"Add day"}),e.jsx(at,{children:"One row per day. Leave a field blank if it doesn't apply."})]}),e.jsxs("div",{className:"grid gap-5 py-2",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"itin-date",children:"Date"}),e.jsx(ne,{id:"itin-date",type:"date",value:x.date,onChange:f=>j({...x,date:f.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"itin-dateLabel",children:"Date label (optional)"}),e.jsx(ne,{id:"itin-dateLabel",placeholder:"Auto-generated from date if blank",value:x.dateLabel,onChange:f=>j({...x,dateLabel:f.target.value})})]})]}),e.jsxs(Ga,{title:"Show",children:[e.jsx(xe,{label:"Venue (name)",value:x.venue,onChange:f=>j({...x,venue:f})}),e.jsx(xe,{label:"Venue Address",value:x.venueAddress,onChange:f=>j({...x,venueAddress:f})}
2),e.jsx(xe,{label:"Venue City",value:x.venueCity,onChange:f=>j({...x,venueCity:f})}),e.jsx(xe,{label:"Venue Phone",value:x.venuePhone,onChange:f=>j({...x,venuePhone:f})}),e.jsxs("div",{className:"col-span-full grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsx(xe,{label:"Venue Contact Name",value:x.venueContactName,onChange:f=>j({...x,venueContactName:f})}),e.jsx(xe,{label:"Venue Contact Email",value:x.venueContactEmail,onChange:f=>j({...x,venueContactEmail:f})}),e.jsx(xe,{label:"Venue Contact Phone",value:x.venueContactPhone,onChange:f=>j({...x,venueContactPhone:f})})]}),e.jsxs("div",{className:"col-span-full grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsx(xe,{label:"Show Time",value:x.showTime,onChange:f=>j(S=>{const k={...S,showTime:f};return S.timesConfirmed||(k.doors=bs(f,-60)??"",k.venueAvailable=bs(f,-120)??""),k})}),e.jsx(xe,{label:"Doors",value:x.doors,onChange:f=>j({...x,doors:f})}),e.jsx(xe,{label:"Venue Available",value:x.venueAvailable,onChange:f=>j({...x,venueAvailable:f})})]}),e.jsxs("div",{className:"col-span-full grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(xe,{label:"Day-of Contact",value:x.dayOfContact,onChange:f=>j({...x,dayOfContact:f})}),e.jsx(xe,{label:"Contact Number",value:x.contactNumber,onChange:f=>j({...x,contactNumber:f})})]}),e.jsxs("div",{className:"col-span-full grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(xe,{label:"Wifi",value:x.wifi,onChange:f=>j({...x,wifi:f})}),e.jsx(xe,{label:"Wifi Password",value:x.wifiPassword,onChange:f=>j({...x,wifiPassword:f})})]}),e.jsxs("label",{className:"col-span-full flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4",checked:x.timesConfirmed,onChange:f=>j(S=>{const k=f.target.checked,M={...S,timesConfirmed:k};return!k&&S.showTime.trim()&&(M.doors=bs(S.showTime,-60)??"",M.venueAvailable=bs(S.showTime,-120)??""),M})}),"Show / doors / availability times confirmed"]}),e.jsxs("label",{className:"col-span-full flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4",checked:x.gummies,onChange:f=>j({...x,gummies:f.target.checked})}),"Gummies"]}),e.jsxs("label",{className:"col-span-full flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4",checked:x.washerDryer,onChange:f=>j({...x,washerDryer:f.target.checked})}),"Washer / Dryer"]}),e.jsxs("label",{className:"col-span-full flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4",checked:x.food,onChange:f=>j({...x,food:f.target.checked})}),"Food"]})]}),e.jsxs(Ga,{title:"Hotel",children:[e.jsx(xe,{label:"Hotel (name)",value:x.hotel,onChange:f=>j({...x,hotel:f})}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(F,{type:"button",variant:"outline",size:"sm",onClick:()=>j({...x,hotel:"Home",hotelAddress:"Pineville, NC",hotelPhone:"",hotelWebsiteUrl:""}),children:"Home"}),e.jsx(F,{type:"button",variant:"outline",size:"sm",onClick:fe,disabled:ie,children:ie?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Look up address, phone & website"})]}),e.jsx(xe,{label:"Hotel Address (full address)",value:x.hotelAddress,onChange:f=>j({...x,hotelAddress:f})}),e.jsx(xe,{label:"Hotel Phone",value:x.hotelPhone,onChange:f=>j({...x,hotelPhone:f})}),e.jsx(xe,{label:"Hotel Website",value:x.hotelWebsiteUrl,onChange:f=>j({...x,hotelWebsiteUrl:f}),type:"url"}),e.jsxs("div",{className:"col-span-full space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{children:"Rooms"}),x.rooms.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Total: ",ib(x.rooms)]})]}),x.rooms.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No rooms yet. Add one, or import a hotel confirmation to append a room automatically."}),x.rooms.map((f,S)=>{const k=M=>j({...x,rooms:x.rooms.map((K,B)=>B===S?{...K,...M}:K)});return e.jsxs("div",{className:"grid gap-3 rounded-lg border p-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center justify-between sm:col-span-2",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:["Room ",S+1]}),e.jsx(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-destructive hover:text-destructive",onClick:()=>j({...x,rooms:x.rooms.filter((M,K)=>K!==S)}),children:"Remove"})]}),e.jsx(xe,{label:"Confirmation #",value:f.confirmationCode,onChange:M=>k({confirmationCode:M})}
2),e.jsx(xe,{label:"Room type",value:f.roomType,onChange:M=>k({roomType:M})}),e.jsx(xe,{label:"Cost ($)",value:f.cost,onChange:M=>k({cost:M})})]},S)}),e.jsx(F,{type:"button",variant:"outline",size:"sm",onClick:()=>j({...x,rooms:[...x.rooms,{...kb}]}),children:"Add room"})]})]}),e.jsxs(Ga,{title:"Travel",children:[e.jsx("p",{className:"col-span-full text-xs text-muted-foreground",children:"Travel is calculated automatically from the city the night before to the city tonight. The city is parsed from the venue or hotel address."}),e.jsxs("div",{className:"col-span-full grid gap-4",children:[x.travelLegs.map((f,S)=>{const k=M=>j({...x,travelLegs:x.travelLegs.map((K,B)=>B===S?{...K,...M}:K)});return e.jsxs("div",{className:"grid gap-4 rounded-lg border bg-background p-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"col-span-full flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:x.travelLegs.length>1?`Flight / Train ${S+1}`:"Flight / Train"}),e.jsx(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-destructive hover:text-destructive",onClick:()=>j({...x,travelLegs:x.travelLegs.filter((M,K)=>K!==S)}),children:"Remove"})]}),e.jsx(xe,{label:"Method",value:f.method,onChange:M=>k({method:M})}),e.jsx(xe,{label:"Carrier",value:f.airline,onChange:M=>k({airline:M})}),e.jsx(xe,{label:"Departing",value:f.departCity,onChange:M=>k({departCity:M})}),e.jsx(xe,{label:"Depart Time",value:f.departTime,onChange:M=>k({departTime:M})}),e.jsx(xe,{label:"Layover",value:f.layover,onChange:M=>k({layover:M})}),e.jsx(xe,{label:"Arrival",value:f.arriveCity,onChange:M=>k({arriveCity:M})}),e.jsx(xe,{label:"Arrive Time",value:f.arriveTime,onChange:M=>k({arriveTime:M})}),e.jsx(xe,{label:"Flight #",value:f.number,onChange:M=>k({number:M})}),e.jsx(xe,{label:"Reservation",value:f.res,onChange:M=>k({res:M})})]},S)}),e.jsxs(F,{type:"button",variant:"outline",size:"sm",className:"justify-self-start",onClick:()=>j({...x,travelLegs:[...x.travelLegs,{...Tb}]}),children:[e.jsx(gt,{className:"mr-1 h-4 w-4"}),"Add flight or train"]})]}),e.jsxs("div",{className:"col-span-full grid gap-4",children:[x.carRentals.map((f,S)=>{const k=M=>j({...x,carRentals:x.carRentals.map((K,B)=>B===S?{...K,...M}:K)});return e.jsxs("div",{className:"grid gap-4 rounded-lg border bg-background p-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"col-span-full flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:x.carRentals.length>1?`Rental car ${S+1}`:"Rental car"}),e.jsx(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-destructive hover:text-destructive",onClick:()=>j({...x,carRentals:x.carRentals.filter((M,K)=>K!==S)}),children:"Remove"})]}),e.jsx(xe,{label:"Company",value:f.company,onChange:M=>k({company:M})}),e.jsx(xe,{label:"Car",value:f.carType,onChange:M=>k({carType:M})}),e.jsx(xe,{label:"Pickup location",value:f.pickupLocation,onChange:M=>k({pickupLocation:M})}),e.jsx(xe,{label:"Pickup time",value:f.pickupTime,onChange:M=>k({pickupTime:M})}),e.jsx(xe,{label:"Drop-off location",value:f.dropoffLocation,onChange:M=>k({dropoffLocation:M})}),e.jsx(xe,{label:"Drop-off date (YYYY-MM-DD)",value:f.dropoffDate,onChange:M=>k({dropoffDate:M})}),e.jsx(xe,{label:"Drop-off time",value:f.dropoffTime,onChange:M=>k({dropoffTime:M})}),e.jsx(xe,{label:"Reservation",value:f.confirmationCode,onChange:M=>k({confirmationCode:M})}),e.jsx(xe,{label:"Total cost ($)",value:f.cost,onChange:M=>k({cost:M})})]},S)}),e.jsxs(F,{type:"button",variant:"outline",size:"sm",className:"justify-self-start",onClick:()=>j({...x,carRentals:[...x.carRentals,{...Ab}]}),children:[e.jsx(gt,{className:"mr-1 h-4 w-4"}),"Add rental car"]})]})]})]}),e.jsxs(ut,{children:[e.jsx(F,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(F,{onClick:ln,disabled:bt,children:bt?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})}),e.jsx(Un,{open:E!=null,onOpenChange:f=>!f&&W(null),children:e.jsxs(_n,{children:[e.jsxs(qn,{children:[e.jsx(Gn,{children:"Delete this day?"}),e.jsx(Kn,{children:"This permanently removes the itinerary day."})]}),e.jsxs(zn,{children:[e.jsx(Hn,{children:"Cancel"}),e.jsx(Wn,{onClick:()=>E!=null&&jt.mutate({id:E}),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function Ga({title:t,children:s}){return e.jsxs("div",{className:"grid gap-3 rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:s})]})}function xe({label:t,value:s,onChange:n,type:r="text"}){return e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{className:"text-xs text-muted-foreground",children:t}),e.jsx(ne,{type:r,value:s,onChange:a=>n(a.target.value)})]})}function Pi({act:t,size:s="md"}){const n=Bu(t.headshotUrl),r=s==="lg"?"h-20 w-20 text-xl":s==="sm"?"h-9 w-9 text-xs":"h-12 w-12 text-sm";return n?e.jsx("img",{src:n,alt:Ue(t),className:`${r} shrink-0 rounded-full border object-cover`}):e.jsx("div",{className:`${r} flex shrink-0 items-center justify-center rounded-full border bg-muted font-bold text-muted-foreground`,children:Jj(t)})}const Lb=[{key:"instagram",label:"Instagram",icon:Jh},{key:"facebook",label:"Facebook",icon:pp},{key:"tiktok",label:"TikTok",icon:Lh},{key:"youtube",label:"YouTube",icon:Xh},{key:"website",label:"Website",icon:ap}];function Fb(t){const s=t.trim();return!s||/^https?:\/\//i.test(s)?s:`https://${s}`}function Vb({act:t}){const s=Lb.map(n=>({...n,value:t[n.key]})).filter(n=>n.value&&n.value.trim()!=="");return s.length===0?null:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.map(({key:n,label:r,icon:a,value:o})=>e.jsx("a",{href:Fb(o),target:"_blank",rel:"noopener noreferrer","aria-label":r,className:"inline-flex h-8 w-8 items-center justify-center rounded-full border text-muted-foreground transition-colors hover:border-primary hover:text-primary",children:e.jsx(a,{className:"h-4 w-4"})},n))})}function Qu({value:t,fullNameForAlt:s,onChange:n}){const{toast:r}=Ye(),[a,o]=h.useState(null),{uploadFile:i,isUploading:d}=qh({basePath:`${lr}/api/storage`,onSuccess:l=>n(l.objectPath),onError:()=>r({title:"Could not upload photo",variant:"destructive"})}),u=h.useRef(null);h.useEffect(()=>()=>{a&&URL.revokeObjectURL(a)},[a]);const c=a??Bu(t);return e.jsxs("div",{className:"flex items-center gap-4",children:[c?e.jsx("img",{src:c,alt:s||"Headshot",className:"h-20 w-20 rounded-full border object-cover"}):e.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full border border-dashed bg-muted text-muted-foreground",children:e.jsx(Bi,{className:"h-7 w-7"})}),e.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:async l=>{const p=l.target.files?.[0];p&&(o(g=>(g&&URL.revokeObjectURL(g),URL.createObjectURL(p))),await i(p)),l.target.value=""}}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(F,{type:"button",variant:"outline",size:"sm",disabled:d,onClick:()=>u.current?.click(),children:[d?e.jsx(le,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{className:"h-4 w-4 mr-1"}),t?"Replace photo":"Upload photo"]}),t?e.jsx(F,{type:"button",variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:()=>{o(l=>(l&&URL.revokeObjectURL(l),null)),n("")},children:"Remove"}):null]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Square images look best. JPG or PNG."})]})]})}function be(t){const s=(t??"").trim();return s||null}const sc={firstName:"",lastName:"",email:"",cell:"",instagram:"",facebook:"",tiktok:"",youtube:"",website:"",bio:"",homeCity:"",homeState:"",homeCountry:"",legalName:"",venmoHandle:"",birthday:"",frequentFlyerPrograms:[],headshotUrl:"",category:"support"};function $b(t){const s=[],n=[];
2return t.split(/\r?\n/).forEach((a,o)=>{const i=a.trim();if(i==="")return;const d=i.split(/[\t,]/).map(g=>g.trim()),[u,c,l,p]=d;if(!u){n.push({line:o+1,raw:i,reason:"Needs at least a first name"});return}if(l&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l)){n.push({line:o+1,raw:i,reason:"Invalid email"});return}s.push({firstName:u,lastName:c??"",email:l?l.toLowerCase():null,cell:p&&p.length>0?p:null})}),{valid:s,errors:n}}function Ob(){const{data:t=[],isLoading:s,isError:n}=Ah(),{data:r}=Ri(),a=r?.role==="admin",o=nt(),{toast:i}=Ye(),[d,u]=h.useState(!0),[c,l]=h.useState(""),[p,g]=h.useState("createdAt"),[v,w]=h.useState("desc"),[A,N]=h.useState(new Set),[I,C]=h.useState(!1),y=()=>o.invalidateQueries({queryKey:Uh()}),T=Ph({mutation:{onSuccess:()=>y(),onError:()=>i({title:"Couldn't delete the request",variant:"destructive"})}}),L=Mh({mutation:{onSuccess:H=>{N(new Set),C(!1),y(),i({title:`Deleted ${H.deleted} request${H.deleted===1?"":"s"}`})},onError:()=>i({title:"Couldn't delete the selected requests",variant:"destructive"})}}),O=h.useMemo(()=>t.filter(H=>H.confirmed).length,[t]),q=h.useMemo(()=>{const H=c.trim().toLowerCase(),oe=t.filter(V=>V.confirmed!==d?!1:H?[V.name,V.email,V.phone,V.city,V.requestedAct].some(ue=>ue.toLowerCase().includes(H)):!0),te=v==="asc"?1:-1,ce=p;return[...oe].sort((V,ue)=>{const $=V[ce].toLowerCase(),se=ue[ce].toLowerCase();return $<se?-1*te:$>se?1*te:(V.id-ue.id)*te})},[t,d,c,p,v]),z=h.useMemo(()=>q.filter(H=>A.has(H.id)).map(H=>H.id),[q,A]),x=q.length>0&&z.length===q.length,j=H=>{H===p?w(oe=>oe==="asc"?"desc":"asc"):(g(H),w(H==="createdAt"?"desc":"asc"))},E=(H,oe)=>{N(te=>{const ce=new Set(te);return oe?ce.add(H):ce.delete(H),ce})},W=H=>{N(oe=>{const te=new Set(oe);for(const ce of q)H?te.add(ce.id):te.delete(ce.id);return te})},ie=(H,oe)=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>j(oe),children:[H,p===oe?v==="asc"?e.jsx(Oi,{className:"h-3.5 w-3.5"}):e.jsx(It,{className:"h-3.5 w-3.5"}):null]}),R=H=>e.jsxs(he,{"data-state":A.has(H.id)?"selected":void 0,children:[a&&e.jsx(_,{className:"w-10",children:e.jsx(In,{checked:A.has(H.id),onCheckedChange:oe=>E(H.id,oe===!0),"aria-label":`Select request from ${H.name}`})}),e.jsx(_,{className:"whitespace-nowrap text-muted-foreground",children:_u(H.createdAt)}),e.jsx(_,{className:"font-medium",children:H.name}),e.jsx(_,{className:"text-muted-foreground",children:e.jsx("a",{href:`mailto:${H.email}`,className:"hover:text-foreground hover:underline",children:H.email})}),e.jsx(_,{className:"text-muted-foreground",children:ia(H.phone)??H.phone}),e.jsx(_,{children:H.city}),e.jsx(_,{children:H.requestedAct}),e.jsx(_,{className:"whitespace-nowrap",children:H.confirmed?e.jsx(it,{variant:"secondary",className:"bg-emerald-100 text-emerald-800 hover:bg-emerald-100",children:"Confirmed"}):e.jsx(it,{variant:"outline",className:"text-muted-foreground",children:"Unconfirmed"})}),a&&e.jsx(_,{className:"w-10 text-right",children:e.jsx(F,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:T.isPending,onClick:()=>T.mutate({id:H.id}),title:"Delete this request",children:e.jsx(ls,{className:"h-4 w-4 text-destructive"})})})]},H.id),re=7+(a?2:0);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-sm font-bold uppercase tracking-wide text-muted-foreground",children:"Support act requests"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Submitted from the contact page by fans and bookers. Requests count once the submitter clicks the confirmation link emailed to them."})]}),s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):n?e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-6 text-center text-sm text-destructive",children:"Couldn't load support act requests."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"inline-flex rounded-md border p-0.5",children:[e.jsxs(F,{type:"button",size:"sm",variant:d?"secondary":"ghost",className:"h-8",onClick:()=>u(!0),children:["Confirmed (",O,")"]}),e.jsxs(F,{type:"button",size:"sm",variant:d?"ghost":"secondary",className:"h-8",onClick:()=>u(!1),children:["Unconfirmed (",t.length-O,")"]})]}),e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[e.jsx(Ms,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ne,{value:c,onChange:H=>
2l(H.target.value),placeholder:"Search name, email, phone, city, act…",className:"h-9 pl-8"})]}),a&&z.length>0&&e.jsxs(F,{type:"button",size:"sm",variant:"destructive",className:"h-9",disabled:L.isPending,onClick:()=>C(!0),children:[e.jsx(ls,{className:"h-4 w-4 mr-1"}),"Delete ",z.length," selected"]})]}),e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[a&&e.jsx(U,{className:"w-10",children:e.jsx(In,{checked:x,onCheckedChange:H=>W(H===!0),"aria-label":"Select all visible requests",disabled:q.length===0})}),e.jsx(U,{children:ie("Date","createdAt")}),e.jsx(U,{children:ie("Name","name")}),e.jsx(U,{children:ie("Email","email")}),e.jsx(U,{children:ie("Phone","phone")}),e.jsx(U,{children:ie("City","city")}),e.jsx(U,{children:ie("Requested act","requestedAct")}),e.jsx(U,{children:"Status"}),a&&e.jsx(U,{className:"w-10"})]})}),e.jsx(De,{children:q.length===0?e.jsx(he,{children:e.jsx(_,{colSpan:re,className:"text-center text-muted-foreground py-8",children:c.trim()?"No requests match your search.":d?"No confirmed requests yet.":"No unconfirmed requests."})}):q.map(R)})]})}),e.jsx(Un,{open:I,onOpenChange:C,children:e.jsxs(_n,{children:[e.jsxs(qn,{children:[e.jsxs(Gn,{children:["Delete ",z.length," request",z.length===1?"":"s","?"]}),e.jsxs(Kn,{children:["This permanently removes the selected support act request",z.length===1?"":"s",". This can't be undone."]})]}),e.jsxs(zn,{children:[e.jsx(Hn,{children:"Cancel"}),e.jsxs(Wn,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:L.isPending,onClick:H=>{H.preventDefault(),L.mutate({data:{ids:z}}
2)},children:[L.isPending?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):null,"Delete"]})]})]})})]})]})}function Zu({canImportLineup:t=!1}){const{toast:s}=Ye(),n=nt(),{data:r,isLoading:a}=Bn(),{data:o=[]}=Wr(),[i,d]=h.useState(!1),[u,c]=h.useState(null),[l,p]=h.useState(sc),[g,v]=h.useState(null),[w,A]=h.useState(null),[N,I]=h.useState(!1),[C,y]=h.useState(""),[T,L]=h.useState(!0),O=h.useMemo(()=>{const P=new Set;for(const Q of o){const de=Q.city?.trim();de&&P.add(de)}return Array.from(P).sort((Q,de)=>Q.localeCompare(de))},[o]),q=qj(l.homeCountry),z=()=>n.invalidateQueries({queryKey:za()}),x=h.useMemo(()=>$b(C),[C]),j=eh({mutation:{onSuccess:P=>{z(),I(!1),y("");const Q=[`${P.created} added`];P.skipped>0&&Q.push(`${P.skipped} skipped`),s({title:"Local guests imported",description:Q.join(", ")})},onError:()=>s({title:"Could not import local guests",variant:"destructive"})}}),E=th({mutation:{onSuccess:()=>{z(),d(!1),s({title:"Support act added"})},onError:()=>s({title:"Could not save support act",variant:"destructive"})}}),W=sh({mutation:{onSuccess:()=>{z(),d(!1),s({title:"Support act updated"})},onError:()=>s({title:"Could not save support act",variant:"destructive"})}}),ie=nh({mutation:{onSuccess:()=>{z(),n.invalidateQueries({queryKey:Qe()}),v(null),s({title:"Support act removed"})},onError:()=>s({title:"Could not remove support act",variant:"destructive"})}}),[R,re]=h.useState(null),H=rh({mutation:{onMutate:P=>re(P.id),onSuccess:()=>{z(),s({title:"Welcome email sent"})},onError:()=>s({title:"Could not send welcome email",variant:"destructive"}),onSettled:()=>re(null)}}),oe=ah({mutation:{onSuccess:P=>{if(z(),P.targeted===0){s({title:"No one to email",description:"Every act with an email has already logged in."});return}const Q=[`${P.sent} sent`];P.failed>0&&Q.push(`${P.failed} failed`),s({title:"Welcome emails sent",description:Q.join(", "),variant:P.failed>0?"destructive":void 0})},onError:()=>s({title:"Could not send welcome emails",variant:"destructive"})}}),te=()=>{c(null),p(sc),d(!0)},ce=P=>{c(P.id),p({firstName:P.firstName,lastName:P.lastName,email:P.email??"",cell:P.cell??"",instagram:P.instagram??"",facebook:P.facebook??"",tiktok:P.tiktok??"",youtube:P.youtube??"",website:P.website??"",bio:P.bio??"",homeCity:P.homeCity??"",homeState:P.homeState??"",homeCountry:P.homeCountry??"",legalName:P.legalName??"",venmoHandle:P.venmoHandle??"",birthday:P.birthday??"",frequentFlyerPrograms:(P.frequentFlyerPrograms??[]).map(Q=>({airline:Q.airline??"",number:Q.number??""})),headshotUrl:P.headshotUrl??"",category:P.category??"support"}),d(!0)},V=()=>{const P={firstName:l.firstName.trim(),lastName:(l.lastName??"").trim(),email:(l.email??"").trim(),cell:be(l.cell),instagram:be(l.instagram),facebook:be(l.facebook),tiktok:be(l.tiktok),youtube:be(l.youtube),website:be(l.website),bio:be(l.bio),homeCity:be(l.homeCity),homeState:be(l.homeState),homeCountry:be(l.homeCountry),legalName:be(l.legalName),venmoHandle:be(l.venmoHandle),birthday:be(l.birthday),frequentFlyerPrograms:(l.frequentFlyerPrograms??[]).map(Q=>({airline:be(Q.airline??""),number:be(Q.number??"")})).filter(Q=>Q.airline!==null||Q.number!==null),headshotUrl:be(l.headshotUrl),category:l.category??"support"};u!=null?W.mutate({id:u,data:P}):E.mutate({data:P})},ue=E.isPending||W.isPending,$=l.firstName.trim()!=="",se=h.useMemo(()=>[...r??[]].sort((P,Q)=>P.lastName.localeCompare(Q.lastName)||P.firstName.localeCompare(Q.firstName)),[r]),X=h.useMemo(()=>{const P=Date.now(),Q=new Set;for(const de of o)if(!(new Date(de.date).getTime()<P))for(const ke of de.supportActs??[])Q.add(ke.id);return Q},[o]),D=h.useMemo(()=>{const P=se.filter(Q=>Q.category!=="local_guest");return T?P.filter(Q=>X.has(Q.id)):P},[se,T,X]),J=h.useMemo(()=>{const P=se.filter(Q=>Q.category==="local_guest");return T?P.filter(Q=>X.has(Q.id)):P},[se,T,X]),fe=(P,Q)=>e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Name"}),e.jsx(U,{children:"Email"}),e.jsx(U,{children:"Cell"}),e.jsx(U,{className:"text-right",children:"Shows"}),e.jsx(U,{children:"Status"}),e.jsx(U,{children:"Socials"}),e.jsx(U,{className:"text-right",children:"Actions"})]})}),e.jsxs(De,{children:[P.map(de=>e.jsxs(he,{children:[e.jsx(_,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pi,{act:de,size:"sm"}),e.jsx("span",{className:"font-medium",children:Ue(de)}
2),de.category==="tour_manager"?e.jsx(it,{variant:"secondary",className:"text-[10px] uppercase tracking-wide",children:"Tour manager"}):null]})}),e.jsx(_,{className:"text-muted-foreground",children:de.email||"—"}),e.jsx(_,{className:"text-muted-foreground",children:ia(de.cell)??"—"}),e.jsx(_,{className:"text-right tabular-nums",children:de.showCount??0}),e.jsx(_,{children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[de.firstLoginAt?e.jsx(it,{variant:"secondary",className:"w-fit text-[10px] uppercase tracking-wide",children:"Logged in"}):e.jsx(it,{variant:"outline",className:"w-fit text-[10px] uppercase tracking-wide text-muted-foreground",children:"Not logged in"}),de.welcomeEmailSentAt?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Welcome ",_u(de.welcomeEmailSentAt)]}):null]})}),e.jsx(_,{children:e.jsx(Vb,{act:de})}),e.jsxs(_,{className:"text-right",children:[de.firstLoginAt?null:e.jsxs(F,{variant:"ghost",size:"sm",disabled:!de.email||R===de.id,title:de.email?de.welcomeEmailSentAt?"Resend welcome email":"Send welcome email":"No email on file",onClick:()=>H.mutate({id:de.id}),children:[R===de.id?e.jsx(le,{className:"mr-1 h-4 w-4 animate-spin"}):e.jsx(Ka,{className:"mr-1 h-4 w-4"}),de.welcomeEmailSentAt?"Resend":"Welcome"]}),e.jsxs(F,{variant:"ghost",size:"sm",onClick:()=>A(de),children:[e.jsx(tn,{className:"mr-1 h-4 w-4"})," Add to shows"]}),e.jsx(F,{variant:"ghost",size:"icon","aria-label":"Edit support act",onClick:()=>ce(de),children:e.jsx(En,{className:"h-4 w-4"})}),e.jsx(F,{variant:"ghost",size:"icon","aria-label":"Remove support act",onClick:()=>v(de.id),children:e.jsx(ls,{className:"h-4 w-4 text-destructive"})})]})]},de.id)),P.length===0?e.jsx(he,{children:e.jsx(_,{colSpan:7,className:"py-8 text-center text-muted-foreground",children:Q})}):null]})]})});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Support acts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Roster of support acts. Anyone here can sign in to manage their own profile and view the tour."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(In,{checked:T,onCheckedChange:P=>L(P===!0)}),"Only with upcoming shows"]}),e.jsxs(F,{variant:"outline",disabled:oe.isPending,onClick:()=>oe.mutate(),title:"Email acts who have an email on file but have never logged in",children:[oe.isPending?e.jsx(le,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ka,{className:"h-4 w-4 mr-1"}),"Welcome acts not logged in"]}),e.jsxs(F,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(Us,{className:"h-4 w-4 mr-1"})," Bulk import guest roster"]}),t?e.jsxs(F,{variant:"outline",onClick:()=>window.dispatchEvent(new Event("open-lineup-import")),children:[e.jsx(Bi,{className:"h-4 w-4 mr-1"})," Import lineup by date"]}):null,e.jsxs(F,{onClick:te,children:[e.jsx(gt,{className:"h-4 w-4 mr-1"})," Add support act"]})]})]}),a?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-display text-sm font-bold uppercase tracking-wide text-muted-foreground",children:"Support acts & tour managers"}),fe(D,T?"No support acts or tour managers with upcoming shows.":"No support acts or tour managers yet. Add your first one.")]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-display text-sm font-bold uppercase tracking-wide text-muted-foreground",children:"Local guests"}),fe(J,T?"No local guests with upcoming shows.":"No local guests yet. Add one or use bulk import.")]}),e.jsx(Ob,{})]}),e.jsx(Ze,{open:i,onOpenChange:d,children:e.jsxs(Xe,{className:"max-h-[90vh] overflow-y-auto",children:[e.jsxs(Je,{children:[e.jsx(et,{children:u!=null?"Edit support act":"Add support act"}),e.jsx(at,{children:"Contact details stay private. Name, photo and socials are shown publicly when this act opens a show."})]}),e.jsxs("div",{className:"grid gap-4 py-2",children:[e.jsx(Qu,{value:l.headshotUrl,fullNameForAlt:`${l.firstName} ${l.lastName}`,onChange:P=>p({...l,headshotUrl:P})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-first",children:"First name"}),e.jsx(ne,{id:"sa-first",value:l.firstName,onChange:P=>p({...l,firstName:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-last",children:"Last name"}),e.jsx(ne,{id:"sa-last",value:l.lastName??"",onChange:P=>p({...l,lastName:P.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-email",children:"Email"}),e.jsx(ne,{id:"sa-email",type:"email",placeholder:"[email protected]",value:l.email??"",onChange:P=>p({...l,email:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-cell",children:"Cell"}),e.jsx(ne,{id:"sa-cell",value:l.cell??"",onChange:P=>p({...l,cell:P.target.value})})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-category",children:"Category"}),e.jsxs(ns,{value:l.category??"support",onValueChange:P=>p({...l,category:P}),children:[e.jsx(rs,{id:"sa-category",children:e.jsx(as,{})}),e.jsxs(is,{children:[e.jsx(Ge,{value:"support",children:"Support act"}),e.jsx(Ge,{value:"tour_manager",children:"Tour manager"}),e.jsx(Ge,{value:"local_guest",children:"Local guest"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tour managers have the same access as support acts. Local guests can only sign in to edit their own profile — no calendar or itinerary access."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-instagram",children:"Instagram"}),e.jsx(ne,{id:"sa-instagram",placeholder:"https://instagram.com/...",value:l.instagram??"",onChange:P=>p({...l,instagram:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-facebook",children:"Facebook"}),e.jsx(ne,{id:"sa-facebook",placeholder:"https://facebook.com/...",value:l.facebook??"",onChange:P=>p({...l,facebook:P.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-tiktok",children:"TikTok"}),e.jsx(ne,{id:"sa-tiktok",placeholder:"https://tiktok.com/@...",value:l.tiktok??"",onChange:P=>p({...l,tiktok:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-youtube",children:"YouTube"}),e.jsx(ne,{id:"sa-youtube",placeholder:"https://youtube.com/@...",value:l.youtube??"",onChange:P=>p({...l,youtube:P.target.value})})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-website",children:"Website"}),e.jsx(ne,{id:"sa-website",placeholder:"https://...",value:l.website??"",onChange:P=>p({...l,website:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{htmlFor:"sa-bio",children:"Bio"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(l.bio??"").length,"/300"]})]}),e.jsx(Pt,{id:"sa-bio",placeholder:"A short blurb shown on this act's public profile.",maxLength:300,rows:3,value:l.bio??"",onChange:P=>p({...l,bio:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-home-country",children:"Home Country"}),e.jsxs(ns,{value:l.homeCountry??"",onValueChange:P=>p({...l,homeCountry:P,homeState:""}),children:[e.jsx(rs,{id:"sa-home-country",children:e.jsx(as,{placeholder:"Select country"})}),e.jsx(is,{children:Oj.map(P=>e.jsx(Ge,{value:P,children:P},P))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-home-state",children:q?"Home State / Province":"Home State / Region"}),q?e.jsxs(ns,{value:l.homeState??"",onValueChange:P=>p({...l,homeState:P}),children:[e.jsx(rs,{id:"sa-home-state",children:e.jsx(as,{placeholder:"Select state"})}),e.jsx(is,{children:q.map(P=>e.jsx(Ge,{value:P,children:P},P))})]}
2):e.jsx(ne,{id:"sa-home-state",placeholder:"State / region",value:l.homeState??"",onChange:P=>p({...l,homeState:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-home-city",children:"Home City"}),e.jsx(ne,{id:"sa-home-city",list:"sa-home-city-options",placeholder:"City",value:l.homeCity??"",onChange:P=>p({...l,homeCity:P.target.value})}),e.jsx("datalist",{id:"sa-home-city-options",children:O.map(P=>e.jsx("option",{value:P},P))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-legal-name",children:"Government Name"}),e.jsx(ne,{id:"sa-legal-name",placeholder:"Legal name for travel bookings",value:l.legalName??"",onChange:P=>p({...l,legalName:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-venmo",children:"Venmo Username"}),e.jsx(ne,{id:"sa-venmo",placeholder:"username (without the @)",value:l.venmoHandle??"",onChange:P=>p({...l,venmoHandle:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"sa-birthday",children:"Birthday"}),e.jsx(ne,{id:"sa-birthday",type:"date",value:l.birthday??"",onChange:P=>p({...l,birthday:P.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{children:"Frequent Flyer Programs"}),(l.frequentFlyerPrograms??[]).map((P,Q)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{placeholder:"Airline (e.g. Delta)",value:P.airline??"",onChange:de=>{const ke=[...l.frequentFlyerPrograms??[]];ke[Q]={...ke[Q],airline:de.target.value},p({...l,frequentFlyerPrograms:ke})}}),e.jsx(ne,{placeholder:"Membership number",value:P.number??"",onChange:de=>{const ke=[...l.frequentFlyerPrograms??[]];ke[Q]={...ke[Q],number:de.target.value},p({...l,frequentFlyerPrograms:ke})}}),e.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"shrink-0","aria-label":"Remove program",onClick:()=>p({...l,frequentFlyerPrograms:(l.frequentFlyerPrograms??[]).filter((de,ke)=>ke!==Q)}),children:e.jsx(en,{className:"h-4 w-4"})})]},Q)),e.jsxs(F,{type:"button",variant:"outline",size:"sm",className:"w-fit",onClick:()=>p({...l,frequentFlyerPrograms:[...l.frequentFlyerPrograms??[],{airline:"",number:""}]}),children:[e.jsx(gt,{className:"mr-1 h-4 w-4"})," Add program"]})]})]}),e.jsxs(ut,{children:[e.jsx(F,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(F,{onClick:V,disabled:ue||!$,children:ue?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})}),e.jsx(Un,{open:g!=null,onOpenChange:P=>!P&&v(null),children:e.jsxs(_n,{children:[e.jsxs(qn,{children:[e.jsx(Gn,{children:"Remove this support act?"}),e.jsx(Kn,{children:"This removes them from the roster and from any shows they open. This cannot be undone."})]}),e.jsxs(zn,{children:[e.jsx(Hn,{children:"Cancel"}),e.jsx(Wn,{onClick:()=>g!=null&&ie.mutate({id:g}),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})}),e.jsx(Bb,{act:w,shows:o,onOpenChange:P=>!P&&A(null)}),e.jsx(Ze,{open:N,onOpenChange:P=>{I(P),P||y("")},children:e.jsxs(Xe,{className:"max-w-2xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Bulk import local guests"}),e.jsx(at,{children:"Paste one guest per line as First, Last, Email, Phone (phone optional). Commas or tabs both work, so you can paste straight from a spreadsheet. Everyone added here joins as a local guest."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Pt,{value:C,onChange:P=>y(P.target.value),rows:10,placeholder:`Jane, Doe, [email protected], 555-123-4567
3John, Smith, [email protected]`,className:"font-mono text-sm"}),C.trim()!==""&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:[x.valid.length," ready to import",x.errors.length>0?`, ${x.errors.length} need fixing`:"","."]}),x.errors.length>0&&e.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-destructive/40 bg-destructive/5 p-2",children:x.errors.map(P=>e.jsxs("div",{className:"text-xs text-destructive",children:["Line ",P.line,": ",P.reason,' — "',P.raw,'"']},P.line))})]})]}),e.jsxs(ut,{children:[e.jsx(F,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(F,{onClick:()=>j.mutate({data:{acts:x.valid}}),disabled:j.isPending||x.valid.length===0,children:j.isPending?e.jsx(le,{className:"h-4 w-4 animate-spin"}):`Import ${x.valid.length} guest${x.valid.length===1?"":"s"}`})]})]})})]})}function Bb({act:t,shows:s,onOpenChange:n}){const{toast:r}
3=Ye(),a=nt(),[o,i]=h.useState([]),[d,u]=h.useState(""),[c,l]=h.useState(!1),[p,g]=h.useState(""),[v,w]=h.useState("");h.useEffect(()=>{i([]),u(""),l(!1),g(""),w("")},[t]);const A=Dh({mutation:{onSuccess:j=>{a.invalidateQueries({queryKey:Qe()}),n(!1);const E=j.added;r({title:E>0?`Added to ${E} show${E===1?"":"s"}`:"No new shows added",description:j.alreadyAttached>0?`${j.alreadyAttached} selected show${j.alreadyAttached===1?" was":"s were"} already in the lineup.`:void 0})},onError:()=>r({title:"Could not add to shows",variant:"destructive"})}}),N=Date.now()-10800*1e3,I=j=>(j.supportActs??[]).some(E=>E.id===t?.id),C=p!==""||v!=="",y=p?new Date(`${p}T00:00:00`).getTime():null,T=v?new Date(`${v}T23:59:59.999`).getTime():null,L=h.useMemo(()=>{const j=d.trim().toLowerCase();return[...s].filter(E=>{const W=new Date(E.date).getTime();return C?!(y!=null&&W<y||T!=null&&W>T):c||W>=N}).filter(E=>j===""||`${E.venue} ${E.city} ${E.regionLabel??E.region}`.toLowerCase().includes(j)).sort((E,W)=>new Date(E.date).getTime()-new Date(W.date).getTime())},[s,d,c,N,C,y,T]),O=L.filter(j=>!I(j)),q=O.length>0&&O.every(j=>o.includes(j.id)),z=j=>i(E=>E.includes(j)?E.filter(W=>W!==j):[...E,j]),x=()=>i(j=>{if(q){const W=new Set(O.map(ie=>ie.id));return j.filter(ie=>!W.has(ie))}const E=new Set(j);return O.forEach(W=>E.add(W.id)),Array.from(E)});return e.jsx(Ze,{open:t!=null,onOpenChange:n,children:e.jsxs(Xe,{className:"flex max-h-[90vh] flex-col overflow-hidden sm:max-w-2xl",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Add to shows"}),e.jsx(at,{children:t?`Pick the shows ${Ue(t)} should open. They'll be added to the end of each lineup; shows already listing them are skipped.`:""})]}),e.jsxs("div",{className:"flex min-h-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"Search shows by venue or city",value:d,onChange:j=>u(j.target.value),className:"pl-8"})]}),e.jsxs(F,{type:"button",variant:c?"default":"outline",size:"sm",disabled:C,onClick:()=>l(j=>!j),className:"shrink-0",children:[e.jsx(tn,{className:"mr-1 h-4 w-4"}),c?"All dates":"Upcoming"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Date range"}),e.jsx(ne,{type:"date",value:p,max:v||void 0,onChange:j=>g(j.target.value),className:"w-auto","aria-label":"From date"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ne,{type:"date",value:v,min:p||void 0,onChange:j=>w(j.target.value),className:"w-auto","aria-label":"To date"}),C?e.jsx(F,{type:"button",variant:"ghost",size:"sm",onClick:()=>{g(""),w("")},children:"Clear"}):null]}),e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("button",{type:"button",onClick:x,disabled:O.length===0,className:"text-sm font-medium text-primary hover:underline disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline",children:q?"Clear selection":"Select all shown"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," selected"]})]}),e.jsx(Ih,{className:"h-[320px] rounded-lg border",children:L.length===0?e.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:"No shows match."}):e.jsx("ul",{className:"divide-y",children:L.map(j=>{const E=I(j);return e.jsx("li",{children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-3 px-3 py-2.5 ${E?"opacity-60":"hover:bg-muted/50"}`,children:[e.jsx(In,{checked:E||o.includes(j.id),disabled:E,onCheckedChange:()=>!E&&z(j.id)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-medium",children:j.venue}),e.jsxs("p",{className:"truncate text-sm text-muted-foreground",children:[j.city,j.regionLabel||j.region?`, ${j.regionLabel||j.region}`:""," ","·"," ",new Date(j.date).toLocaleDateString("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"})]})]}),E?e.jsx(it,{variant:"secondary",className:"shrink-0",children:"Added"}):null]})},j.id)})})})]}),e.jsxs(ut,{children:[e.jsx(F,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(F,{disabled:o.length===0||A.isPending,onClick:()=>t&&A.mutate({id:t.id,data:{showIds:o}}),children:A.isPending?e.jsx(le,{className:"h-4 w-4 animate-spin"}):`Add to ${o.length||""} ${o.length===1?"show":"shows"}`.trim()})]})]})})}const Ub="2021-01-01",_b="2023-01-01",Xu=t=>
3new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(t)),qb=t=>Xu(t)<Ub,Gb=t=>Xu(t)<_b?1/0:1,Kb=[{value:"tour_manager",label:"Tour Manager"},{value:"support",label:"Support Act"},{value:"guest",label:"Guest"}],zb=t=>t==="tour_manager"?"tour_manager":t==="support"?"support":"guest",nc=(t,s,n,r,a)=>{const o={...t,[n]:r};if(r==="tour_manager")for(const i of s)i!==n&&o[i]==="tour_manager"&&(o[i]="guest");else if(r==="support"){let i=1;for(const d of s)d===n||o[d]!=="support"||(i<a?i++:o[d]="guest")}return o};function Hb({show:t,acts:s,lineup:n,onOpenChange:r}){const{toast:a}=Ye(),o=nt(),[i,d]=h.useState([]),[u,c]=h.useState({}),[l,p]=h.useState(""),g=t?!qb(t.date):!1,v=t?Gb(t.date):1,w=t?.id??null;h.useEffect(()=>{if(t){const E=(t.supportActs??[]).map(R=>R.id);d(E);const W=new Map(n.map(R=>[R.supportActId,R.effectiveRole])),ie={};for(const R of E)ie[R]=W.get(R)??"guest";c(ie)}p("")},[w]);const A=fh({mutation:{onSuccess:()=>{o.invalidateQueries({queryKey:Qe()})},onError:()=>a({title:"Could not update support acts",variant:"destructive"})}}),N=(E,W)=>{if(!t)return;const ie=E.map(R=>({id:R,role:g?W[R]??"guest":null}));A.mutate({id:t.id,data:{supportActs:ie}})},I=E=>{const W=[...i,E],ie=zb(O.get(E)?.category),R=nc(u,W,E,ie,v);d(W),c(R),N(W,R)},C=E=>{const W=i.filter(R=>R!==E),ie={...u};delete ie[E],d(W),c(ie),N(W,ie)},y=(E,W)=>{const ie=nc(u,i,E,W,v);c(ie),N(i,ie)},T=h.useRef(i);T.current=i;const L=h.useRef(u);L.current=u;const O=h.useMemo(()=>new Map(s.map(E=>[E.id,E])),[s]),q=i.map(E=>O.get(E)).filter(E=>!!E),z=s.filter(E=>!i.includes(E.id)),x=l.trim().toLowerCase(),j=x===""?z:z.filter(E=>Ue(E).toLowerCase().includes(x));return e.jsx(Ze,{open:t!=null,onOpenChange:r,children:e.jsxs(Xe,{className:"max-h-[90vh] overflow-y-auto",children:[e.jsxs(Je,{children:[e.jsx(et,{children:"Support"}),e.jsx(at,{children:t?`Who is opening for ${t.venue} on ${new Date(t.date).toLocaleDateString("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"})}? Drag to set the running order.`:""})]}),e.jsxs("div",{className:"grid gap-5 py-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Lineup (in order)"}),q.length===0?e.jsx("p",{className:"rounded-lg border border-dashed px-3 py-4 text-center text-sm text-muted-foreground",children:"No support acts yet. Add acts from below."}):e.jsx(xo,{axis:"y",values:i,onReorder:d,className:"space-y-2",children:q.map(E=>e.jsxs(vo,{value:E.id,onDragEnd:()=>N(T.current,L.current),className:"flex items-center gap-3 rounded-lg border bg-card px-3 py-2",children:[e.jsx(Ui,{className:"h-4 w-4 shrink-0 cursor-grab text-muted-foreground"}),e.jsx(Pi,{act:E,size:"sm"}),e.jsx("span",{className:"flex-1 font-medium",children:Ue(E)}),g&&e.jsx("select",{"aria-label":`Role for ${Ue(E)}`,value:u[E.id]??"guest",onChange:W=>y(E.id,W.target.value),className:"h-8 rounded-md border border-input bg-background px-2 text-xs",children:Kb.map(W=>e.jsx("option",{value:W.value,children:W.label},W.value))}),e.jsx(F,{variant:"ghost",size:"icon","aria-label":"Remove support act",onClick:()=>C(E.id),children:e.jsx(en,{className:"h-4 w-4"})})]},E.id))})]}),z.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Add an act"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ms,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"Filter acts by name",value:l,onChange:E=>p(E.target.value),className:"pl-8"})]}),e.jsx("div",{className:"space-y-2",children:j.length===0?e.jsxs("p",{className:"rounded-lg border border-dashed px-3 py-4 text-center text-sm text-muted-foreground",children:["No acts match “",l.trim(),"”."]}):j.map(E=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border px-3 py-2",children:[e.jsx(Pi,{act:E,size:"sm"}),e.jsx("span",{className:"flex-1 font-medium",children:Ue(E)}),e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>I(E.id),children:[e.jsx(gt,{className:"h-4 w-4 mr-1"})," Add"]})]},E.id))})]}
3):null,s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No support acts in the roster yet. Add some in the Support Acts tab first."}):null]}),e.jsxs(ut,{className:"items-center sm:justify-between",children:[e.jsx("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:A.isPending?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"h-4 w-4 animate-spin"})," Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Xa,{className:"h-4 w-4 text-emerald-600"})," Changes save automatically"]})}),e.jsx(F,{variant:"outline",onClick:()=>r(!1),children:"Done"})]})]})})}function rc({days:t}){const s=h.useMemo(()=>{const n=new Map;for(const r of t){const a=r.date.slice(0,10),o=n.get(a)??[];o.push(r),n.set(a,o)}return[...n.entries()].sort((r,a)=>r[0].localeCompare(a[0])).map(([r,a])=>({date:r,rows:a}))},[t]);return t.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed py-16 text-center text-muted-foreground",children:[e.jsx(tn,{className:"mx-auto mb-3 h-10 w-10 opacity-20"}),e.jsx("p",{className:"font-medium",children:"No itinerary days posted yet."})]}):e.jsx("div",{className:"space-y-3",children:s.map(n=>{const r=n.rows,a=r.length>1,[o,i,d]=n.date.split("-"),u=o&&i&&d?`${Number(i)}/${Number(d)}/${o.slice(2)}`:r[0].dateLabel,c=r.find(C=>!!C.venue?.trim()||!!C.venueAddress?.trim()||!!C.showTime?.trim())??r.find(C=>(C.shows?.length??0)>0)??r[0],l=c.shows?.[0]??null,p=(()=>{if(l){const T=l.address?.trim();if(!T)return null;const L=l.city?.trim();return L&&!T.toLowerCase().includes(L.toLowerCase())?`${T}, ${L}`:T}const C=c.venueAddress?.trim(),y=c.venueCity?.trim();return C?y&&!C.toLowerCase().includes(y.toLowerCase())?`${C}, ${y}`:C:y||null})(),g=r.some(C=>(C.shows?.length??0)>0||!!C.venue?.trim()||!!C.city?.trim()||!!C.showTime?.trim()),v=r.some(C=>!!C.hotel?.trim()),w=!g&&v,A=r.flatMap(Ti),N=A.length>0,I=r.flatMap(Ai);return e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"border-b bg-muted/30 px-4 py-3",children:e.jsxs("p",{className:"font-display text-lg font-bold leading-tight",children:[u,l?e.jsxs("span",{className:"ml-2 text-sm font-semibold text-muted-foreground",children:[l.city,l.regionLabel?`, ${l.regionLabel}`:""]}):null]})}),e.jsxs("div",{className:"grid gap-x-8 gap-y-5 p-4 sm:grid-cols-2 lg:grid-cols-2",children:[e.jsx(Js,{children:w?e.jsx("p",{className:"font-display text-base font-bold uppercase tracking-wide",children:"Day Off"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-0.5 text-sm",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(xt,{value:l?l.venue:c.venue,name:"Venue"})}),e.jsxs("p",{className:"text-muted-foreground",children:[e.jsx(Pn,{raw:p,display:zs(p),name:"Address"})," · ",e.jsx(ws,{raw:l?.venuePhone?.trim()||c.venuePhone,name:"Phone"})]})]}),(()=>{const C=(c.showTime??(l?An(l.date):null))?.trim()||null,y=Mt(c.venueAvailable?.trim()||Ks(C,c.timesConfirmed,-120)||null),T=Mt(c.doors?.trim()||Ks(C,c.timesConfirmed,-60)||null),L=Mt(C),O=[y&&`${y} Arrive`,T&&`${T} Doors`,L&&`${L} Show`].filter(Boolean);return e.jsxs("div",{className:"text-sm font-medium",children:[e.jsx(xt,{value:O.length?O.join(", "):null,name:"Schedule"}),O.length>0&&!c.timesConfirmed&&e.jsx("span",{className:"ml-1 text-xs font-normal text-amber-600 dark:text-amber-400",children:"(tentative)"})]})})(),l&&e.jsx(Qs,{event:bc(l),label:"Add show to calendar",filename:`steve-hofstetter-${l.city??"show"}`,iconOnly:!0,className:"h-8 w-8"}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Wifi: ",e.jsx(xt,{value:c.wifi,name:"Wifi"}),c.wifiPassword?.trim()&&e.jsxs(e.Fragment,{children:[" · Password: ",c.wifiPassword]})]}),e.jsx(yu,{gummies:c.gummies,food:c.food,washerDryer:c.washerDryer})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Js,{title:a?"Hotels":void 0,children:r.map((C,y)=>e.jsx("div",{className:y>0?"border-t pt-3":"",children:e.jsxs("div",{className:"space-y-0.5 text-sm",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(xt,{value:C.hotel,name:"Hotel"})}),Ws(C)&&e.jsx("p",{className:"text-muted-foreground",children:Ws(C)}),e.jsx("p",{className:"text-muted-foreground",children:e.jsx(Pn,{raw:C.hotelAddress,display:zs(C.hotelAddress),name:"Address"})}),e.jsx("p",{className:"text-muted-foreground",children:e.jsx(ws,{raw:C.hotelPhone,name:"Phone"})}),(()=>{const T=qu(C),O=T.filter(q=>q.confirmationCode?.trim()||q.costCents!=null).length>1;return e.jsxs(e.Fragment,{children:[T.map((q,z)=>q.confirmationCode?.trim()||q.costCents!=null?e.jsxs("div",{className:"text-muted-foreground",children:[O&&e.jsxs("span",{className:"font-medium text-foreground",children:["Room ",z+1,q.roomType?.trim()?` · ${q.roomType}`:"",":"," "]}),q.confirmationCode?.trim()&&e.jsxs("span",{children:["Confirmation:"," ",e.jsx("span",{className:"font-medium text-foreground",children:q.confirmationCode})]}),q.confirmationCode?.trim()&&q.costCents!=null&&" · ",q.costCents!=null&&e.jsxs("span",{children:["Cost:"," ",e.jsx("span",{className:"font-medium text-foreground",children:Dt(q.costCents)})]})]},z):null),O&&C.hotelCostCents!=null&&e.jsxs("p",{className:"text-muted-foreground",children:["Total:"," ",e.jsx("span",{className:"font-medium text-foreground",children:Dt(C.hotelCostCents)})]})]})})(),C.hotel?.trim()&&e.jsx("div",{className:"pt-1",children:e.jsx(Qs,{event:wc({hotel:C.hotel,hotelAddress:C.hotelAddress,hotelPhone:C.hotelPhone,confirmationCode:C.hotelConfirmationCode,rooms:Ws(C),dateYmd:n.date}),label:"Add hotel to calendar",filename:`hotel-${C.hotel??"stay"}`,iconOnly:!0,className:"h-8 w-8"})})]})},C.id))}),N&&e.jsx(Hu,{legs:A,dateYmd:n.date}),e.jsx(Wu,{rentals:I,dateYmd:n.date})]})]})]},n.date)})})}function ac({name:t}){const{signOut:s}=Li();return e.jsx("header",{className:"sticky top-0 z-40 border-b bg-background",children:e.jsxs("div",{className:"container mx-auto flex h-16 items-center justify-between px-4 md:px-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ys,{href:"/",className:"font-display text-lg font-black uppercase tracking-tighter text-primary",children:"Steve Hofstetter"}),e.jsx(it,{variant:"outline",className:"uppercase tracking-wide",children:"Performer"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs(Ys,{href:"/",children:[e.jsx(Nc,{className:"h-4 w-4 mr-1"})," View site"]})}),t?e.jsx("span",{className:"hidden text-sm text-muted-foreground sm:inline",children:t}):null,e.jsx(F,{variant:"outline",size:"sm",onClick:()=>s({redirectUrl:lr||"/"}),children:"Sign out"})]})]})})}function Mi(){const{toast:t}=Ye(),s=nt(),{data:n,isLoading:r}=ih(),[a,o]=h.useState(null);h.useEffect(()=>{n&&o({firstName:n.firstName,lastName:n.lastName,cell:n.cell??"",instagram:n.instagram??"",facebook:n.facebook??"",tiktok:n.tiktok??"",youtube:n.youtube??"",website:n.website??"",bio:n.bio??"",legalName:n.legalName??"",venmoHandle:n.venmoHandle??"",birthday:n.birthday??"",frequentFlyerPrograms:(n.frequentFlyerPrograms??[]).map(c=>({airline:c.airline??"",number:c.number??""}
3)),headshotUrl:n.headshotUrl??""})},[n]);const i=oh({mutation:{onSuccess:()=>{s.invalidateQueries({queryKey:Oh()}),s.invalidateQueries({queryKey:Bh()}),t({title:"Profile saved"})},onError:()=>t({title:"Could not save profile",variant:"destructive"})}});if(r||!a)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})});const d=()=>{i.mutate({data:{firstName:a.firstName.trim(),lastName:a.lastName.trim(),cell:be(a.cell),instagram:be(a.instagram),facebook:be(a.facebook),tiktok:be(a.tiktok),youtube:be(a.youtube),website:be(a.website),bio:be(a.bio),legalName:be(a.legalName),venmoHandle:be(a.venmoHandle),birthday:be(a.birthday),frequentFlyerPrograms:(a.frequentFlyerPrograms??[]).map(c=>({airline:be(c.airline??""),number:be(c.number??"")})).filter(c=>c.airline!==null||c.number!==null),headshotUrl:be(a.headshotUrl)}})},u=a.firstName.trim()!==""&&a.lastName.trim()!=="";return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"My profile"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This is what fans see when you open a show. Your email stays private."})]}),e.jsxs("div",{className:"grid gap-4 rounded-lg border bg-card p-6",children:[e.jsx(Qu,{value:a.headshotUrl,fullNameForAlt:`${a.firstName} ${a.lastName}`,onChange:c=>o({...a,headshotUrl:c})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-first",children:"First name"}),e.jsx(ne,{id:"p-first",value:a.firstName,onChange:c=>o({...a,firstName:c.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-last",children:"Last name"}),e.jsx(ne,{id:"p-last",value:a.lastName,onChange:c=>o({...a,lastName:c.target.value})})]})]}),n?.email?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{children:"Email"}),e.jsx(ne,{value:n.email,disabled:!0})]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-cell",children:"Cell"}),e.jsx(ne,{id:"p-cell",value:a.cell??"",onChange:c=>o({...a,cell:c.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-instagram",children:"Instagram"}),e.jsx(ne,{id:"p-instagram",placeholder:"https://instagram.com/...",value:a.instagram??"",onChange:c=>o({...a,instagram:c.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-facebook",children:"Facebook"}),e.jsx(ne,{id:"p-facebook",placeholder:"https://facebook.com/...",value:a.facebook??"",onChange:c=>o({...a,facebook:c.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-tiktok",children:"TikTok"}),e.jsx(ne,{id:"p-tiktok",placeholder:"https://tiktok.com/@...",value:a.tiktok??"",onChange:c=>o({...a,tiktok:c.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-youtube",children:"YouTube"}),e.jsx(ne,{id:"p-youtube",placeholder:"https://youtube.com/@...",value:a.youtube??"",onChange:c=>o({...a,youtube:c.target.value})})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-website",children:"Website"}),e.jsx(ne,{id:"p-website",placeholder:"https://...",value:a.website??"",onChange:c=>o({...a,website:c.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{htmlFor:"p-bio",children:"Bio"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(a.bio??"").length,"/300"]})]}),e.jsx(Pt,{id:"p-bio",placeholder:"A short blurb fans see on your profile.",maxLength:300,rows:3,value:a.bio??"",onChange:c=>o({...a,bio:c.target.value})})]}),e.jsxs("div",{className:"space-y-1 border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Travel info"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only Steve's team sees this — it's used for booking your travel. Never shown publicly."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-legal-name",children:"Government name"}),e.jsx(ne,{id:"p-legal-name",placeholder:"Legal name as it appears on your ID",value:a.legalName??"",onChange:c=>o({...a,legalName:c.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-birthday",children:"Birthday"}),e.jsx(ne,{id:"p-birthday",type:"date",value:a.birthday??"",onChange:c=>o({...a,birthday:c.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"p-venmo",children:"Venmo username"}),e.jsx(ne,{id:"p-venmo",placeholder:"username (without the @)",value:a.venmoHandle??"",onChange:c=>o({...a,venmoHandle:c.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to pay you what you're owed after a run."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{children:"Frequent flyer programs"}),(a.frequentFlyerPrograms??[]).map((c,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{placeholder:"Airline (e.g. Delta)",value:c.airline??"",onChange:p=>{const g=[...a.frequentFlyerPrograms??[]];g[l]={...g[l],airline:p.target.value},o({...a,frequentFlyerPrograms:g})}}),e.jsx(ne,{placeholder:"Membership number",value:c.number??"",onChange:p=>{const g=[...a.frequentFlyerPrograms??[]];g[l]={...g[l],number:p.target.value},o({...a,frequentFlyerPrograms:g})}}),e.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"shrink-0","aria-label":"Remove program",onClick:()=>o({...a,frequentFlyerPrograms:(a.frequentFlyerPrograms??[]).filter((p,g)=>g!==l)}),children:e.jsx(en,{className:"h-4 w-4"})})]},l)),e.jsxs(F,{type:"button",variant:"outline",size:"sm",className:"w-fit",onClick:()=>o({...a,frequentFlyerPrograms:[...a.frequentFlyerPrograms??[],{airline:"",number:""}]}),children:[e.jsx(gt,{className:"mr-1 h-4 w-4"})," Add program"]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{onClick:d,disabled:i.isPending||!u,children:i.isPending?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save profile"})})]})]})}function Wb(){const{data:t=[],isLoading:s}=ch(),[n,r]=h.useState(!1),a=h.useMemo(()=>{const o=Date.now();return[...t].filter(i=>n?!0:new Date(i.date).getTime()>=o).sort((i,d)=>{const u=new Date(i.date).getTime(),c=new Date(d.date).getTime();return n?c-u:u-c})},[t,n]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Tour calendar"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All of Steve's dates. Read-only."})]}),e.jsx(F,{variant:"outline",size:"sm",onClick:()=>r(o=>!o),children:n?"Show upcoming":"Show past dates"})]}),s?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed py-16 text-center text-muted-foreground",children:[e.jsx(tn,{className:"mx-auto mb-3 h-10 w-10 opacity-20"}),e.jsx("p",{className:"font-medium",children:"No dates to show."})]}):e.jsx("div",{className:"space-y-3",children:a.map(o=>{const d=new Date(o.date).toLocaleDateString("en-US",{timeZone:"America/Ne
3w_York",weekday:"short",month:"short",day:"numeric",year:"numeric"}),u=An(o.date);return e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border bg-card p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-display text-lg font-bold leading-tight",children:[o.city,o.region?`, ${o.region.toUpperCase()}`:""]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o.venue}),o.supportActs&&o.supportActs.length>0?e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Support:"," ",o.supportActs.map(c=>Ue(c)).join(", ")]}):null]}),e.jsxs("div",{className:"text-sm font-medium text-muted-foreground sm:text-right",children:[e.jsx("p",{children:d}),e.jsx("p",{children:u})]})]},o.id)})})]})}function Yb(){const{data:t=[],isLoading:s}=dh(),n=jc(),[r,a]=h.useState(""),[o,i]=h.useState(!1),d=uh(),{upcoming:u,past:c}=h.useMemo(()=>{const l=new Date;l.setHours(0,0,0,0),l.setDate(l.getDate()-1);const p=l.getTime(),g=r.trim().toLowerCase(),v=[],w=[];for(const A of t)g&&![A.city,A.venue,A.hotel,A.hotelAddress,A.dateLabel].filter(Boolean).some(I=>I.toLowerCase().includes(g))||(new Date(A.date).getTime()>=p?v.push(A):w.push(A));return{upcoming:v,past:w}},[t,r]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(yc,{open:o,onOpenChange:i,days:d.data??[],isLoading:d.isLoading,isError:d.isError}),e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Itinerary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Travel and show schedule. Read-only."})]}),e.jsxs(F,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(tn,{className:"mr-2 h-4 w-4"}),"Next 14 days"]})]}),e.jsx($i,{quote:n.data,isError:n.isError,isLoading:n.isLoading}),!s&&t.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx(Ms,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ne,{placeholder:"Search city, venue, or hotel...",className:"pl-9",value:r,onChange:l=>a(l.target.value)})]}),s?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(Yr,{defaultValue:"upcoming",children:[e.jsxs(Qr,{className:"mb-4",children:[e.jsx(Le,{value:"upcoming",children:"Upcoming"}),e.jsx(Le,{value:"past",children:"Past"})]}),e.jsx(Ce,{value:"upcoming",children:e.jsx(rc,{days:u})}),e.jsx(Ce,{value:"past",children:e.jsx(rc,{days:c})})]})]})}function ft(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t/100)}function ic(t){const s=new Date(t);return Number.isNaN(s.getTime())?"":s.toLocaleDateString("en-US",{timeZone:"America/New_York",weekday:"short",month:"short",day:"numeric",year:"numeric"})}function Qb({run:t}){const[s,n]=h.useState(!1),r=t.payout,a=[t.firstShowDate,t.lastShowDate].filter(Boolean).map(c=>ic(c)),o=a.length===2&&a[0]!==a[1]?`${a[0]} – ${a[1]}`:a[0]??"",i=[{label:"Base pay",value:r.base},{label:"Bonus",value:r.bonus},{label:"Merch bonus",value:r.merchBonus},{label:"Tips",value:r.tips},{label:"Your merch",value:r.merchOwn},{label:"Driving",value:r.driving},{label:"Misc",value:r.misc},{label:"Cash you held",value:r.cashHeld,negative:!0}].filter(c=>c.value!==0),u=[{key:"base",label:"Base",negative:!1},{key:"bonus",label:"Bonus",negative:!1},{key:"merchBonus",label:"Merch bonus",negative:!1},{key:"tips",label:"Tips",negative:!1},{key:"merchOwn",label:"Your merch",negative:!1},{key:"driving",label:"Driving",negative:!1},{key:"cashHeld",label:"Cash held",negative:!0}].filter(c=>r[c.key]!==0||r.perShow.some(l=>l[c.key]!==0));return e.jsxs("div",{className:"rounded-lg border",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-lg font-bold uppercase tracking-tight",children:t.runTitle}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o&&e.jsxs("span",{children:[o," · "]}),r.showCount," ",r.showCount===1?"show":"shows"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Owed"}),e.jsx("div",{className:"font-display text-2xl font-black tabular-nums",children:ft(r.owed)})]})]}),e.jsxs("div",{className:"border-t px-4 py-3",children:[e.jsx("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-1 text-sm sm:grid-cols-3",children:i.map(c=>e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("dt",{className:"text-muted-foreground",children:c.label}),e.jsx("dd",{className:"tabular-nums",children:c.negative?`−${ft(c.value)}`:ft(c.value)})]},c.label))}),r.miscNote&&r.miscNote.trim()!==""&&e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Misc note:"})," ",r.miscNote]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 border-t pt-3 text-sm",children:[e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Total "}),e.jsx("span",{className:"font-semibold tabular-nums",children:ft(r.total)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Paid "}),e.jsx("span",{className:"font-semibold tabular-nums",children:ft(r.paid)})]})]}),r.perShow.length>0&&e.jsxs(F,{variant:"ghost",size:"sm",onClick:()=>n(c=>!c),children:[s?e.jsx(It,{className:"mr-1 h-4 w-4"}):e.jsx(rp,{className:"mr-1 h-4 w-4"}),"Per-show breakdown"]})]})]}),s&&r.perShow.length>0&&e.jsxs("div",{className:"overflow-x-auto border-t",children:[e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"px-4 py-2 font-medium",children:"Show"}),u.map(c=>e.jsx("th",{className:"whitespace-nowrap px-2 py-2 text-right font-medium",children:c.label},c.key)),e.jsx("th",{className:"whitespace-nowrap px-4 py-2 text-right font-medium",children:"Total"})]})}),e.jsx("tbody",{children:r.perShow.map(c=>{const l=u.reduce((p,g)=>p+(g.negative?-c[g.key]:c[g.key]),0);return e.jsxs("tr",{className:"border-b bg-muted/20 last:border-b-0",children:[e.jsxs("td",{className:"px-4 py-2",children:[e.jsx("div",{className:"font-medium text-foreground",children:ic(c.date)}),c.venue&&e.jsx("div",{className:"text-muted-foreground",children:c.venue})]}),u.map(p=>e.jsx("td",{className:"whitespace-nowrap px-2 py-2 text-right tabular-nums",children:c[p.key]?p.negative?`−${ft(c[p.key])}`:ft(c[p.key]):""},p.key)),e.jsx("td",{className:"whitespace-nowrap px-4 py-2 text-right font-medium tabular-nums",children:ft(l)})]},`ps-${c.showId}`)})}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"border-t font-medium",children:[e.jsx("td",{className:"px-4 py-2 text-muted-foreground",children:"Totals"}),u.map(c=>e.jsx("td",{className:"whitespace-nowrap px-2 py-2 text-right tabular-nums",children:r[c.key]?c.negative?`−${ft(r[c.key])}`:ft(r[c.key]):""},c.key)),e.jsx("td",{className:"whitespace-nowrap px-4 py-2 text-right tabular-nums",children:ft(u.reduce((c,l)=>c+(l.negative?-r[l.key]:r[l.key]),0))})]})})]}),r.misc!==0&&e.jsxs("p",{className:"px-4 py-2 text-[11px] text-muted-foreground",children:["Per-show totals exclude Misc (",ft(r.misc),"), which is added to your run total."]})]})]})}function Ju(){const{data:t=[],isLoading:s}=lh(),n=jc(),r=h.useMemo(()=>[...t].sort((a,o)=>{const i=a.lastShowDate?new Date(a.lastShowDate).getTime():0;return(o.lastShowDate?new Date(o.lastShowDate).getTime():0)-i}
3),[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-tight",children:"Your pay"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your own pay for every run you worked. Read-only."})]}),e.jsx($i,{quote:n.data,isError:n.isError,isLoading:n.isLoading,financial:!0}),n.data?.pricePerGallon==null&&!n.isLoading&&t.length>0&&e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400",role:"status",children:"Your run profit bonus and pay may change when a national diesel price becomes available. Recorded actual fuel expenses remain included."}),s?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed py-16 text-center text-muted-foreground",children:[e.jsx(Np,{className:"mx-auto mb-3 h-10 w-10 opacity-20"}),e.jsx("p",{className:"font-medium",children:"No run pay yet."}),e.jsx("p",{className:"text-sm",children:"Runs you've worked will show up here once they're set up."})]}):e.jsx("div",{className:"space-y-4",children:r.map(a=>e.jsx(Qb,{run:a},a.runId))})]})}function Zb({supportAct:t}){return t.category==="local_guest"?e.jsxs("div",{className:"min-h-[100dvh] bg-background",children:[e.jsx(ac,{name:Ue(t)}),e.jsx("main",{className:"container mx-auto px-4 py-8 md:px-6",children:e.jsx(Mi,{})})]}):e.jsxs("div",{className:"min-h-[100dvh] bg-background",children:[e.jsx(ac,{name:Ue(t)}),e.jsx("main",{className:"container mx-auto px-4 py-8 md:px-6",children:e.jsxs(Yr,{defaultValue:"profile",children:[e.jsxs(Qr,{className:"mb-6",children:[e.jsx(Le,{value:"profile",children:"My Profile"}),e.jsx(Le,{value:"calendar",children:"Calendar"}),e.jsx(Le,{value:"itinerary",children:"Itinerary"}),e.jsx(Le,{value:"pay",children:"Pay"})]}),e.jsx(Ce,{value:"profile",children:e.jsx(Mi,{})}),e.jsx(Ce,{value:"calendar",children:e.jsx(Wb,{})}),e.jsx(Ce,{value:"itinerary",children:e.jsx(Yb,{})}),e.jsx(Ce,{value:"pay",children:e.jsx(Ju,{})})]})})]})}const Xb=["Book","Shirt","Sticker","Album","Other"],oc={name:"",nickname:"",type:"Other",priceDollars:"",costDollars:"",currentlySelling:!0,ownerActId:null,ownerGuest:!1};function Di(t){const s=t.category==="tour_manager"?"tour manager":t.category==="local_guest"?"local guest":"support act";return`${t.firstName} ${t.lastName} (${s})`}function Jb({supportActs:t,value:s,onChange:n}){const[r,a]=h.useState(!1),o=h.useMemo(()=>{const u=c=>c==="tour_manager"?0:c==="support"?1:2;return[...t].filter(c=>c.category!=="local_guest").sort((c,l)=>{const p=u(c.category)-u(l.category);return p!==0?p:`${c.firstName} ${c.lastName}`.localeCompare(`${l.firstName} ${l.lastName}`)})},[t]),i=s.ownerActId==null?null:t.find(u=>u.id===s.ownerActId),d=s.ownerActId!=null?i?`${i.firstName} ${i.lastName}`.trim():"Unknown owner":s.ownerGuest?"Guest":"Steve (counts in reports)";return e.jsxs(sa,{open:r,onOpenChange:a,children:[e.jsx(na,{asChild:!0,children:e.jsxs(F,{type:"button",variant:"outline",role:"combobox","aria-expanded":r,id:"merch-owner",className:"w-full justify-between font-normal",children:[e.jsx("span",{className:"truncate",children:d}),e.jsx(Yn,{className:"h-4 w-4 opacity-50 shrink-0"})]})}),e.jsx(sr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(rr,{children:[e.jsx(ar,{placeholder:"Search owner..."}),e.jsxs(ir,{children:[e.jsx(or,{children:"No matches."}),e.jsxs(aa,{children:[e.jsx(os,{value:"Steve (counts in reports)",onSelect:()=>{n({ownerActId:null,ownerGuest:!1}),a(!1)},children:"Steve (counts in reports)"}),e.jsx(os,{value:"Guest",onSelect:()=>{n({ownerActId:null,ownerGuest:!0}),a(!1)},children:"Guest"}),o.map(u=>{const c=`${u.firstName} ${u.lastName}`.trim();return e.jsx(os,{value:c,onSelect:()=>{n({ownerActId:u.id,ownerGuest:!1}),a(!1)},children:Di(u)},u.id)})]})]})]})})]})}function ew(){const{toast:t}=Ye(),s=nt(),{data:n=[],isLoading:r}=Fi(),{data:a=[]}=Bn(),o=h.useMemo(()=>new Map(a.map(V=>[V.id,V])),[a]),[i,d]=h.useState(!1),[u,c]=h.useState(null),[l,p]=h.useState(oc),[g,v]=h.useState(null),[w,A]=h.useState(!1),[N,I]=h.useState("name"),[C,y]=h.useState("asc"),T=V=>{V===N?y(ue=>ue==="asc"?"desc":"asc"):(I(V),y("asc"))},L=w?n:n.filter(V=>V.currentlySelling),O=n.length-L.length,q=h.useMemo(()=>{const V=C==="asc"?1:-1,ue=X=>X.toLowerCase(),$=X=>X.ownerActId!=null?(()=>{const D=o.get(X.ownerActId);return D?Di(D):""})():X.ownerGuest?"Guest":"Steve",se=(X,D)=>X==null&&D==null?0:X==null?1:D==null?-1:(X-D)*V;return[...L].sort((X,D)=>{let J=0;
3switch(N){case"name":J=ue(X.name).localeCompare(ue(D.name))*V;break;case"nickname":J=ue(X.nickname??"").localeCompare(ue(D.nickname??""))*V;break;case"type":J=ue(X.type).localeCompare(ue(D.type))*V;break;case"owner":J=ue($(X)).localeCompare(ue($(D)))*V;break;case"price":J=se(X.priceCents??null,D.priceCents??null);break;case"cost":J=se(X.costCents??null,D.costCents??null);break;case"selling":J=(Number(X.currentlySelling)-Number(D.currentlySelling))*V;break}return J!==0?J:X.name.localeCompare(D.name)})},[L,N,C,o]),z=()=>s.invalidateQueries({queryKey:Vi()}),x=Km({mutation:{onSuccess:()=>{z(),d(!1),t({title:"Merch item added"})},onError:()=>t({title:"Could not save item",variant:"destructive"})}}),j=zm({mutation:{onSuccess:()=>{z(),d(!1),t({title:"Merch item updated"})},onError:()=>t({title:"Could not save item",variant:"destructive"})}}),E=Hm({mutation:{onSuccess:()=>{z(),v(null),t({title:"Merch item deleted"})},onError:()=>t({title:"Could not delete item",variant:"destructive"})}}),W=()=>{c(null),p(oc),d(!0)},ie=V=>{c(V.id),p({name:V.name,nickname:V.nickname??"",type:V.type,priceDollars:V.priceCents!=null?(V.priceCents/100).toString():"",costDollars:V.costCents!=null?(V.costCents/100).toString():"",currentlySelling:V.currentlySelling,ownerActId:V.ownerActId??null,ownerGuest:V.ownerGuest??!1}),d(!0)},[R,re]=h.useState(null),H=V=>{re(V.id),j.mutate({id:V.id,data:{name:V.name,nickname:V.nickname??null,type:V.type,priceCents:V.priceCents??null,costCents:V.costCents??null,currentlySelling:!V.currentlySelling,ownerActId:V.ownerActId??null,ownerGuest:V.ownerGuest??!1}},{onSettled:()=>re(null)})},oe=()=>{const V=l.priceDollars.trim(),ue=V===""?null:Math.round(Number(V)*100),$=l.costDollars.trim(),se=$===""?null:Math.round(Number($)*100),X={name:l.name.trim(),nickname:l.nickname.trim()||null,type:l.type,priceCents:ue,costCents:se,currentlySelling:l.currentlySelling,ownerActId:l.ownerActId,ownerGuest:l.ownerActId!=null?!1:l.ownerGuest};u!=null?j.mutate({id:u,data:X}):x.mutate({data:X})},te=x.isPending||j.isPending,ce=(V,ue,$)=>e.jsx(U,{className:$==="right"?"text-right":void 0,children:e.jsxs("button",{type:"button",onClick:()=>T(ue),className:`inline-flex items-center gap-1 hover:text-foreground ${$==="right"?"flex-row-reverse":""} ${N===ue?"text-foreground":""}`,children:[V,N===ue?C==="asc"?e.jsx(Oi,{className:"h-3.5 w-3.5"}):e.jsx(It,{className:"h-3.5 w-3.5"}):e.jsx(Yn,{className:"h-3.5 w-3.5 opacity-40"})]})});return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-black uppercase tracking-tight",children:"Show Merch"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Catalog of items sold at shows. Currently-selling items appear as quantity inputs in the show editor."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"mr-2 flex items-center gap-2",children:[e.jsx($r,{id:"show-discontinued",checked:w,onCheckedChange:A}),e.jsxs(Z,{htmlFor:"show-discontinued",className:"text-sm",children:["Show discontinued",O>0&&!w?` (${O})`:""]})]}),e.jsxs(F,{onClick:W,children:[e.jsx(gt,{className:"mr-1 h-4 w-4"})," Add item"]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[ce("Name","name"),ce("Nickname","nickname"),ce("Type","type"),ce("Owner","owner"),ce("Price","price","right"),ce("Cost","cost","right"),ce("Selling","selling"),e.jsx(U,{className:"text-right",children:"Actions"})]})}),e.jsxs(De,{children:[q.map(V=>e.jsxs(he,{children:[e.jsx(_,{className:"font-medium",children:V.name}),e.jsx(_,{className:"text-muted-foreground",children:V.nickname||"—"}),e.jsx(_,{children:V.type}),e.jsx(_,{className:"text-muted-foreground",children:V.ownerActId!=null?(()=>{const ue=o.get(V.ownerActId);return ue?Di(ue):"—"})():V.ownerGuest?"Guest":"Steve"}),e.jsx(_,{className:"text-right tabular-nums",children:V.priceCents!=null?`$${(V.priceCents/100).toFixed(2)}`:"—"}),e.jsx(_,{className:"text-right tabular-nums",children:V.costCents!=null?`$${(V.costCents/100).toFixed(2)}`:"—"}),e.jsx(_,{children:e.jsx("button",{type:"button",onClick:()=>H(V),disabled:R===V.id,title:"Click to toggle",className:"disabled:opacity-50",children:V.currentlySelling?e.jsx(it,{variant:"outline",className:"cursor-pointer hover:bg-accent",children:"Selling"}):e.jsx(it,{variant:"secondary",className:"cursor-pointer text-muted-foreground hover:bg-accent",children:"No"})})}),e.jsxs(_,{className:"text-right",children:[e.jsx(F,{variant:"ghost",size:"icon",onClick:()=>ie(V),children:e.jsx(En,{className:"h-4 w-4"})}),e.jsx(F,{variant:"ghost",size:"icon",onClick:()=>v(V.id),children:e.jsx(ls,{className:"h-4 w-4 text-destructive"})})]})]},V.id)),!r&&q.length===0?e.jsx(he,{children:e.jsx(_,{colSpan:8,className:"py-8 text-center text-muted-foreground",children:n.length===0?"N
3o merch items yet.":"No currently-selling items. Toggle “Show discontinued” to see the rest."})}):null]})]})}),e.jsx(Ze,{open:i,onOpenChange:d,children:e.jsxs(Xe,{children:[e.jsx(Je,{children:e.jsx(et,{children:u!=null?"Edit merch item":"Add merch item"})}),e.jsxs("div",{className:"grid gap-4 py-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"merch-name",children:"Name"}),e.jsx(ne,{id:"merch-name",value:l.name,onChange:V=>p({...l,name:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"merch-nickname",children:"Nickname"}),e.jsx(ne,{id:"merch-nickname",placeholder:"Short label for column headings (optional)",value:l.nickname,onChange:V=>p({...l,nickname:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"merch-type",children:"Type"}),e.jsxs(ns,{value:l.type,onValueChange:V=>p({...l,type:V}),children:[e.jsx(rs,{id:"merch-type",children:e.jsx(as,{})}),e.jsx(is,{children:Xb.map(V=>e.jsx(Ge,{value:V,children:V},V))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"merch-owner",children:"Owner"}),e.jsx(Jb,{supportActs:a,value:{ownerActId:l.ownerActId,ownerGuest:l.ownerGuest},onChange:V=>p({...l,...V})}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Tour-manager, support-act, and Guest merch is tracked per show but excluded from Steve's reports."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"merch-price",children:"Price (USD)"}),e.jsx(ne,{id:"merch-price",type:"number",step:"0.01",min:"0",placeholder:"Optional",value:l.priceDollars,onChange:V=>p({...l,priceDollars:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Z,{htmlFor:"merch-cost",children:"Cost (USD)"}),e.jsx(ne,{id:"merch-cost",type:"number",step:"0.01",min:"0",placeholder:"Optional — unit cost for profit",value:l.costDollars,onChange:V=>p({...l,costDollars:V.target.value})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Z,{htmlFor:"merch-selling",children:"Currently selling"}),e.jsx($r,{id:"merch-selling",checked:l.currentlySelling,onCheckedChange:V=>p({...l,currentlySelling:V})})]})]}),e.jsxs(ut,{children:[e.jsx(F,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(F,{onClick:oe,disabled:te||l.name.trim()==="",children:te?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})}),e.jsx(Un,{open:g!=null,onOpenChange:V=>!V&&v(null),children:e.jsxs(_n,{children:[e.jsxs(qn,{children:[e.jsx(Gn,{children:"Delete this merch item?"}),e.jsx(Kn,{children:"This removes it from the catalog and from every show's recorded sales."})]}),e.jsxs(zn,{children:[e.jsx(Hn,{children:"Cancel"}),e.jsx(Wn,{onClick:()=>g!=null&&E.mutate({id:g}),children:"Delete"})]})]})})]})}function tw(){return new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date)}function sw(t){const s=new Date(Date.now()-t*24*60*60*1e3);return new Intl.DateTimeFormat("en-CA",{timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit"}).format(s)}function nw(){const{toast:t}=Ye(),s=nt(),{data:n=[],isLoading:r}=Wm(),{data:a=[]}=Fi(),[o,i]=h.useState({}),d=h.useRef(!1);h.useEffect(()=>{if(d.current||n.length===0)return;const x={};for(const j of n)x[j.catalogObjectId]=j.merchId??null;i(x),d.current=!0},[n]);const u=h.useMemo(()=>new Map(a.map(x=>[x.id,x])),[a]),c=h.useMemo(()=>{const x=new Set(Object.values(o).filter(j=>j!=null));return a.filter(j=>j.currentlySelling||x.has(j.id))},[a,o]),l=h.useMemo(()=>d.current?n.some(x=>(o[x.catalogObjectId]??null)!==(x.merchId??null)):!1,[n,o]),p=h.useMemo(()=>[...n].sort((x,j)=>{const E=x.merchId!=null?1:0,W=j.merchId!=null?1:0;return E!==W?E-W:x.itemName.localeCompare(j.itemName)}),[n]),g=xc({mutation:{onSuccess:()=>{s.invalidateQueries({queryKey:Wa()}),d.current=!1,t({title:"Square mapping saved"})},onError:()=>t({title:"Could not save mapping",variant:"destructive"})}}),v=()=>{const x=n.map(j=>({squareCatalogObjectId:j.catalogObjectId,squareItemName:j.variationName?`${j.itemName} – ${j.variationName}`:j.itemName,merchId:o[j.catalogObjectId]??null}));g.mutate({data:{mappings:x}})},w=n.filter(x=>x.merchId==null).length,A=Ym({mutation:{onSuccess:x=>{s.invalidateQueries({queryKey:Wa()}),s.invalidateQueries({queryKey:Vi()}),d.current=!1,t({title:x.created>0?`Created ${x.created} discontinued item${x.created===1?"":"s"}`:"Nothing to create — all items are mapped"})},onError:()=>t({title:"Could not create items for unmapped rows",variant:"destructive"})}}),[N,I]=h.useState(()=>sw(1)),[C,y]=h.useState(()=>tw()),[T,L]=h.useState(null),O=Qm({mutation:{onSuccess:x=>{L(x),s.invalidateQueries({queryKey:Qe()}),t({title:"Square sync complete",description:`${x.rowsWritten} rows written across ${x.shows.length} shows.`})},onError:()=>t({title:"Square sync failed",variant:"destructive"})}}),q=()=>{L(null),O.mutate({data:{startDate:N,endDate:C}})},z=n.filter(x=>(o[x.catalogObjectId]??null)!=null).length;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-black uppercase tracking-tight",children:"Square Sync"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Map Square catalog items to show-merch items, then pull credit-card sales by date into each show. Syncing overwrites the credit-card column per show + item; cash columns are preserved."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 font-display text-lg font-black uppercase tracking-tight",children:"Pull Sales"}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"sq-start",className:"text-sm",children:"Start show date"}),e.jsx(ne,{id:"sq-start",type:"date",value:N,onChange:x=>I(x.target.value),className:"w-44"})]}),e.jsxs("div",{children:[e.jsx(Z,{htmlFor:"sq-end",className:"text-sm",children:"End show date"}),e.jsx(ne,{id:"sq-end",type:"date",value:C,onChange:x=>y(x.target.value),className:"w-44"})]}),e.jsxs(F,{onClick:q,disabled:O.isPending,children:[O.isPending?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Sync Square sales"]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Select dates as displayed in the show calendar. Merch counts only all-card orders; tips count all tenders. Sales use 6 AM–6 AM in the venue’s city timezone (Eastern if unknown). Same-day sales go to the first show; off-day sales go to the closest preceding show. Only selected show dates are updated; cash quantities are preserved."})]}),T?e.jsx(rw,{result:T}):null,e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-lg font-black uppercase tracking-tight",children:"Item Mapping"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[z," of ",n.length," Square items mapped. Unmapped items are ignored by the sync."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(F,{variant:"outline",onClick:()=>A.mutate(),disabled:w===0||A.isPending,title:"Creates a discontinued show-merch item for each unmapped Square item, then maps it. Edit or delete them afterward.",children:[A.isPending?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Create items for ",w," unmapped"]}),e.jsxs(F,{onClick:v,disabled:!l||g.isPending,children:[g.isPending?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save mapping"]})]})]}),r?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"})," Loading Square catalog…"]}):e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Square item"}),e.jsx(U,{className:"w-32",children:"Price"}),e.jsx(U,{className:"w-72",children:"Maps to show-merch item"})]})}),e.jsx(De,{children:p.map(x=>{const j=o[x.catalogObjectId]??null,E=j!=null&&!u.has(j);return e.jsxs(he,{children:[e.jsxs(_,{className:"font-medium",children:[x.itemName,x.variationName?e.jsxs("span",{className:"text-muted-foreground",children:[" ","– ",x.variationName]}):null]}),e.jsx(_,{children:x.priceCents!=null?`$${(x.priceCents/100).toFixed(2)}`:"—"}),e.jsx(_,{children:e.jsxs(ns,{value:j==null?"none":String(j),onValueChange:W=>i(ie=>({...ie,[x.catalogObjectId]:W==="none"?null:Number(W)})),children:[e.jsx(rs,{children:e.jsx(as,{placeholder:"Ignored"})}),e.jsxs(is,{children:[e.jsx(Ge,{value:"none",children:"Ignore (no mapping)"}),E?e.jsxs(Ge,{value:String(j),children:["(deleted item #",j,")"]}):null,c.map(W=>e.jsxs(Ge,{value:String(W.id),children:[W.name,W.nickname?` (${W.nickname})`:"",W.currentlySelling?"":" — discontinued"]},W.id))]})]})})]},x.catalogObjectId)})})]})})]}),e.jsx(iw,{merch:a,merchById:u})]})}function rw({result:t}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-4",children:[e.jsx("h3",{className:"mb-2 font-display text-lg font-black uppercase tracking-tight",children:"Result"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1 text-sm sm:grid-cols-3",children:[e.jsxs("div",{children:["Orders fetched: ",e.jsx("strong",{children:t.ordersFetched})]}),e.jsxs("div",{children:["Rows written: ",e.jsx("strong",{children:t.rowsWritten})]}),e.jsxs("div",{children:["Card units matched: ",e.jsx("strong",{children:t.matchedCardUnits})]}),e.jsxs("div",{children:["Unmapped card units: ",e.jsx("strong",{children:t.unmappedCardUnits})]}),e.jsxs("div",{children:["Non-card units: ",e.jsx("strong",{children:t.nonCardUnits})]})]})]}),t.shows.length>0?e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Show"}),e.jsx(U,{children:"Show date / sales timezone"}),e.jsx(U,{children:"Items written (card qty)"})]})}),e.jsx(De,{children:t.shows.map(s=>e.jsxs(he,{children:[e.jsxs(_,{className:"font-medium",children:[s.venue,e.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.city]})]}),e.jsxs(_,{children:[s.date??"—",e.jsx("div",{className:"text-xs text-muted-foreground",children:s.timeZone})]}),e.jsx(_,{children:s.items.map(n=>`${n.name}: ${n.cardQty}`).join(", ")})]},s.showId))})]})}):null,t.unmatched.length>0?e.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50/50 p-4",children:[e.jsxs("h4",{className:"mb-1 font-semibold text-amber-900",children:["Unmatched orders (",t.unmatched.length,")"]}),e.jsx("p",{className:"mb-2 text-sm text-amber-800",children:"Card orders with mapped items before any loaded show’s sales window or showtime. These were not written anywhere. Timestamps below are UTC."}),e.jsx("div",{className:"max-h-48 overflow-auto text-sm",children:t.unmatched.map(s=>e.jsxs("div",{className:"text-amber-900",children:[new Date(s.createdAt).toISOString().replace("T"," ").replace("Z"," UTC")," — ",s.cardUnits," unit(s)"]},s.orderId))})]}):null,t.ambiguous.length>0?e.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50/50 p-4",children:[e.jsxs("h4",{className:"mb-1 font-semibold text-amber-900",children:["Ambiguous orders (",t.ambiguous.length,")"]}),e.jsx("p",{className:"mb-2 text-sm text-amber-800",children:"Card orders on days with more than one show. Skipped — attribution is unclear."}),e.jsx("div",{className:"max-h-48 overflow-auto text-sm",children:t.ambiguous.map(s=>e.jsxs("div",{className:"text-amber-900",children:[new Date(s.createdAt).toISOString().replace("T"," ").replace("Z"," UTC")," — shows"," ",s.showIds.join(", ")
3]},s.orderId))})]}):null]})}function aw(t,s){if(!t)return null;const n=i=>i.toLowerCase().replace(/[^a-z0-9]+/g," ").trim(),r=n(t);if(!r)return null;const a=s.find(i=>n(i.name)===r);if(a)return a.id;const o=s.find(i=>{const d=n(i.name);return d.length>2&&(r.includes(d)||d.includes(r))});return o?o.id:null}function lc(t){const s=new Date(t);return Number.isNaN(s.getTime())?"—":s.toLocaleDateString(void 0,{timeZone:"America/New_York",year:"2-digit",month:"short",day:"numeric"})}function iw({merch:t,merchById:s}){const{toast:n}=Ye(),r=nt(),[a,o]=h.useState(!1),{data:i=[],isFetching:d,isError:u,refetch:c}=Nh(void 0,{query:{enabled:a,queryKey:Fh()}}),[l,p]=h.useState({}),g=h.useRef(null);h.useEffect(()=>{if(i.length===0||g.current===i)return;const x={};for(const j of i)x[j.catalogObjectId]=j.merchId??aw(j.name,t);p(x),g.current=i},[i,t]);const v=h.useMemo(()=>{const x=new Set(Object.values(l).filter(j=>j!=null));return t.filter(j=>j.currentlySelling||x.has(j.id))},[t,l]),w=h.useMemo(()=>g.current!==i?!1:i.some(x=>(l[x.catalogObjectId]??null)!==(x.merchId??null)),[i,l]),A=xc({mutation:{onSuccess:()=>n({title:"Deleted-item mappings saved"}),onError:()=>n({title:"Could not save mapping",variant:"destructive"})}}),[N,I]=h.useState({}),[C,y]=h.useState(new Set),T=h.useRef({}),L=Ch({mutation:{onError:()=>n({title:"Could not add item to Square catalog",variant:"destructive"})}}),O=x=>{if(C.has(x.catalogObjectId)||N[x.catalogObjectId])return;const j=x.name?.trim()||x.catalogObjectId,E=l[x.catalogObjectId]??null,W=T.current[x.catalogObjectId]??=crypto.randomUUID();y(ie=>new Set(ie).add(x.catalogObjectId)),L.mutate({data:{name:j,priceCents:x.priceCents,merchId:E,idempotencyKey:W}},{onSuccess:ie=>{I(R=>({...R,[x.catalogObjectId]:!0})),E!=null&&ie.merchId==null?n({title:`Added "${j}", but the mapping didn't save`,description:"Map it in the Item Mapping table above.",variant:"destructive"}):n({title:`Added "${j}" to Square catalog`}),r.invalidateQueries({queryKey:Wa()})},onSettled:()=>y(ie=>{const R=new Set(ie);return R.delete(x.catalogObjectId),R})})},q=()=>{const x=i.filter(j=>(l[j.catalogObjectId]??null)!==(j.merchId??null)).map(j=>({squareCatalogObjectId:j.catalogObjectId,squareItemName:j.name??j.catalogObjectId,merchId:l[j.catalogObjectId]??null}));x.length!==0&&A.mutate({data:{mappings:x}})},z=()=>{a?c():o(!0)};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-lg font-black uppercase tracking-tight",children:"Deleted Items"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Square items deleted from the catalog that still have sales on record. Map one to an existing merch item and its card sales get counted the next time you sync that date range. Use “Add to catalog” to re-create the item in Square (using the mapping you picked) so future sales track automatically."})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs(F,{variant:"outline",onClick:z,disabled:d,children:[d?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,a?"Rescan history":"Find deleted items"]}),a&&i.length>0?e.jsxs(F,{onClick:q,disabled:!w||A.isPending,children:[A.isPending?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save mappings"]}):null]})]}),u?e.jsx("p",{className:"text-sm text-destructive",children:"Could not scan Square sales history."}):null,a&&!d&&!u&&i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No deleted items found in the last two years of sales."}):null,i.length>0?e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Deleted Square item"}),e.jsx(U,{className:"w-24",children:"Price"}),e.jsx(U,{className:"w-28",children:"Units (card)"}),e.jsx(U,{className:"w-40",children:"Sold"}),e.jsx(U,{className:"w-72",children:"Maps to show-merch item"}),e.jsx(U,{className:"w-40",children:"Square catalog"})]})}),e.jsx(De,{children:i.map(x=>{const j=l[x.catalogObjectId]??null,E=j!=null&&!s.has(j),W=N[x.catalogObjectId]===!0,ie=C.has(x.catalogObjectId);return e.jsxs(he,{children:[e.jsx(_,{className:"font-medium",children:x.name??e.jsxs("span",{className:"text-muted-foreground",children:["(unnamed · ",x.catalogObjectId.slice(0,8),"…)"]})}),e.jsx(_,{children:x.priceCents!=null?`$${(x.priceCents/100).toFixed(2)}`:"—"}),e.jsxs(_,{children:[x.unitsSold,e.jsxs("span",{className:"text-muted-foreground",children:[" ","(",x.cardUnitsSold,")"]})]}),e.jsxs(_,{className:"text-sm text-muted-foreground",children:[lc(x.firstSeen)," –"," ",lc(x.lastSeen)]}),e.jsx(_,{children:e.jsxs(ns,{value:j==null?"none":String(j),onValueChange:R=>p(re=>({...re,[x.catalogObjectId]:R==="none"?null:Number(R)})),children:[e.jsx(rs,{children:e.jsx(as,{placeholder:"Ignored"})}),e.jsxs(is,{children:[e.jsx(Ge,{value:"none",children:"Ignore (no mapping)"}),E?e.jsxs(Ge,{value:String(j),children:["(deleted item #",j,")"]}):null,v.map(R=>e.jsxs(Ge,{value:String(R.id),children:[R.name,R.nickname?` (${R.nickname})`:"",R.currentlySelling?"":" — discontinued"]},R.id))]})]})}),e.jsx(_,{children:W?e.jsx("span",{className:"text-sm text-muted-foreground",children:"Added"}):e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>O(x),disabled:ie,title:"Re-create this item in the live Square catalog",children:[ie?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Add to catalog"]})})]},x.catalogObjectId)})})]})}):null]})}function Mn(t){const s=t.date?new Intl.DateTimeFormat("en-US",{timeZone:"America/Ne
3w_York",year:"2-digit",month:"numeric",day:"numeric"}).format(new Date(t.date)):"",n=t.city??"";return s?`${n} — ${s}`:n}function ow({value:t,onChange:s,shows:n,showById:r}){const[a,o]=h.useState(!1),[i,d]=h.useState(""),u=t!=null?r.get(t):void 0,c=h.useMemo(()=>{const p=i.trim().toLowerCase();return(p?n.filter(v=>Mn(v).toLowerCase().includes(p)):n).slice(0,50)},[n,i]),l=t==null?"Ignore (no mapping)":u?Mn(u):`(deleted show #${t})`;return e.jsxs(sa,{open:a,onOpenChange:p=>{o(p),p||d("")},children:[e.jsx(na,{asChild:!0,children:e.jsxs(F,{variant:"outline",role:"combobox","aria-expanded":a,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:"truncate",children:l}),e.jsx(Yn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(sr,{className:"w-[22rem] p-0",align:"start",children:e.jsxs(rr,{shouldFilter:!1,children:[e.jsx(ar,{placeholder:"Search shows…",value:i,onValueChange:d}),e.jsxs(ir,{children:[e.jsx(or,{children:"No shows found."}),e.jsxs(os,{value:"__ignore",onSelect:()=>{s(null),o(!1)},children:[e.jsx(Xa,{className:ht("mr-2 h-4 w-4",t==null?"opacity-100":"opacity-0")}),"Ignore (no mapping)"]}),c.map(p=>e.jsxs(os,{value:String(p.id),onSelect:()=>{s(p.id),o(!1)},children:[e.jsx(Xa,{className:ht("mr-2 h-4 w-4",t===p.id?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:Mn(p)})]},p.id))]})]})})]})}function lw({campaign:t,override:s,onSaved:n}){const{toast:r}=Ye(),a=s?.dailyBudgetCents??t.dailyBudgetCents,o=s?.lifetimeBudgetCents??t.lifetimeBudgetCents,i=a!=null?"daily":o!=null?"lifetime":null,d=i==="daily"?a:o,[u,c]=h.useState(!1),[l,p]=h.useState(""),g=Rh(),v=()=>{p(d!=null?(d/100).toFixed(2):""),c(!0)},w=()=>{const A=Number.parseFloat(l);if(!Number.isFinite(A)||A<=0){r({title:"Enter a budget greater than $0",variant:"destructive"});return}const N=Math.round(A*100),I=i==="lifetime"?{lifetimeBudgetCents:N}:{dailyBudgetCents:N};g.mutate({campaignId:t.campaignId,data:I},{onSuccess:C=>{n(t.campaignId,{dailyBudgetCents:C.dailyBudgetCents,lifetimeBudgetCents:C.lifetimeBudgetCents}),c(!1),r({title:"Budget updated"})},onError:C=>{const y=C?.data?.message;r({title:"Couldn't update budget",description:y??"Facebook rejected the change. The token may lack the ads_management permission.",variant:"destructive"})}})};return i==null?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Ad-set level — not editable here"}):u?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"$"}),e.jsx(ne,{type:"number",min:"0.01",step:"0.01",value:l,onChange:A=>p(A.target.value),className:"h-8 w-24",autoFocus:!0}),e.jsx(F,{size:"sm",onClick:w,disabled:g.isPending,children:g.isPending?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"}),e.jsx(F,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:g.isPending,children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"whitespace-nowrap",children:["$",((d??0)/100).toFixed(2),e.jsx("span",{className:"text-xs text-muted-foreground",children:i==="daily"?" / day":" lifetime"})]}),e.jsx(F,{size:"sm",variant:"ghost",onClick:v,children:"Edit"})]})}function cw(){const{toast:t}=Ye(),s=nt(),{data:n,isLoading:r}=Sh(),a=kh({mutation:{onSuccess:()=>s.invalidateQueries({queryKey:Ao()}),onError:()=>t({title:"Could not save setting",variant:"destructive"})}}),o=Th({mutation:{onSuccess:v=>{s.invalidateQueries({queryKey:Ao()}),s.invalidateQueries({queryKey:Qe()});const w=v.budget;t({title:"Automation run complete",description:`${w.budgetUpdates} budget change(s), ${w.paused} paused, ${w.resumed} resumed${w.errors>0?`, ${w.errors} error(s)`:""}.`,variant:w.errors>0?"destructive":void 0})},onError:()=>t({title:"Automation run failed",variant:"destructive"})}}),[i,d]=h.useState(!1),u=n?.log??[],c=n?.lastRun??null,l=v=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"America/New_York"}).format(new Date(v)),p=v=>v==null?"—":`$${(v/100).toFixed(2)}`,g=v=>{switch(v.action){case"budget_update":return`Budget ${p(v.oldBudgetCents)} → ${p(v.newBudgetCents)}`;case"pause":return"Paused";
3case"resume":return"Resumed";default:return"Error"}};return e.jsxs("div",{className:"rounded-md border p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-lg font-black uppercase tracking-tight",children:"Daily Automation"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Once a day, syncs spend into shows and sets each ad set's daily budget to the show's recommended spend (75% images / 25% video). $0 recommendations pause the campaign; campaigns we paused resume automatically when the recommendation comes back. Manual pauses are left alone."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{checked:n?.enabled??!1,disabled:r||a.isPending,onCheckedChange:v=>a.mutate({data:{enabled:v}})}),e.jsx("span",{className:"text-sm",children:n?.enabled?"On":"Off"})]}),e.jsxs(F,{size:"sm",variant:"outline",disabled:o.isPending,onClick:()=>o.mutate(),children:[o.isPending?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Run now"]})]})]}),e.jsx("div",{className:"mt-3 text-sm text-muted-foreground",children:c?e.jsxs(e.Fragment,{children:["Last run ",l(c.ranAt)," ET",c.source?` (${c.source})`:""," ·"," ",c.campaignsConsidered," campaign(s) checked ·"," ",c.budgetUpdates," budget change(s) · ",c.paused," paused ·"," ",c.resumed," resumed",c.errors>0?e.jsxs("span",{className:"text-red-600",children:[" · ",c.errors," error(s)"]}):null]}):r?"Loading…":"Hasn't run yet."}),u.length>0?e.jsxs("div",{className:"mt-3",children:[e.jsx(F,{size:"sm",variant:"ghost",onClick:()=>d(v=>!v),children:i?"Hide change log":`Show change log (${u.length})`}),i?e.jsx("div",{className:"mt-2 overflow-x-auto",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"When (ET)"}),e.jsx(U,{children:"Campaign"}),e.jsx(U,{children:"Action"}),e.jsx(U,{children:"Detail"})]})}),e.jsx(De,{children:u.map(v=>e.jsxs(he,{children:[e.jsxs(_,{className:"whitespace-nowrap align-top text-xs",children:[l(v.ranAt),e.jsx("div",{className:"text-muted-foreground",children:v.source})]}),e.jsx(_,{className:"align-top text-xs",children:v.campaignName??v.campaignId??"—"}),e.jsx(_,{className:`whitespace-nowrap align-top text-xs ${v.ok?"":"text-red-600"}`,children:g(v)}),e.jsx(_,{className:"align-top text-xs text-muted-foreground",children:v.detail})]},v.id))})]})}):null]}):null]})}function dw(){const{toast:t}=Ye(),s=nt(),{data:n,isLoading:r,isError:a,error:o,refetch:i,isFetching:d}=Zm({query:{queryKey:$h(),enabled:!1,retry:!1}}),u=n?.campaigns??[],{data:c=[]}=Wr(),l=h.useMemo(()=>[...c].sort((D,J)=>{const fe=D.date?new Date(D.date).getTime():0;return(J.date?new Date(J.date).getTime():0)-fe}),[c]),p=h.useMemo(()=>new Map(l.map(D=>[D.id,D])),[l]),g=20,[v,w]=h.useState({}),[A,N]=h.useState(new Set),[I,C]=h.useState({}),y=(D,J)=>C(fe=>({...fe,[D]:J})),[T,L]=h.useState([]);h.useEffect(()=>{if(u.length===0)return;const D={};for(const J of u)D[J.campaignId]=J.mappedShowId??(J.ignored?null:J.suggestedShowId??null);w(D),N(new Set),C({}),L(u.filter(J=>J.mappedShowId==null&&!J.ignored).slice(0,g).map(J=>J.campaignId))},[u]);const O=Xm({mutation:{onError:()=>t({title:"Could not save mapping",variant:"destructive"})}}),[q,z]=h.useState(null),x=(D,J)=>{if(D.length===0)return;z(J);const fe=D.map(P=>({campaignId:P.campaignId,campaignName:P.campaignName,showId:v[P.campaignId]??null}));O.mutate({data:{mappings:fe}},{onSuccess:()=>{N(P=>{const Q=new Set(P);for(const de of D)Q.add(de.campaignId);return Q}),t({title:D.length===1?"Campaign saved":`${D.length} campaigns saved`})},onSettled:()=>z(null)})},[j,E]=h.useState(null),W=Jm({mutation:{onSuccess:D=>{E(D),s.invalidateQueries({queryKey:Qe()}),t({title:"Ad-spend sync complete",description:`Updated fbAds on ${D.showsUpdated} show(s).`})},onError:()=>t({title:"Ad-spend sync failed",variant:"destructive"})}}),ie=()=>{E(null),W.mutate()},R=a&&o?.data?.error==="notConfigured",re=h.useMemo(()=>u.filter(D=>D.mappedShowId==null&&!D.ignored&&!A.has(D.campaignId)),[u,A]),H=h.useMemo(()=>new Map(u.map(D=>[D.campaignId,D])),[u]),oe=h.useMemo(()=>T.map(D=>H.get(D)).filter(D=>D!=null&&!A.has(D.campaignId)),[T,H,A]),te=h.useMemo(()=>new Set(T),[T]),ce=h.useMemo(()=>re.filter(D=>!te.has(D.campaignId)).slice(0,g).map(D=>D.campaignId),[re,te]),V=()=>L(ce),ue=h.useMemo(()=>u.filter(D=>D.mappedShowId!=null&&!A.has(D.campaignId)&&!te.has(D.campaignId)),[u,A,te]),$=h.useMemo(()=>u.filter(D=>A.has(D.campaignId)),[u,A]),se=h.useMemo(()=>u.filter(D=>D.ignored&&!A.has(D.campaignId)),[u,A]),X=D=>{const J=v[D.campaignId]??null,fe=D.suggestedShowId!=null?p.get(D.suggestedShowId):void 0,P=q===D.campaignId||q==="batch::current";return e.jsxs(he,{children:[e.jsxs(_,{className:"align-top font-medium",children:[D.campaignName,e.jsx("div",{className:"text-xs font-normal text-muted-foreground",children:D.endDate?`Ran until ${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(`${D.endDate}T00:00:00Z`))}`:"End date unknown"})]}),e.jsxs(_,{className:"align-top",children:["$",(D.spendCents/100).toFixed(2)]}),e.jsx(_,{className:"align-top",children:e.jsx(lw,{campaign:D,override:I[D.campaignId],onSaved:y})}),e.jsxs(_,{className:"align-top",children:[D.mappedShowId==null?D.suggestedShowId!=null?e.jsxs("div",{className:"mb-1 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Suggested: "}),e.jsx("span",{className:"font-medium",children:fe?Mn(fe):`show #${D.suggestedShowId}`}),e.jsxs("span",{className:"text-muted-foreground",children:[" ","· via ",D.suggestedVia]})]}):e.jsx("div",{className:"mb-1 text-xs text-muted-foreground",children:"No suggestion — pick a show"}):null,e.jsx(ow,{value:J,onChange:Q=>w(de=>({...de,[D.campaignId]:Q})),shows:l,showById:p})]}
3),e.jsx(_,{className:"w-28 align-top",children:e.jsxs(F,{size:"sm",variant:A.has(D.campaignId)?"secondary":"outline",disabled:O.isPending,onClick:()=>x([D],D.campaignId),children:[P?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,A.has(D.campaignId)?"Saved ✓":J==null?"Ignore":"Confirm"]})})]},D.campaignId)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-black uppercase tracking-tight",children:"Facebook Ad Spend"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Pull lifetime spend for each Facebook campaign, map each campaign to its show, then sync spend into the show's FB Ads field (feeds Net Profit). One campaign per show is assumed; if two campaigns map to the same show their spend is summed. You can also adjust a campaign's daily or lifetime budget here (requires an ",e.jsx("code",{children:"ads_management"})," ","token)."]})]}),e.jsx(cw,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(F,{onClick:()=>i(),disabled:d,children:[d?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,u.length>0?"Refresh from Facebook":"Load from Facebook"]}),u.length>0?e.jsxs("span",{className:"text-sm text-muted-foreground",children:[u.length," campaigns loaded · ",re.length," still unmapped. Unmapped campaigns are ignored by the sync."]}):null]}),R?e.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50/50 p-4 text-sm text-amber-900",children:["Facebook isn't connected yet. Add the ",e.jsx("code",{children:"META_ACCESS_TOKEN"})," ","and ",e.jsx("code",{children:"META_AD_ACCOUNT_ID"})," secrets (an access token with"," ",e.jsx("code",{children:"ads_read"}),' on the ad account), then click "Load from Facebook".']}):a?e.jsx("div",{className:"rounded-md border border-red-300 bg-red-50/50 p-4 text-sm text-red-900",children:"Couldn't load campaigns from Facebook. The token may be expired or lack access to the ad account."}):null,r||d?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4 animate-spin"})," Loading campaigns…"]}):u.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-lg font-black uppercase tracking-tight",children:"Map Campaigns"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Reviewing ",oe.length," · ",re.length," unmapped remaining",A.size>0?` · ${A.size} saved this session`:""]})]}),oe.length>0?e.jsxs(F,{onClick:()=>x(oe,"batch::current"),disabled:O.isPending,children:[q==="batch::current"?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Confirm all ",oe.length]}):null]}),oe.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Campaign"}),e.jsx(U,{className:"w-32",children:"Lifetime spend"}),e.jsx(U,{className:"w-44",children:"Budget"}),e.jsx(U,{className:"w-80",children:"Maps to show"}),e.jsx(U,{className:"w-28",children:"Action"})]})}),e.jsx(De,{children:oe.map(X)})]})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsxs(F,{variant:"outline",onClick:V,disabled:ce.length===0,children:["Find ",Math.min(g,ce.length)," more"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:ce.length>0?`${ce.length} more unmapped campaign${ce.length===1?"":"s"} after this page.`:"No more unmapped campaigns after this page."})]})]}):re.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(F,{onClick:V,children:["Find ",Math.min(g,ce.length)," to map"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[re.length," unmapped campaign",re.length===1?"":"s"," to review."]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"All campaigns reviewed — nothing left to map."}),$.length>0?e.jsxs("details",{className:"mt-4",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-muted-foreground",children:["Saved this session (",$.length,") — click to review or re-edit"]}),e.jsx("div",{className:"mt-3 rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Campaign"}),e.jsx(U,{className:"w-32",children:"Lifetime spend"}),e.jsx(U,{className:"w-44",children:"Budget"}),e.jsx(U,{className:"w-80",children:"Maps to show"}),e.jsx(U,{className:"w-28",children:"Action"})]})}),e.jsx(De,{children:$.map(X)})]})})]}):null,ue.length>0?e.jsxs("details",{className:"mt-4",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-muted-foreground",children:["Already mapped (",ue.length,") — click to review or edit"]}),e.jsx("div",{className:"mt-3 rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Campaign"}),e.jsx(U,{className:"w-32",children:"Lifetime spend"}),e.jsx(U,{className:"w-44",children:"Budget"}),e.jsx(U,{className:"w-80",children:"Maps to show"}),e.jsx(U,{className:"w-28",children:"Action"})]})}),e.jsx(De,{children:ue.map(X)})]})})]}
3):null,se.length>0?e.jsxs("details",{className:"mt-4",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-muted-foreground",children:["Ignored (",se.length,") — click to review; pick a show to un-ignore"]}),e.jsx("div",{className:"mt-3 rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Campaign"}),e.jsx(U,{className:"w-32",children:"Lifetime spend"}),e.jsx(U,{className:"w-44",children:"Budget"}),e.jsx(U,{className:"w-80",children:"Maps to show"}),e.jsx(U,{className:"w-28",children:"Action"})]})}),e.jsx(De,{children:se.map(X)})]})})]}):null]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 font-display text-lg font-black uppercase tracking-tight",children:"Sync Spend"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(F,{onClick:ie,disabled:W.isPending,children:[W.isPending?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Sync spend to shows"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Writes each mapped show's FB Ads field to the sum of its campaigns' lifetime spend. Save your mapping first."})]})]}),j?e.jsx(uw,{result:j,shows:p}):null]}):a?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Load from Facebook" to pull campaign spend.'})]})}function uw({result:t,shows:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-4",children:[e.jsx("h3",{className:"mb-2 font-display text-lg font-black uppercase tracking-tight",children:"Result"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1 text-sm sm:grid-cols-3",children:[e.jsxs("div",{children:["Campaigns fetched: ",e.jsx("strong",{children:t.campaignsFetched})]}),e.jsxs("div",{children:["Mapped campaigns: ",e.jsx("strong",{children:t.mappedCampaigns})]}),e.jsxs("div",{children:["Shows updated: ",e.jsx("strong",{children:t.showsUpdated})]}),e.jsxs("div",{children:["Frozen (past): ",e.jsx("strong",{children:t.showsLocked})]}),e.jsxs("div",{children:["Skipped (already frozen): ",e.jsx("strong",{children:t.skippedLocked})]})]})]}),t.updated.length>0?e.jsx("div",{className:"rounded-md border",children:e.jsxs(Pe,{children:[e.jsx(Me,{children:e.jsxs(he,{children:[e.jsx(U,{children:"Show"}),e.jsx(U,{className:"w-40",children:"FB Ads written"}),e.jsx(U,{className:"w-28",children:"Status"})]})}),e.jsx(De,{children:t.updated.map(n=>{const r=s.get(n.showId);return e.jsxs(he,{children:[e.jsx(_,{className:"font-medium",children:r?Mn(r):`Show #${n.showId}`}),e.jsxs(_,{children:["$",(n.fbAdsCents/100).toFixed(2)]}),e.jsx(_,{children:n.locked?e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Frozen"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Live"})})]},n.showId)})})]})}):null]})}const Ii=[{value:"products",label:"Merch"},{value:"show-merch",label:"Show Merch"},{value:"square",label:"Square Sync"}],Ei=[{value:"threads",label:"Threads"},{value:"video-memes",label:"Video"}];function Ht(){return e.jsx("div",{className:"flex min-h-64 items-center justify-center text-sm font-medium text-muted-foreground",role:"status","aria-live":"polite",children:"Loading section…"})}const cc=[{value:"shows",label:"Calendar"},{value:"report",label:"Report"},{value:"booking",label:"Booking"},{value:"runs",label:"Runs"},{value:"itinerary",label:"Itinerary"},{value:"hotel-checks",label:"Hotel Checks"},...Ii,{value:"ad-spend",label:"Ad Spend"},...Ei.map(t=>({value:t.value,label:`Memes: ${t.label}`})),{value:"support-acts",label:"Support Acts"},{value:"membership",label:"Membership"},{value:"ticketing",label:"Ticketing"},{value:"kindness",label:"Kindness Tickets"}],dc=[{value:"itinerary",label:"Itinerary"},{value:"booking",label:"Booking"},{value:"support-acts",label:"Support Acts"},{value:"profile",label:"My Profile"},{value:"pay",label:"Pay"}];function em(t,s){const[n,r]=wm(),a=n.get("section");return[t.some(d=>d.value===a&&d.value!=="hotel-checks")?a:s,d=>{!t.some(u=>u.value===d)||d==="hotel-checks"||r(u=>{const c=new URLSearchParams(u);return c.set("section",d),c})}]}function mw(){const[t,s]=em(cc,"shows"),[n,r]=h.useState(t==="shows"),[a,o]=h.useState(0);h.useEffect(()=>{t==="shows"&&r(!0)},[t]),h.useEffect(()=>{const l=()=>{s("shows"),o(p=>p+1)};return window.addEventListener("open-lineup-import",l),()=>window.removeEventListener("open-lineup-import",l)},[s]);const[,i]=jm(),d=Ii.find(l=>l.value===t),u=Ei.find(l=>l.value===t),c=l=>{if(l==="hotel-checks"){i("/admin/hotel-checks");return}s(l)};return e.jsxs("div",{className:"min-h-[100dvh] min-w-0 overflow-x-hidden bg-background",children:[e.jsx(zu,{canImpersonate:!0}),e.jsx("main",{className:"container mx-auto min-w-0 px-3 py-5 sm:px-4 md:px-6 md:py-8",children:e.jsxs(Yr,{value:t,onValueChange:s,className:"min-w-0",children:[e.jsxs("div",{className:"relative mb-5 md:hidden",children:[e.jsx("label",{htmlFor:"admin-section",className:"mb-1.5 block text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Admin section"}),e.jsx("select",{id:"admin-section",value:t,onChange:l=>c(l.target.value),className:"h-12 w-full appearance-none rounded-lg border border-input bg-background px-4 pr-10 text-base font-semibold shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20","data-testid":"select-admin-section",children:cc.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}),e.jsx(It,{className:"pointer-events-none absolute bottom-3.5 right-3.5 h-5 w-5 text-muted-foreground"})]}),e.jsx("div",{className:"mb-6 hidden w-full max-w-full md:block",children:e.jsxs(Qr,{className:"flex h-auto flex-wrap justify-start gap-1",children:[e.jsx(Le,{value:"shows",children:"Calendar"}),e.jsx(Le,{value:"report",children:"Report"}),e.jsx(Le,{value:"booking","data-testid":"tab-admin-booking",children:"Booking"}),e.jsx(Le,{value:"runs",children:"Runs"}),e.jsx(Le,{value:"itinerary",children:"Itinerary"}),e.jsx(Ys,{href:"/admin/hotel-checks",className:"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground ring-offset-background transition-all hover:text-foreground","data-testid":"link-admin-hotel-checks",children:"Hotel Checks"}),e.jsxs(Ya,{children:[e.jsxs(Qa,{className:`inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all ${d?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[d?d.label:"Merch",e.jsx(It,{className:"h-3.5 w-3.5"})]}),e.jsx(Za,{align:"start",children:Ii.map(l=>e.jsx(yn,{onSelect:()=>s(l.value),children:l.label},l.value))})]}),e.jsx(Le,{value:"ad-spend",children:"Ad Spend"}),e.jsxs(Ya,{children:[e.jsxs(Qa,{className:`inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all ${u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[u?`Memes: ${u.label}`:"Memes",e.jsx(It,{className:"h-3.5 w-3.5"})]}),e.jsx(Za,{align:"start",children:Ei.map(l=>e.jsx(yn,{onSelect:()=>s(l.value),children:l.label},l.value))})]}),e.jsx(Le,{value:"support-acts",children:"Support Acts"}),e.jsx(Le,{value:"membership",children:"Membership"}),e.jsx(Le,{value:"ticketing",children:"Ticketing"}),e.jsx(Le,{value:"kindness","data-testid":"tab-admin-kindness",children:"Kindness Tickets"})]})}),(n||t==="shows")&&e.jsx(Ce,{value:"shows",forceMount:!0,className:"data-[state=inactive]:hidden",children:e.jsx(fb,{active:t==="shows",lineupImportRequest:a})}),e.jsx(Ce,{value:"report",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Gj,{})})}),e.jsx(Ce,{value:"booking",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Ou,{})})}),e.jsx(Ce,{value:"runs",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Kj,{})})}),e.jsx(Ce,{value:"itinerary",children:e.jsx(Yu,{})}),e.jsx(Ce,{value:"products",children:e.jsx(jb,{})}),e.jsx(Ce,{value:"show-merch",children:e.jsx(ew,{})}),e.jsx(Ce,{value:"square",children:e.jsx(nw,{})}),e.jsx(Ce,{value:"ad-spend",children:e.jsx(dw,{})}),e.jsx(Ce,{value:"threads",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(zj,{})})}),e.jsx(Ce,{value:"video-memes",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Hj,{})})}),e.jsx(Ce,{value:"support-acts",children:e.jsx(Zu,{canImportLineup:!0})}),e.jsx(Ce,{value:"membership",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Wj,{})})}),e.jsx(Ce,{value:"ticketing",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Yj,{})})}),e.jsx(Ce,{value:"kindness",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Qj,{})})})]})})]})}function hw(){const[t,s]=em(dc,"itinerary"),{data:n}=Ri();return e.jsxs("div",{className:"min-h-[100dvh] min-w-0 overflow-x-hidden bg-background",children:[e.jsx(zu,{}),e.jsx("main",{className:"container mx-auto min-w-0 px-3 py-5 sm:px-4 md:px-6 md:py-8",children:e.jsxs(Yr,{value:t,onValueChange:s,className:"min-w-0",children:[e.jsxs("div",{className:"relative mb-5 md:hidden",children:[e.jsx("label",{htmlFor:"tour-manager-section",className:"mb-1.5 block text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Admin section"}),e.jsx("select",{id:"tour-manager-section",value:t,onChange:r=>s(r.target.value),className:"h-12 w-full appearance-none rounded-lg border border-input bg-background px-4 pr-10 text-base font-semibold shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20","data-testid":"select-tour-manager-section",children:dc.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))}),e.jsx(It,{className:"pointer-events-none absolute bottom-3.5 right-3.5 h-5 w-5 text-muted-foreground"})]}),e.jsxs(Qr,{className:"mb-6 hidden h-auto flex-wrap justify-start gap-1 md:flex",children:[e.jsx(Le,{value:"itinerary",children:"Itinerary"}),e.jsx(Le,{value:"booking","data-testid":"tab-tour-manager-booking",children:"Booking"}),e.jsx(Le,{value:"support-acts",children:"Support Acts"}),e.jsx(Le,{value:"profile",children:"My Profile"}),e.jsx(Le,{value:"pay",children:"Pay"})]}),e.jsx(Ce,{value:"itinerary",children:e.jsx(Yu,{})}),e.jsx(Ce,{value:"booking",children:e.jsx(h.Suspense,{fallback:e.jsx(Ht,{}),children:e.jsx(Ou,{readOnly:!!n?.impersonating})})}),e.jsx(Ce,{value:"support-acts",children:e.jsx(Zu,{})}),e.jsx(Ce,{value:"profile",children:e.jsx(Mi,{})}),e.jsx(Ce,{value:"pay",children:e.jsx(Ju,{})})]})})]})}function pw(){const{signOut:t}=Li();return e.jsxs("div",{className:"flex min-h-[100dvh] flex-col items-center justify-center gap-4 px-4 text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-black uppercase tracking-tight",children:"No access"}),e.jsx("p",{className:"max-w-md text-muted-foreground",children:"This account is not on the admin or support-act roster. Ask the site owner to add your email, then sign in again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(F,{variant:"outline",asChild:!0,children:e.jsx(Ys,{href:"/",children:"Back to site"})}),e.jsx(F,{onClick:()=>t({redirectUrl:lr||"/"}),children:"Sign out"})]})]})}function fw(){const{data:t=[]}=Bn(),[s,n]=h.useState(!1),r=h.useMemo(()=>[...t].sort((a,o)=>
3Ue(a).localeCompare(Ue(o),void 0,{sensitivity:"base"})),[t]);return e.jsxs(sa,{open:s,onOpenChange:n,children:[e.jsx(na,{asChild:!0,children:e.jsxs(F,{type:"button",variant:"outline",size:"sm",role:"combobox","aria-expanded":s,className:"h-9 w-9 p-0 sm:w-auto sm:px-3",children:[e.jsx(jn,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"sr-only sm:not-sr-only",children:"View as"})]})}),e.jsx(sr,{className:"w-72 p-0",align:"end",children:e.jsxs(rr,{children:[e.jsx(ar,{placeholder:"Search people..."}),e.jsxs(ir,{children:[e.jsx(or,{children:"No people found."}),e.jsx(aa,{children:r.map(a=>e.jsx(os,{value:`${Ue(a)} ${a.email??""}`,onSelect:()=>{n(!1),mh(a.id)},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:Ue(a)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Uu(a.category)})]})},a.id))})]})]})})]})}function gw({act:t}){return e.jsx("div",{className:"bg-amber-500 text-amber-950",children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-3 px-4 py-2 md:px-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(jn,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Viewing as ",e.jsx("span",{className:"font-bold",children:Ue(t)})," ·"," ",Uu(t.category)]})]}),e.jsxs(F,{type:"button",size:"sm",variant:"outline",className:"border-amber-950/40 bg-amber-100 hover:bg-amber-50",onClick:()=>bm(),children:[e.jsx(en,{className:"h-4 w-4 mr-1"})," Exit view"]})]})})}function xw(){const{data:t,isLoading:s}=Ri();if(s)return e.jsx("div",{className:"flex min-h-[100dvh] items-center justify-center",children:e.jsx(le,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(t?.role==="admin")return e.jsx(mw,{});if(t?.role==="support"&&t.supportAct){const n=t.supportAct.category==="tour_manager"?e.jsx(hw,{}):e.jsx(Zb,{supportAct:t.supportAct});return t.impersonating?e.jsxs("div",{className:"min-h-[100dvh]",children:[e.jsx(gw,{act:t.supportAct}),n]}):n}return e.jsx(pw,{})}const Qw=Object.freeze(Object.defineProperty({__proto__:null,default:xw},Symbol.toStringTag,{value:"Module"}));export{Yn as C,Fa as D,Ui as G,sa as P,xo as R,na as a,sr as b,$y as c,Ci as d,Vy as e,Yw as f,Ww as g,vo as h,$n as i,En as j,Qw as k,Oy as m,Ly as o,Ql as p,By as s,Fy as t,Qn as u,gu as v};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.