1import{bK as wn,cq as s,b1 as re,cG as le,cQ as G,bf as M,by as dt,o as F,bk as In,D as En,be as un,N as yt,Z as vt,P as St,R as Me,bd as An,r as Yl,bg as Jl,v as ml,t as fl,s as hl,av as hs,aB as ps,ax as xs,bj as ws,b6 as mn,b2 as Xl,aw as pl,au as er,ad as $n,ag as kn,b3 as Ps,bs as tr,ac as Pe,aD as It,ab as sr,ae as an,a1 as bn,a7 as nr,a9 as lr,a8 as rr,b8 as ir,bb as ar,b9 as or}from"./index-cg8gw9xW.js";import{ba as T,b9 as mt,bu as he,cd as Ce,aW as gs,b3 as ge,aQ as xl,aN as Fe,aV as tt,ap as js,c4 as Ee,a9 as cr,aK as Ns,aJ as He,aT as Et,X as ie,Y as dr,V as ur,bK as At,bH as mr,ay as Qe,aa as ct,bL as Pn,bM as Zn,al as fr,C as hr,aD as pr,am as xr,aU as Yn,y as on,aR as gr,b1 as cs,ca as jr,c0 as Nt,ab as kt,M as br,N as yr,ae as lt,af as rt,ac as pt,ah as bt,k as Tn,u as Gn,v as gl,l as zn,p as Mn,r as jl,q as bl,t as Fn,s as Dn,O as yl,I as vr,J as Sr,K as Nr,ax as Is,ag as Ts,aL as _s,cf as Jn,d as We,b$ as Cr,c1 as _r,f as us,bw as Rr,cc as wr,bi as Rs,e as yn,x as ze,b5 as Ir,au as Er,aw as ds,D as Ar,j as vn}from"./index-BKM6dmQa.js";import{I as $r,J as kr}from"./RouterProvider-CSvsxik1.js";import{Q as Pr}from"./questions-D5_DdRA4.js";import{x as Tr,B as Gr,K as zr,b as Mr,P as vl,S as Sl,l as ys,f as Fr,O as cn,D as Dr,i as Or,s as Lr,t as Vr,k as Ur,A as Nl,u as qr,J as Cl,d as Br,F as Kr,y as Wr,c as Xn,H as Qr,e as el,R as Hr,N as Zr,v as Yr,w as Jr,r as _l,h as Xr,g as ei,C as ti,G as si,W as ni,a as li,p as Rl,o as ri,z as wl,I as Il,L as ii,E as Sn,m as ai,j as oi,n as ci,q as tl}from"./refund-line-item-price-Dm9Wreqa.js";import{d as di,c as ui,F as vs,I as On,e as Ln,g as mi,b as El,u as fi,P as hi,f as pi,a as xi}from"./image-lightbox-B4oMiWOQ.js";import{I as Ze,d as Se,c as be,f as we,a as ft,b as Pt,g as $t,A as gi,e as Ss}from"./InfoCard-Drvs12mH.js";import{S as ut,E as ji}from"./general-CagrlsW7.js";import{m as Re,q as bi}from"./factories-Bw3vkuJd.js";import{F as xe,c as nt,a as Ve,b as sl}from"./field-CNE_lbUm.js";import{T as Vn}from"./tag-twPQ3Yzx.js";import{S as Es,c as As,d as $s,a as ks,b as Gs}from"./select-hqXHF7N5.js";import{s as Al,o as Un,D as je,m as ye,j as Oe,l as Ie,k as Ne,i as ve,p as yi,L as De,h as vi,t as Si,v as Ni,u as Ci,T as _i}from"./switch-25HiRgYQ.js";import{R as $l}from"./refresh-ccw-Ca1LV_e9.js";import{C as kl,b as fn,a as Nn,E as fs}from"./button-group-ppkIJAEV.js";import{f as fe,g as qn}from"./currency-5NZh3_Ic.js";import{B as it,g as Pl,h as Tl,d as Bn,b as zs,C as Ri,i as Gl,c as wi,f as Ii}from"./calendar-Dd_sZ_L1.js";import{e as nl,f as Ei,d as Ai,c as $i,b as ki,g as Pi,a as Ti,A as Gi}from"./ActivityFeed-UO_obpWp.js";import{e as Kn,i as Ms,f as Fs,g as Ds,b as Os,P as Ls,a as zl,d as Ml}from"./ProductItem-DttIhwzk.js";import{C as Wn}from"./circle-x-DtCwrmCw.js";import{i as zi}from"./isBefore-CPv7jNG9.js";import{A as Fl}from"./arrow-right-L0MyuoFc.js";import{E as Ct}from"./ellipsis-vertical-CQ3WUfKS.js";import{c as Tt,b as Gt,a as Mi,A as xt}from"./alert-CESsYHJT.js";import{U as Fi,S as ms}from"./users-BmxLkEht.js";import{S as Di}from"./shield-check-D_utsfQI.js";import{P as bs}from"./pencil-DbGe-IFl.js";import{E as Dl}from"./eye-ZbVeuLYi.js";import{P as Oi,E as hn}from"./emails-C6hFPnwM.js";import{R as Li,C as Qn,u as Vi}from"./use-terms-and-agreements-BtYKRIVx.js";import{u as Ol}from"./use-return-reasons-DpOcpuB0.js";import{T as Ui}from"./trash-2-BZEBUla3.js";import{I as qi}from"./iframe-email-preview-ZdJQ4POk.js";import{M as Bi}from"./map-pin-Cjd6fe50.js";import{c as jt}from"./currency.es-9OAR_aOO.js";import{A as Ki,P as Wi,C as Qi,g as Hi,R as Zi}from"./rule-calculation-value-display-KLNAza-7.js";import{T as Yi,H as Ji}from"./typography-C-_DoHfk.js";import"./parseISO-BJeHpXe_.js";import"./chevron-up-H8N2vdlb.js";import"./item-Udo0HP0k.js";import"./image-BbA6u7oD.js";import"./package-check-BrZfXDnL.js";/** 2 * @license lucide-react v0.556.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Xi=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Cn=wn("bell",Xi);/** 7 * @license lucide-react v0.556.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ea=[["path",{d:"M14.564 14.558a3 3 0 1 1-4.122-4.121",key:"1rnrzw"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 .819-.175",key:"1x3arw"}],["path",{d:"M9.695 4.024A2 2 0 0 1 10.004 4h3.993a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v7.344",key:"1i84u0"}]],ta=wn("camera-off",ea);/** 12 * @license lucide-react v0.556.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const sa=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],na=wn("zap",sa),la=()=>{const t=T.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(ra,{}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsxs("div",{className:"flex flex-col overflow-auto gap-6 h-full w-full min-h-0",children:[e,s.jsxs("div",{className:"flex gap-6",children:[s.jsx(ia,{}),s.jsx(ua,{})]})]}),t[1]=n):n=t[1],n},ra=()=>{const t=T.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{className:"h-8 w-48"}),s.jsx(re,{className:"h-6 w-20 rounded-full"}),s.jsx(re,{className:"h-6 w-24 rounded-full"})]}),s.jsx(re,{className:"h-4 w-36"})]}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsxs("div",{className:"flex items-center justify-between rounded-lg",children:[e,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{className:"size-9 rounded-md"}),s.jsx(re,{className:"size-9 rounded-md"}),s.jsx(re,{className:"size-9 rounded-md"})]})]}),t[1]=n):n=t[1],n},ia=()=>{const t=T.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"flex-auto flex flex-col pb-[160px] gap-4",children:[s.jsx(aa,{}),s.jsx(ll,{}),s.jsx(ll,{}),s.jsx(ca,{})]}),t[0]=e):e=t[0],e},aa=()=>{const t=T.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=["return-method","credit-method","is-exchange"],t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Ze,{children:s.jsx("div",{className:"grid grid-cols-3 gap-y-4",children:e.map(fa)})}),t[1]=n):n=t[1],n},ll=()=>{const t=T.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{className:"h-6 w-28"}),s.jsx(re,{className:"h-6 w-20 rounded-full"})]}),s.jsx(re,{className:"size-8 rounded-md"})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(re,{className:"size-20 rounded-md shrink-0"}),t[1]=n):n=t[1];let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs("div",{className:"flex gap-4",children:[n,s.jsxs("div",{className:"flex flex-col gap-2 flex-1",children:[s.jsx(re,{className:"h-5 w-3/4"}),s.jsx(re,{className:"h-4 w-1/2"}),s.jsx(re,{className:"h-4 w-1/3"})]}),s.jsx(re,{className:"h-5 w-16"})]}),t[2]=l):l=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=["reason","status","disposition"],t[3]=r):r=t[3];let i;return t[4]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsxs("div",{className:"flex flex-col border border-border p-4 bg-background rounded-lg gap-4",children:[e,l,s.jsx("div",{className:"grid grid-cols-3 gap-4",children:r.map(ha)})]}),t[4]=i):i=t[4],i},oa=["a","b","c","d"],ca=()=>{const t=T.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(re,{className:"h-5 w-28 mb-2"}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsxs(Ze,{children:[e,s.jsx("div",{className:"flex flex-col gap-3",children:oa.map(pa)})]}),t[1]=n):n=t[1],n},da=[{id:"refunds",titleWidth:"w-28",rows:["r1","r2","r3","r4"]},{id:"order",titleWidth:"w-20",rows:["r1","r2","r3","r4","r5"]},{id:"rules",titleWidth:"w-36",rows:["r1","r2","r3"]},{id:"shipments",titleWidth:"w-24",rows:["r1","r2","r3"]}],ua=()=>{const t=T.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"flex-none max-w-[360px] w-[360px] flex flex-col space-y-4",children:da.map(xa)}),t[0]=e):e=t[0],e},ma=t=>{const e=T.c(7),{titleWidth:n,rows:l}=t,r=`h-5 ${n}`;let i;e[0]!==r?(i=s.jsx(re,{className:r}),e[0]=r,e[1]=i):i=e[1];let o;e[2]!==l?(o=l.map(ga),e[2]=l,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=s.jsxs(Ze,{className:"gap-3",children:[i,o]}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a};function fa(t){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(re,{className:"h-3 w-24"}),s.jsx(re,{className:"h-5 w-32"})]},t)}function ha(t){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(re,{className:"h-3 w-20"}),s.jsx(re,{className:"h-5 w-28"})]},t)}function pa(t){return s.jsxs("div",{className:"flex gap-3",children:[s.jsx(re,{className:"size-8 rounded-full shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-1.5 flex-1",children:[s.jsx(re,{className:"h-4 w-2/3"}),s.jsx(re,{className:"h-3 w-1/4"})]})]},t)}function xa(t){return s.jsx(ma,{titleWidth:t.titleWidth,rows:t.rows},t.id)}function ga(t){return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(re,{className:"h-3 w-20"}),s.jsx(re,{className:"h-4 w-full"})]},t)}const Rn=le.createContext({}),se=()=>{if(!le.useContext(Rn))throw new Error("usePage must be used within an PageProvider");return le.useContext(Rn)},ja=t=>{const e=T.c(36),{children:n,returnGroupId:l,className:r}=t;let i;e[0]!==l?(i=Number.parseInt(String(l),10),e[0]=l,e[1]=i):i=e[1];const o=i,a=String(l);let d;e[2]!==a?(d=[a],e[2]=a,e[3]=d):d=e[3];const c=!!l;let u;e[4]!==d||e[5]!==c?(u={queryKey:d,enabled:c},e[4]=d,e[5]=c,e[6]=u):u=e[6];let m;e[7]!==o?(m={id:o},e[7]=o,e[8]=m):m=e[8];const{data:f,isFetching:h,isError:p,isRefetching:x,refetch:j}=Tr(u,m),g=String(l);let b;e[9]!==g?(b=[g],e[9]=g,e[10]=b):b=e[10];const y=!!l;let v;e[11]!==b||e[12]!==y?(v={queryKey:b,enabled:y},e[11]=b,e[12]=y,e[13]=v):v=e[13];let S;e[14]!==o?(S={returnGroupId:o},e[14]=o,e[15]=S):S=e[15];const{data:C,isFetching:R,isRefetching:w,isError:_,refetch:I}=Gr(v,S);if(h&&!x&&R&&!w){let z;return e[16]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(la,{}),e[16]=z):z=e[16],z}else if((p||!f?.returnGroup)&&!h){const z=p?"Error fetching return group":"Return group not found";let D;return e[17]!==z?(D=s.jsxs("div",{children:["Error:"," ",z]}),e[17]=z,e[18]=D):D=e[18],D}if(!f?.returnGroup)return null;const N=C?.suggestedRefundTransactions;let A;e[19]!==f.returnGroup||e[20]!==h||e[21]!==R||e[22]!==_||e[23]!==w||e[24]!==j||e[25]!==I||e[26]!==N?(A={returnGroup:f.returnGroup,isReturnGroupFetching:h,refetch:j,refundTransactions:N,isRefundTransactionsFetching:R,isRefundTransactionsRefetching:w,isRefundTransactionsError:_,refundTransactionsRefetch:I},e[19]=f.returnGroup,e[20]=h,e[21]=R,e[22]=_,e[23]=w,e[24]=j,e[25]=I,e[26]=N,e[27]=A):A=e[27];let P;e[28]!==r?(P=mt("h-full w-full min-h-0",r),e[28]=r,e[29]=P):P=e[29];let k;
16e[30]!==n||e[31]!==P?(k=s.jsx(zr,{show:!0,appear:!0,enter:"transition-opacity duration-100",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition-opacity duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",className:P,as:"div",children:n}),e[30]=n,e[31]=P,e[32]=k):k=e[32];let E;return e[33]!==A||e[34]!==k?(E=s.jsx(Rn.Provider,{value:A,children:k}),e[33]=A,e[34]=k,e[35]=E):E=e[35],E},ba=Re(he` 17 mutation SubmitReturnGroup($input: ReturnGroupInput!) { 18 submitReturnGroup(input: $input) 19 } 20`),ya=(t,e)=>{switch(e.type){case"enable":return{...t,enabled:!0};case"cancel":return{...t,enabled:!1};case"setState":return{...e.state};case"setReturnValues":return{...t,returnValues:e.returnValues};case"updateReturnValue":return{...t,returnValues:{...t.returnValues,[e.returnId]:e.returnValue}};case"setShippingGroupOptions":return{...t,shippingGroupOptions:e.shippingGroupOptions};case"setShippingGroups":return{...t,shippingGroups:e.shippingGroups};case"updateShippingGroup":{const{shippingGroupNumber:n,shippingGroup:l}=e,r=t.shippingGroups.map(i=>i.shippingGroupNumber===n?l:i);return{...t,shippingGroups:r}}default:throw new Error}},rl=(t,e="fill")=>{const n=[{fill:"fill-info",bg:"bg-info"},{fill:"fill-success",bg:"bg-success"},{fill:"fill-destructive",bg:"bg-destructive"},{fill:"fill-warning",bg:"bg-warning"}];return n[(t-1)%n.length][e]},va=t=>{const e=T.c(24),{children:n}=t,{settings:l}=Ce(),{returnGroup:r,refetch:i}=se();l?.returnPolicy?.itemConditionChoices;let o;e[0]!==l?.returnPolicy?.itemConditionChoices?(o=l?.returnPolicy?.itemConditionChoices||[],e[0]=l?.returnPolicy?.itemConditionChoices,e[1]=o):o=e[1];const a=o;let d,c;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=[],c=[],e[2]=d,e[3]=c):(d=e[2],c=e[3]);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u={enabled:!1,initialized:!1,shippingGroups:d,shippingGroupOptions:c,isAllowReturnGroupSubmit:!1,isAllowShippingGroupsEdit:!1,returnValues:{}},e[4]=u):u=e[4];const[m,f]=le.useReducer(ya,u),{enabled:h,initialized:p,shippingGroupOptions:x,shippingGroups:j,returnValues:g,isAllowReturnGroupSubmit:b,isAllowShippingGroupsEdit:y}=m;let v;e[5]!==i?(v={onSuccess:()=>{i(),G.success("Return saved. Shipping labels will be generated shortly. (if any)")},onError:()=>{i(),G.error(`Return failed to save... Contact ${ut} for assistance.`)}},e[5]=i,e[6]=v):v=e[6];const{mutate:S,isPending:C}=ba(v);let R,w;e[7]!==a||e[8]!==r?(R=()=>{r&&Sa(r,f,a)},w=[r,a],e[7]=a,e[8]=r,e[9]=R,e[10]=w):(R=e[9],w=e[10]),le.useEffect(R,w);let _;e[11]!==h||e[12]!==p||e[13]!==b||e[14]!==y||e[15]!==C||e[16]!==S||e[17]!==g||e[18]!==x||e[19]!==j?(_={enabled:h,initialized:p,returnValues:g,shippingGroupOptions:x,shippingGroups:j,isAllowReturnGroupSubmit:b,isAllowShippingGroupsEdit:y,isPending:C,mutate:S,dispatch:f},e[11]=h,e[12]=p,e[13]=b,e[14]=y,e[15]=C,e[16]=S,e[17]=g,e[18]=x,e[19]=j,e[20]=_):_=e[20];let I;return e[21]!==n||e[22]!==_?(I=s.jsx(Ll.Provider,{value:_,children:n}),e[21]=n,e[22]=_,e[23]=I):I=e[23],I},Ll=le.createContext({enabled:!1,initialized:!1,returnValues:{},shippingGroupOptions:[],shippingGroups:[],isPending:!1,isAllowReturnGroupSubmit:!1,isAllowShippingGroupsEdit:!1,dispatch:()=>{},mutate:()=>{}}),Sa=(t,e,n)=>{const l=t.shipments.map((o,a)=>({shippingGroupNumber:a+1,expenseType:o.expenseType||gs.MerchantPaid,shippingZoneName:o.shippingZone?.name||"No zone found"})),r={};t.returns.forEach(o=>{const a=t.shipments.find(d=>d.returnNames?.includes(o.name));r[o.id]={shippingGroup:a?t.shipments.indexOf(a)+1:null,verificationDecision:o.verificationDecision||ge.Perfect,verificationDecisionLabel:o.verificationDecisionNote||n.find(d=>d.value===ge.Perfect)?.label||null}});const i={enabled:!1,initialized:!0,returnValues:r,shippingGroups:l||[{shippingGroupNumber:1,expenseType:gs.MerchantPaid,shippingZoneName:t.availableShippingZones[0]?.name||"No zone found"}],shippingGroupOptions:l?l.map((o,a)=>({label:`Return Label ${a+1}`,value:a+1,color:rl(a+1)})):[{label:"Return Label 1",value:1,color:rl(1)}],isAllowReturnGroupSubmit:t.status===Fe.InReview,isAllowShippingGroupsEdit:t.returnMethod!==xl.Ecodrop};e({type:"setState",state:i})},pn=()=>{const t=le.useContext(Ll);if(!t)throw new Error("useReview must be used within an ReviewProvider");return t},Vl=(t,e="fill")=>{const n=[{fill:"fill-info text-info",bg:"bg-info"},{fill:"fill-success text-success",bg:"bg-success"},{fill:"fill-destructive text-destructive",bg:"bg-destructive"},{fill:"fill-warning text-warning",bg:"bg-warning"}];return n[(t-1)%n.length][e]},Na=t=>t.every(e=>e.status===js.Canceled),Ca=t=>t.filter(n=>[tt.Created,tt.InTransit,tt.Delivered,tt.Failed,tt.Canceled].includes(n.status)),_a=t=>t.filter(e=>e.status===tt.Draft),Ra=()=>{const t=T.c(18),{returnValues:e,shippingGroups:n,dispatch:l,isAllowReturnGroupSubmit:r}=pn(),{returnGroup:i}=se();let o,a,d,c;if(t[0]!==l||t[1]!==r||t[2]!==i.availableShippingZones||t[3]!==i.returnMethod||t[4]!==i.returns||t[5]!==e||t[6]!==n){c=Symbol.for("react.early_return_sentinel");e:{const m=Ia(e),f=Object.keys(m).length,h=Na(i.returns),p=i.availableShippingZones||[];if(h){c=null;break e}const x=g=>{const b=p.find(y=>y.name===g);return Number(b?.shippingFee?.amount.amount||0).toFixed(2)},j=Ea;o="flex flex-col overflow-auto max-h-[300px] w-full",t[11]!==i.returnMethod||t[12]!==f?(a=f===0&&s.jsxs("div",{className:"p-4 rounded border border-border bg-muted m-4 self-start flex flex-col items-center w-[200px]",children:[s.jsx(M,{size:"sm",weight:"semibold",children:"No Return Labels"}),i.returnMethod===xl.Ecodrop?s.jsx(M,{size:"sm",tone:"muted",className:"text-center mt-1",children:"EcoDrop shipping controlled by Route Returns"}):null]}),t[11]=i.returnMethod,t[12]=f,t[13]=a):a=t[13],d=f>0&&s.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,224px)] gap-x-4 w-full p-4",children:n.map((g,b)=>{const{shippingGroupNumber:y,expenseType:v,shippingZoneName:S}=g;return s.jsxs("div",{className:dt("relative w-56 flex flex-col gap-2"),children:[s.jsxs(M,{size:"sm",weight:"semibold",className:"flex items-center gap-1",children:[s.jsx(Vn,{className:dt("size-4",Vl(y))}),"Return Label ",y]}),s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs(xe,{className:"flex flex-col gap-1.5",children:[s.jsx(nt,{htmlFor:`${y}-shippingZone`,children:"Destination"}),s.jsxs(Es,{value:S,disabled:!r,onValueChange:C=>{l({type:"updateShippingGroup",shippingGroupNumber:y,shippingGroup:{shippingGroupNumber:y,expenseType:v,shippingZoneName:C||""}})},children:[s.jsx(As,{children:s.jsx($s,{})}),s.jsx(ks,{children:p.map(Aa)})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(M,{size:"xs",weight:"semibold",children:"Items in this label:"}),s.jsx("ul",{className:"list-disc ml-4",children:m?.[y]?.map(C=>{const R=i.returns.find(w=>w.id===C);return s.jsx(M,{as:"li",size:"sm",children:wa(R?.lineItem.productName||"Product",26)},C)})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs(M,{size:"sm",tone:"muted",children:["Shipping Fee: $",j(v)?"0.00":
20x(S)]}),Number(x(S))>0&&s.jsxs(xe,{className:"flex items-center gap-2",children:[s.jsx(nt,{children:"Waive Shipping Fee"}),s.jsx(Al,{name:`${y}-waiveShipping`,checked:j(v),disabled:!r,onCheckedChange:C=>{l({type:"updateShippingGroup",shippingGroupNumber:y,shippingGroup:{shippingGroupNumber:y,expenseType:C?gs.MerchantPaid:gs.RefundDeduction,shippingZoneName:S}})}})]})]})]})]},String(b))})})}t[0]=l,t[1]=r,t[2]=i.availableShippingZones,t[3]=i.returnMethod,t[4]=i.returns,t[5]=e,t[6]=n,t[7]=o,t[8]=a,t[9]=d,t[10]=c}else o=t[7],a=t[8],d=t[9],c=t[10];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;return t[14]!==o||t[15]!==a||t[16]!==d?(u=s.jsxs("div",{className:o,children:[a,d]}),t[14]=o,t[15]=a,t[16]=d,t[17]=u):u=t[17],u},wa=(t,e)=>t.length<=e?t:`${t.slice(0,e)}...`,Ia=t=>{const e={};return Object.keys(t).forEach(n=>{const l=t[n].shippingGroup;l&&(e[l]?e[l].push(parseInt(n,10)):e[l]=[parseInt(n,10)])}),e};function Ea(t){return t===gs.MerchantPaid}function Aa(t){const{name:e}=t;return s.jsx(Gs,{value:e||"",children:e},e)}const $a=()=>{const t=T.c(22),{settings:e}=Ce(),{dispatch:n,isAllowReturnGroupSubmit:l,returnValues:r,mutate:i,isPending:o,shippingGroups:a}=pn(),{returnGroup:d}=se(),c=e?.imageVerificationPolicy.enabled;let u;t[0]!==r?(u=Object.keys(r).map(ka),t[0]=r,t[1]=u):u=t[1];const m=u,f=m.length;let h;t[2]!==m||t[3]!==r?(h=m.filter(w=>{const _=r[w].verificationDecision;return _?[ge.DeclineDamaged,ge.DeclineOther,ge.Defective,ge.Good,ge.NoIssue,ge.Perfect,ge.Poor,ge.Seconds,ge.WrongItem].includes(_):!1}),t[2]=m,t[3]=r,t[4]=h):h=t[4];const p=h.length;let x=!0;c&&p!==f&&(x=!1);let j;t[5]===Symbol.for("react.memo_cache_sentinel")?(j=[],t[5]=j):j=t[5],le.useEffect(Pa,j);let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(Ra,{}),t[6]=g):g=t[6];let b;t[7]!==n?(b=s.jsx(F,{variant:"outline",onClick:()=>{n({type:"cancel"})},children:"Cancel"}),t[7]=n,t[8]=b):b=t[8];const y=!x||o||!l;let v;t[9]!==i||t[10]!==d.id||t[11]!==m||t[12]!==r||t[13]!==a?(v=()=>{i({input:{shippingConfigurations:a,returnGroupId:d.id,returnInputs:m.map(w=>({returnId:w,shippingGroup:r[w].shippingGroup,verificationDecision:r[w].verificationDecision,verificationDecisionNote:r[w].verificationDecisionLabel||""}))}})},t[9]=i,t[10]=d.id,t[11]=m,t[12]=r,t[13]=a,t[14]=v):v=t[14];const S=c?` (${p}/${f})`:null;let C;t[15]!==y||t[16]!==v||t[17]!==S?(C=s.jsxs(F,{disabled:y,onClick:v,children:["Submit",S]}),t[15]=y,t[16]=v,t[17]=S,t[18]=C):C=t[18];let R;return t[19]!==b||t[20]!==C?(R=s.jsxs("div",{className:"flex flex-col animate-fade w-full",children:[g,s.jsxs("div",{className:"flex space-x-4 w-full justify-center border-t border-border py-2",children:[b,C]})]}),t[19]=b,t[20]=C,t[21]=R):R=t[21],R};function ka(t){return parseInt(t,10)}function Pa(){const t=document.querySelector('[data-anchor="return-actions"]');t&&t.scrollIntoView({block:"start",behavior:"smooth"})}const Ta=()=>{const t=T.c(18),{open:e}=Ee(),{settings:n}=Ce(),{returnGroup:l}=se(),{enabled:r,isAllowReturnGroupSubmit:i,dispatch:o}=pn();let a;t[0]!==l?(a=di(l),t[0]=l,t[1]=a):a=t[1];const d=a;let c;t[2]!==l||t[3]!==n?(c=ui(l,n),t[2]=l,t[3]=n,t[4]=c):c=t[4];const u=c,m=r?"ml-[296px] mr-[440px] bottom-4 left-0 right-0 backdrop-blur-sm bg-background/95":"fixed bottom-4 left-[50%] -translate-x-1/2 px-4 backdrop-blur-sm bg-card/30";let f;t[5]!==m?(f=dt("border border-border rounded-lg shadow flex fixed transition-all z-10",m),t[5]=m,t[6]=f):f=t[6];let h;t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==d||t[11]!==u||t[12]!==e||t[13]!==l?(h=r?s.jsx($a,{}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex space-x-4 py-4 animate-fade",children:[l.status!==Fe.Closed?s.jsxs(F,{variant:"destructive",onClick:()=>{e("cancel")},children:[s.jsx(In,{}),"Cancel"]}):null,d?s.jsxs(F,{variant:"outline",onClick:()=>{e("reset")},children:[s.jsx($l,{}),"Reset"]}):null,u?s.jsxs(F,{variant:"outline",onClick:()=>{e("reupload")},children:[s.jsx(kl,{}),"Reupload"]}):null,s.jsxs(F,{variant:"outline",onClick:()=>{e("flag")},children:[s.jsx(vs,{}),"Flag"]}),l.completeAllowed?s.jsxs(F,{variant:"outline",onClick:()=>{e("complete")},children:[s.jsx(Mr,{}),"Complete"]}):null]}),i?s.jsx("div",{className:"border-l ml-4 pl-4 py-4 animate-fade",children:s.jsxs("div",{className:"relative",children:[s.jsxs(F,{onClick:()=>{o({type:"enable"})},children:[s.jsx(cr,{}),"Review"]}),s.jsx("div",{className:"absolute -right-1.5 -top-1.5",children:s.jsx(vl,{})})]})}):null]}),t[7]=o,t[8]=r,t[9]=i,t[10]=d,t[11]=u,t[12]=e,t[13]=l,t[14]=h):h=t[14];let p;return t[15]!==f||t[16]!==h?(p=s.jsx("div",{className:f,children:h}),t[15]=f,t[16]=h,t[17]=p):p=t[17],p},xn=t=>{const e=T.c(19),{imageUrl:n,alt:l,title:r,variantName:i,sku:o,price:a}=t,d=o?`(SKU: ${o})`:null;
20let c;e[0]!==d||e[1]!==i?(c=[i,d].filter(Boolean),e[0]=d,e[1]=i,e[2]=c):c=e[2];const u=c.join(" ");let m;e[3]!==l||e[4]!==n?(m=s.jsx(Kn,{src:n,alt:l,className:"size-[60px]!"}),e[3]=l,e[4]=n,e[5]=m):m=e[5];let f;e[6]!==r?(f=s.jsx(Ms,{children:r}),e[6]=r,e[7]=f):f=e[7];let h;e[8]!==u?(h=u?s.jsx(Fs,{children:u}):null,e[8]=u,e[9]=h):h=e[9];let p;e[10]!==a?(p=a?s.jsx(Ds,{weight:"regular",children:a}):null,e[10]=a,e[11]=p):p=e[11];let x;e[12]!==f||e[13]!==h||e[14]!==p?(x=s.jsxs(Os,{children:[f,h,p]}),e[12]=f,e[13]=h,e[14]=p,e[15]=x):x=e[15];let j;return e[16]!==m||e[17]!==x?(j=s.jsxs(Ls,{size:"sm",variant:"default",className:"mt-1 border-0 bg-transparent p-0 shadow-none",children:[m,x]}),e[16]=m,e[17]=x,e[18]=j):j=e[18],j},Ge=t=>{const e=T.c(24);let n,l,r,i,o;e[0]!==t?({event:l,icon:r,label:i,children:n,...o}=t,e[0]=t,e[1]=n,e[2]=l,e[3]=r,e[4]=i,e[5]=o):(n=e[1],l=e[2],r=e[3],i=e[4],o=e[5]);let a;e[6]!==r?(a=s.jsx($i,{children:r}),e[6]=r,e[7]=a):a=e[7];let d;e[8]!==i?(d=s.jsx(ki,{children:s.jsx(Pi,{children:i})}),e[8]=i,e[9]=d):d=e[9];let c;e[10]!==l.source||e[11]!==l.sourceDetails?(c=l.sourceDetails?s.jsxs(nl,{children:["Triggered by ",l.sourceDetails.name," (",l.sourceDetails.email,")"]}):l.source?s.jsxs(nl,{children:["Triggered by ",ji[l.source]]}):null,e[10]=l.source,e[11]=l.sourceDetails,e[12]=c):c=e[12];let u;e[13]!==n||e[14]!==d||e[15]!==c?(u=s.jsxs(Ti,{children:[d,c,n]}),e[13]=n,e[14]=d,e[15]=c,e[16]=u):u=e[16];let m;e[17]!==l.createdAt?(m=s.jsx(Ei,{timestamp:l.createdAt}),e[17]=l.createdAt,e[18]=m):m=e[18];let f;return e[19]!==o||e[20]!==a||e[21]!==u||e[22]!==m?(f=s.jsxs(Ai,{indicator:a,...o,children:[u,m]}),e[19]=o,e[20]=a,e[21]=u,e[22]=m,e[23]=f):f=e[23],f},Ga=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const i=n.payload?.exchange_line_item;let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Wn,{className:"size-5 text-destructive"}),e[3]=o):o=e[3];let a;e[4]!==i?(a=i?s.jsx(xn,{imageUrl:i.variant.image?.url,alt:i.variant.image?.alt_text||i.variant.product_name,title:i.variant.product_name,variantName:i.variant.name,sku:i.variant.sku,price:i.discounted_price?.presentment_money?fe({amount:parseFloat(i.discounted_price.presentment_money.amount),currencyCode:i.discounted_price.presentment_money.currency_code},!0):null}):null,e[4]=i,e[5]=a):a=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==a?(d=s.jsx(Ge,{event:n,...l,icon:o,label:"Exchange canceled",children:a}),e[6]=n,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},za=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(Un,{className:"size-5 text-info"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs(M,{size:"sm",className:"mt-1",children:["You updated the email for this order from"," ",s.jsx(M,{as:"span",weight:"semibold",children:r.old_email})," ","to"," ",s.jsx(M,{as:"span",weight:"semibold",children:r.new_email}),"."]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Customer email updated",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Ma=t=>t.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),Fa=t=>{const e=T.c(13);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]!==r?(i=r?.email_type?Ma(r.email_type):null,e[3]=r,e[4]=i):i=e[4];const o=i;let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(Un,{className:"size-5 text-info"}),e[5]=a):a=e[5];let d;e[6]!==o||e[7]!==r?(d=r?s.jsxs(M,{size:"sm",className:"mt-1",children:[o," email was sent",r.destination_email?s.jsxs(s.Fragment,{children:[" to ",r.destination_email]}):null]}):null,e[6]=o,e[7]=r,e[8]=d):d=e[8];let c;return e[9]!==n||e[10]!==l||e[11]!==d?(c=s.jsx(Ge,{event:n,...l,icon:a,label:"Email sent",children:d}),e[9]=n,e[10]=l,e[11]=d,e[12]=c):c=e[12],c},Da=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(Sl,{className:"size-5 text-info"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs(M,{size:"sm",className:"mt-1",children:[r.metric_name?`${r.metric_name} event`:"Event"," was sent to Klaviyo",r.destination_email?s.jsxs(s.Fragment,{children:[" for ",r.destination_email]}):null]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Klaviyo event sent",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Oa={[Ns.Manual]:"Manual",[Ns.OriginalPaymentMethod]:"Original Payment Method",[Ns.StoreCreditDiscount]:"Store Credit Discount",[Ns.StoreCreditGiftCard]:"Store Credit Gift Card",[Ns.StoreCreditNative]:"Store Credit Native"},La={[He.Failed]:"Failed",[He.PartiallyFailed]:"Partially Failed",[He.Succesfull]:"Successful",[He.Unknown]:"Unknown"},Va=t=>{switch(t){case He.Succesfull:return"primary";case He.Failed:return"destructive";case He.PartiallyFailed:return"destructive";default:return"secondary"}},Ua=t=>{const e=T.c(12);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload,i=r?.status===He.Failed,o=r?.amount_refunded?.presentment_money,a=!i&&o;let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(En,{className:"size-5 text-success"}),e[3]=d):d=e[3];let c;e[4]!==r||e[5]!==o||e[6]!==a?(c=r?s.jsxs(M,{size:"sm",className:"mt-1 flex items-center gap-1.5 flex-wrap",children:[r.refund_type?Oa[r.refund_type]:null,r.refund_type&&a?" â ":null,a?fe({amount:o.amount,currencyCode:o.currency_code},!0):null,r.status?s.jsx(it,{variant:Va(r.status),children:La[r.status]||r.status}):null]}):null,e[4]=r,e[5]=o,e[6]=a,e[7]=c):c=e[7];let u;return e[8]!==n||e[9]!==l||e[10]!==c?(u=s.jsx(Ge,{event:n,...l,icon:d,label:"Refund",children:c}),e[8]=n,e[9]=l,e[10]=c,e[11]=u):u=e[11],u},qa=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(Wn,{className:"size-5 text-destructive"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs("div",{className:"flex flex-col gap-2 mt-1",children:[r.name?s.jsx(M,{size:"sm",weight:"semibold",children:r.name}):null,r.variant&&r.price?s.jsx(xn,{imageUrl:r.variant.image?.url,alt:r.variant.image?.alt_text||r.variant.product_name,title:r.variant.product_name,variantName:r.variant.name,sku:r.variant.sku,price:r.price.discounted_price?.presentment_money?fe({amount:parseFloat(r.price.discounted_price.presentment_money.amount),currencyCode:r.price.discounted_price.presentment_money.currency_code},!0):null}):null]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Return canceled",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Ba=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(ys,{className:"size-5 text-muted-foreground"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs("div",{className:"flex flex-col gap-2 mt-1",children:[r.name?s.jsx(M,{size:"sm",weight:"semibold",children:r.name}):null,r.variant&&r.price?s.jsx(xn,{imageUrl:r.variant.image?.url,alt:r.variant.image?.alt_text||r.variant.product_name,title:r.variant.product_name,variantName:r.variant.name,sku:r.variant.sku,price:r.price.discounted_price?.presentment_money?fe({amount:parseFloat(r.price.discounted_price.presentment_money.amount),currencyCode:r.price.discounted_price.presentment_money.currency_code},!0):null}):null]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Return closed",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Ka=t=>{const e=T.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(ys,{className:"size-5 text-primary"}),e[0]=n):n=e[0];let l;return e[1]!==t?(l=s.jsx(Ge,{...t,icon:n,label:"Return group submitted"}),e[1]=t,e[2]=l):l=e[2],l},Wa={[Et.Approved]:"Approved",[Et.Declined]:"Declined",[Et.NoDecision]:"No Decision"},Qa=t=>{switch(t){case Et.Approved:return"primary";case Et.Declined:return"destructive";default:return"secondary"}},Ha=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(ys,{className:"size-5 text-warning"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs("div",{className:"flex flex-col gap-2 mt-1",children:[r.name?s.jsx(M,{size:"sm",weight:"semibold",children:r.name}):null,r.variant?s.jsx(xn,{imageUrl:r.variant.image_url,alt:r.variant.product_title||"Product",title:r.variant.product_title||"Product",variantName:r.variant.title,sku:r.variant.sku,price:r.price?.unit_price?.presentment_money?fe({amount:r.price.unit_price.presentment_money.amount,currencyCode:r.price.unit_price.presentment_money.currency_code},!0):null}):null,r.review_decision?s.jsxs(M,{size:"sm",className:"flex items-center gap-1.5",children:["Decision:"," ",s.jsx(it,{variant:Qa(r.review_decision),children:Wa[r.review_decision]})]}):null]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Return reviewed",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Za=t=>{const e=T.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(ys,{className:"size-5 text-muted-foreground"}),e[0]=n):n=e[0];let l;return e[1]!==t?(l=s.jsx(Ge,{...t,icon:n,label:"Return reset"}),e[1]=t,e[2]=l):l=e[2],l},Ya=t=>{const e=T.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(ys,{className:"size-5 text-muted-foreground"}),e[0]=n):n=e[0];let l;return e[1]!==t?(l=s.jsx(Ge,{...t,icon:n,label:"Return group reset"}),e[1]=t,e[2]=l):l=e[2],l},Ja=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(un,{className:"size-5 text-warning"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs(M,{size:"sm",className:"mt-1 flex flex-col",children:[r.carrier?s.jsx("span",{children:r.carrier}):null,r.return_names&&r.return_names.length>0?s.jsx(M,{as:"span",weight:"semibold",children:r.return_names.join(", ")}):null]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Shipment created",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},Xa=t=>{const e=T.c(10);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(un,{className:"size-5 text-warning"}),e[3]=i):i=e[3];let o;e[4]!==r?(o=r?s.jsxs(M,{size:"sm",tone:"muted",className:"mt-1 flex flex-col",children:[r.carrier?s.jsx("span",{children:r.carrier}):null,r.return_names&&r.return_names.length>0?s.jsx("span",{children:r.return_names.join(", ")}):null]}):null,e[4]=r,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==l||e[8]!==o?(a=s.jsx(Ge,{event:n,...l,icon:i,label:"Shipment tracking info updated",children:o}),e[6]=n,e[7]=l,e[8]=o,e[9]=a):a=e[9],a},eo=t=>{const e=T.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(ys,{className:"size-5 text-warning"}),e[0]=n):n=e[0];let l;return e[1]!==t?(l=s.jsx(Ge,{...t,icon:n,label:"Return group created"}),e[1]=t,e[2]=l):l=e[2],l},to=t=>{const e=T.c(13);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload,i=r?.new_shipment?.return_names,o=r?.old_shipment?.shipping_zone?.name,a=r?.new_shipment?.shipping_zone?.name;let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(un,{className:"size-5 text-warning"}),e[3]=d):d=e[3];let c;e[4]!==a||e[5]!==o||e[6]!==r||e[7]!==i?(c=r&&(o!=null||a!=null)?s.jsxs(M,{size:"sm",className:"mt-1 flex flex-col",children:[i&&i.length>0?s.jsx(M,{as:"span",weight:"semibold",children:i.join(", ")}
20):null,s.jsxs("span",{children:["Shipping zone updated from"," ",s.jsx(M,{as:"span",weight:"semibold",children:o??"â"})," ","to"," ",s.jsx(M,{as:"span",weight:"semibold",children:a??"â"}),"."]})]}):null,e[4]=a,e[5]=o,e[6]=r,e[7]=i,e[8]=c):c=e[8];let u;return e[9]!==n||e[10]!==l||e[11]!==c?(u=s.jsx(Ge,{event:n,...l,icon:d,label:"Shipment updated",children:c}),e[9]=n,e[10]=l,e[11]=c,e[12]=u):u=e[12],u},so=t=>{const e=T.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(vs,{className:"size-5 text-warning"}),e[0]=n):n=e[0];let l;return e[1]!==t?(l=s.jsx(Ge,{...t,icon:n,label:"Return group flagged"}),e[1]=t,e[2]=l):l=e[2],l},no=t=>{const e=T.c(12);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=n.payload,i=r?.reasons_added&&r.reasons_added.length>0,o=!!r?.comment_appended;let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(vs,{className:"size-5 text-warning"}),e[3]=a):a=e[3];let d;e[4]!==o||e[5]!==i||e[6]!==r?(d=r&&(i||o)?s.jsxs(M,{size:"sm",className:"mt-1 flex flex-col gap-1",children:[i?s.jsxs("span",{children:["Reasons added:"," ",s.jsx(M,{as:"span",weight:"semibold",size:"sm",children:r.reasons_added?.map(io).join(", ")})]}):null,o?s.jsxs("span",{children:["Comment added:"," ",s.jsx(M,{as:"span",weight:"semibold",size:"sm",children:r.comment_appended})]}):null]}):null,e[4]=o,e[5]=i,e[6]=r,e[7]=d):d=e[7];let c;return e[8]!==n||e[9]!==l||e[10]!==d?(c=s.jsx(Ge,{event:n,...l,icon:a,label:"Flag updated",children:d}),e[8]=n,e[9]=l,e[10]=d,e[11]=c):c=e[11],c},lo=t=>{const e=T.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Fr,{className:"size-5 text-muted-foreground"}),e[0]=n):n=e[0];let l;return e[1]!==t?(l=s.jsx(Ge,{...t,icon:n,label:"Flag cleared"}),e[1]=t,e[2]=l):l=e[2],l},Ul={[ie.ReturnGroupCreated]:eo,[ie.ExchangeCanceled]:Ga,[ie.CustomerEmailUpdated]:za,[ie.EmailSent]:Fa,[ie.KlaviyoEventSent]:Da,[ie.RefundCreated]:Ua,[ie.ReturnApproved]:null,[ie.ReturnCanceled]:qa,[ie.ReturnClosed]:Ba,[ie.ReturnCreated]:null,[ie.ReturnGroupSubmitted]:Ka,[ie.ReturnRejected]:null,[ie.ReturnReopened]:null,[ie.ReturnReviewed]:Ha,[ie.ReturnReset]:Za,[ie.ShipmentCanceled]:null,[ie.ShipmentCreated]:Ja,[ie.ShipmentTrackingInfoUpdated]:Xa,[ie.ShipmentUpdated]:to,[ie.ShipmentDelivered]:null,[ie.ShipmentInTransit]:null,[ie.Unknown]:null,[ie.ReturnGroupReset]:Ya,[ie.SettingsUpdated]:null,[ie.ReturnGroupFlagged]:so,[ie.ReturnGroupFlagUpdated]:no,[ie.ReturnGroupFlagCleared]:lo,[ie.RuleDefinitionCreated]:null,[ie.RuleDefinitionUpdated]:null,[ie.RuleDefinitionDeleted]:null,[ie.CustomerEmailsConfigUpdated]:null,[ie.ShippingZoneCreated]:null,[ie.ShippingZoneDeleted]:null,[ie.ShippingZonePriorityUpdated]:null,[ie.ShippingZoneUpdated]:null},ro=t=>{const e=T.c(7);let n,l;e[0]!==t?({event:n,...l}=t,e[0]=t,e[1]=n,e[2]=l):(n=e[1],l=e[2]);const r=Ul[n.eventType];if(!r)return null;let i;return e[3]!==r||e[4]!==n||e[5]!==l?(i=s.jsx(r,{event:n,...l}),e[3]=r,e[4]=n,e[5]=l,e[6]=i):i=e[6],i};function io(t){return dr[t]??t}const ao=()=>{const t=T.c(14),{returnGroup:e}=se();let n;e:{if(!e){let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],t[0]=c):c=t[0],n=c;break e}let d;if(t[1]!==e.createdAt||t[2]!==e.events||t[3]!==e.id){const c=e.events??[],u=c.some(oo),m=[];u||m.push({id:-1,eventType:ie.ReturnGroupCreated,eventCategory:ur.Workflow,createdAt:e.createdAt,returnGroupId:e.id,payload:null,source:null}),d=[...c,...m].filter(co).sort(uo),t[1]=e.createdAt,t[2]=e.events,t[3]=e.id,t[4]=d}else d=t[4];n=d}const l=n;let r;t[5]!==l.length?(r=s.jsx(Pl,{children:s.jsxs(Tl,{children:["Activity Feed (",l.length,")"]})}),t[5]=l.length,t[6]=r):r=t[6];let i;t[7]!==l?(i=l.map(mo),t[7]=l,t[8]=i):i=t[8];let o;t[9]!==i?(o=s.jsx(Bn,{children:s.jsx(Gi,{children:i})}),t[9]=i,t[10]=o):o=t[10];let a;return t[11]!==r||t[12]!==o?(a=s.jsxs(zs,{children:[r,o]}),t[11]=r,t[12]=o,t[13]=a):a=t[13],a};function oo(t){return t.eventType===ie.ReturnGroupCreated}function co(t){return Ul[t.eventType]!==null}function uo(t,e){return zi(At(t.createdAt),At(e.createdAt))?-1:1}function mo(t){return s.jsx(ro,{event:t},t.id)}const fo=mr(he` 21 mutation CancelExchange( 22 $returnGroupId: Int! 23 $platformVariantIds: [String!]! 24 ) { 25 cancelExchange( 26 returnGroupId: $returnGroupId 27 platformVariantIds: $platformVariantIds 28 ) { 29 success 30 userErrors { 31 message 32 } 33 } 34 } 35`),ho=()=>{const t=T.c(14),{returnGroup:e,refetch:n}=se(),l=Ee();let r;t[0]!==l||t[1]!==n?(r={onSuccess:m=>{if(m.cancelExchange.userErrors?.length){G.dismiss(),G.error(m.cancelExchange.userErrors[0].message);return}
35G.dismiss(),G.success("Exchange canceled"),l.close("cancelExchange"),n()},onError:xo},t[0]=l,t[1]=n,t[2]=r):r=t[2];const{mutate:i,isPending:o}=fo(r);let a;t[3]!==l?(a=l.getDialogProps("cancelExchange"),t[3]=l,t[4]=a):a=t[4];let d;t[5]!==i||t[6]!==e.id?(d=m=>{i({returnGroupId:e.id,platformVariantIds:m.map(go)})},t[5]=i,t[6]=e.id,t[7]=d):d=t[7];let c;t[8]!==o||t[9]!==d?(c=s.jsx(po,{isLoading:o,onSubmit:d}),t[8]=o,t[9]=d,t[10]=c):c=t[10];let u;return t[11]!==a||t[12]!==c?(u=s.jsx(je,{...a,children:c}),t[11]=a,t[12]=c,t[13]=u):u=t[13],u},po=t=>{const e=T.c(27),{onSubmit:n,isLoading:l}=t,{returnGroup:r}=se();let i;e[0]!==r.exchangeLineItems?(i=r.exchangeLineItems.filter(jo),e[0]=r.exchangeLineItems,e[1]=i):i=e[1];const o=i;let a;e[2]!==o?(a=new Set(o),e[2]=o,e[3]=a):a=e[3];const[d,c]=le.useState(a);if(!o)return null;const u=d.size!==1?"s":"";let m;e[4]!==d.size||e[5]!==u?(m=s.jsxs(ye,{children:["Remove ",d.size," item",u," ","from exchange"]}),e[4]=d.size,e[5]=u,e[6]=m):m=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(Oe,{children:"Choose which items to remove from the exchange order."}),e[7]=f):f=e[7];let h;e[8]!==m?(h=s.jsxs(Ie,{children:[m,f]}),e[8]=m,e[9]=h):h=e[9];let p;if(e[10]!==o||e[11]!==d){let v;e[13]!==d?(v=S=>{const{variant:C,discountedPrice:R}=S,w=`${S.platformProductId}-${S.platformVariantId}`;if(!C)return null;const _=d.has(S),I=[C.name,C.sku?`SKU: ${C.sku}`:null].filter(Boolean).join(" · ");return s.jsxs(Ls,{size:"sm",className:mt("cursor-pointer",_&&"bg-muted"),onClick:()=>{c(N=>{const A=new Set(N);return A.has(S)?A.delete(S):A.add(S),A})},children:[s.jsx(fn,{checked:_,tabIndex:-1,className:"pointer-events-none"}),s.jsx(Kn,{src:C.image?.url,alt:C.image?.altText||C.productName}),s.jsxs(Os,{children:[s.jsx(Ms,{children:C.productName}),I?s.jsx(Fs,{children:I}):null]}),R?s.jsx(zl,{children:s.jsx(Ds,{weight:"regular",children:fe(R.presentmentMoney,!0)})}):null]},w)},e[13]=d,e[14]=v):v=e[14],p=o.map(v),e[10]=o,e[11]=d,e[12]=p}else p=e[12];let x;e[15]!==p?(x=s.jsx(Ml,{children:p}),e[15]=p,e[16]=x):x=e[16];let j;e[17]!==n||e[18]!==d?(j=()=>n([...d]),e[17]=n,e[18]=d,e[19]=j):j=e[19];const g=l||d.size===0;let b;e[20]!==g||e[21]!==j?(b=s.jsx(Ne,{children:s.jsx(F,{type:"submit",onClick:j,disabled:g,children:"Submit"})}),e[20]=g,e[21]=j,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==x?(y=s.jsxs(ve,{className:"max-w-lg! flex flex-col space-y-3 mt-2",children:[h,x,b]}),e[23]=b,e[24]=h,e[25]=x,e[26]=y):y=e[26],y};function xo(){G.dismiss(),G.error("Failed to cancel exchange")}function go(t){return t.platformVariantId}function jo(t){return t.variant}const bo=()=>{const t=T.c(25),{returnGroup:e}=se(),{draftOrder:n,order:l,instantExchange:r}=e,{settings:i}=Ce(),o=i.exchangePolicy.instantExchangesEnabled;let a=null;if(n)if(n.order){let f;t[2]!==n.order.dateFulfilled?(f=n.order.dateFulfilled?`Fulfilled at ${n.order.dateFulfilled?.split(" ")[0]}.`:"Fulfill this order now that the returner has shipped back their item(s).",t[2]=n.order.dateFulfilled,t[3]=f):f=t[3];let h;t[4]!==f?(h=s.jsx("div",{children:f}),t[4]=f,t[5]=h):h=t[5];let p;t[6]!==n.order.platformId?(p=s.jsx(cn,{platformOrderId:n.order.platformId,children:"View Order"}),t[6]=n.order.platformId,t[7]=p):p=t[7];let x;t[8]!==h||t[9]!==p?(x=s.jsxs(s.Fragment,{children:[h,p]}),t[8]=h,t[9]=p,t[10]=x):x=t[10],a=x}else if(n.platformId){let f;t[11]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx("div",{children:"Wait for the returner to ship back their item(s) before fulfilling the exchange."}),t[11]=f):f=t[11];let h;t[12]!==n.platformId?(h=n.platformId.split("/").pop()||"",t[12]=n.platformId,t[13]=h):h=t[13];let p;t[14]!==h?(p=s.jsxs(s.Fragment,{children:[f,s.jsx(Dr,{platformDraftOrderId:h,children:"View Draft Order"})]}),t[14]=h,t[15]=p):p=t[15],a=p}else a="Shopify draft order will be created once you submit this return.";else if(e.isExchange&&e.status!==Fe.InReview){let f;t[0]!==l.platformId?(f=s.jsx(cn,{platformOrderId:l.platformId,children:"View Exchange Order"}),t[0]=l.platformId,t[1]=f):f=t[1],a=f}else e.status===Fe.InReview&&(a="Awaiting review of return.");if(!a&&!o&&!r)return null;let d;t[16]!==r||t[17]!==o?(d=o||r?s.jsxs(Se,{children:[s.jsx(be,{icon:na,children:"Instant Exchange"}),s.jsx(we,{children:r?"Yes":"No"})]}):null,t[16]=r,t[17]=o,t[18]=d):d=t[18];let c;t[19]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(be,{icon:Or,children:"Draft Order"}),t[19]=c):c=t[19];let u;t[20]!==a?(u=s.jsxs(Se,{children:[c,s.jsx(we,{children:a})]}),t[20]=a,t[21]=u):u=t[21];let m;return t[22]!==d||t[23]!==u?(m=s.jsxs("div",{className:"grid grid-cols-3 mt-4",children:[d,u]}),t[22]=d,t[23]=u,t[24]=m):m=t[24],m},Hn=t=>{const e=T.c(18),{image:n,productName:l,className:r,onClick:i}=t,[o,a]=le.useState(!1),d=n.url,c=n.altText||l;let u;e[0]!==r?(u=mt("cursor-pointer",r),e[0]=r,e[1]=u):u=e[1];let m;e[2]!==i?(m=g=>{i?.(g),a(!0)},e[2]=i,e[3]=m):m=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),a(!0))},e[4]=f):f=e[4];let h;e[5]!==n.url||e[6]!==c||e[7]!==u||e[8]!==m?(h=s.jsx(Kn,{src:d,alt:c,className:u,role:"button",tabIndex:0,onClick:m,onKeyDown:f}),e[5]=n.url,e[6]=c,e[7]=u,e[8]=m,e[9]=h):h=e[9];let p;e[10]!==n.url?(p=[{src:n.url}],e[10]=n.url,e[11]=p):p=e[11];let x;e[12]!==o||e[13]!==p?(x=s.jsx(On,{open:o,onOpenChange:a,slides:p}),e[12]=o,e[13]=p,e[14]=x):x=e[14];let j;return e[15]!==h||e[16]!==x?(j=s.jsxs(s.Fragment,{children:[h,x]}),e[15]=h,e[16]=x,e[17]=j):j=e[17],j},yo=()=>{const t=T.c(4),{returnGroup:e}=se(),{exchangeLineItems:n}=e;if(!n||n.length===0)return null;let l;t[0]!==n?(l=n.map(vo),t[0]=n,t[1]=l):l=t[1];let r;return t[2]!==l?(r=s.jsx("div",{className:"flex flex-col gap-4 mt-2",children:l}),t[2]=l,t[3]=r):r=t[3],r};function vo(t){const{variant:e,discountedPrice:n}=t;if(!e)return null;
35const l=[e.name,e.sku].filter(Boolean).join(" / ");return s.jsx(zs,{className:"gap-0 p-4",children:s.jsxs(Ls,{size:"lg",className:"border-0 bg-transparent p-0 shadow-none",children:[e.image?s.jsx(Hn,{image:e.image,productName:e.productName}):null,s.jsxs(Os,{children:[s.jsx(Ms,{children:e.productName}),l?s.jsx(Fs,{children:l}):null,n?.presentmentMoney?s.jsx(Ds,{children:fe(n.presentmentMoney,!0)}):null]})]})},t.frateExchangeId)}const So=t=>{const e=T.c(10),{isPending:n,onSubmit:l}=t,r=Ee();let i;e[0]!==r?(i=r.getDialogProps("processExchanges"),e[0]=r,e[1]=i):i=e[1];let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ie,{children:s.jsx(ye,{children:"Would you like to process an exchange manually?"})}),a=s.jsx(M,{size:"sm",className:"py-4",children:"This action cannot be undone. Are you sure you want to process an exchange manually?"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let d;e[4]!==n||e[5]!==l?(d=s.jsxs(ve,{children:[o,a,s.jsx(Ne,{children:s.jsx(F,{disabled:n,onClick:l,children:"Confirm"})})]}),e[4]=n,e[5]=l,e[6]=d):d=e[6];let c;return e[7]!==i||e[8]!==d?(c=s.jsx(je,{...i,children:d}),e[7]=i,e[8]=d,e[9]=c):c=e[9],c},No=()=>{const t=T.c(52),e=Ee(),{returnGroup:n,refetch:l}=se(),{exchangeLineItems:r,instantExchange:i,isExchange:o}=n,{settings:a}=Ce(),[d,c]=le.useState(!0),u=String(n.id);let m;t[0]!==u?(m=[u],t[0]=u,t[1]=m):m=t[1];const f=!!n.id&&n.status===Fe.Open&&o&&!i&&d&&!n.draftOrder;let h;t[2]!==m||t[3]!==f?(h={queryKey:m,enabled:f,refetchInterval:5e3},t[2]=m,t[3]=f,t[4]=h):h=t[4];let p;t[5]!==n.id?(p={returnGroupId:n.id},t[5]=n.id,t[6]=p):p=t[6];const{data:x,isFetching:j,refetch:g}=Lr(h,p);let b;t[7]!==e||t[8]!==g||t[9]!==l?(b={onSuccess:H=>{if(H.processExchanges.userErrors?.length){G.dismiss(),G.error(H.processExchanges.userErrors[0].message);return}G.dismiss(),G.success("Exchanges processed"),c(!1),e.close("processExchanges"),g(),l()},onError:Co},t[7]=e,t[8]=g,t[9]=l,t[10]=b):b=t[10];const{mutate:y,isPending:v}=Vr(b);let S;t[11]!==x?.processExchangeStatus.status?(S=()=>{[Qe.PlatformCreated,Qe.HoldForManualExchangeProcessing,Qe.ExchangeProcessed].includes(x?.processExchangeStatus?.status)&&c(!1)},t[11]=x?.processExchangeStatus.status,t[12]=S):S=t[12];const C=x?.processExchangeStatus.status;let R;t[13]!==C?(R=[C],t[13]=C,t[14]=R):R=t[14],le.useEffect(S,R),x?.processExchangeStatus.status;const w=x?.processExchangeStatus.status;let _;e:{const H=!!n.draftOrder,X=n.isExchangeFulfilled;if(n.status===Fe.InReview){_=!0;break e}if(!X){if(H){_=!0;break e}if([Qe.PlatformCreated,Qe.HoldForManualExchangeProcessing,Qe.ExchangeProcessed].includes(w)){_=!0;break e}}_=!1}const I=_;let N;t[15]!==I||t[16]!==w?(N=new Set,[Qe.PlatformCreated,Qe.HoldForManualExchangeProcessing].includes(w)&&N.add("Process Exchange"),I&&N.add("Cancel Exchange"),t[15]=I,t[16]=w,t[17]=N):N=t[17];const A=N;if(!r.length||!a)return null;const P=r.length;let k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(ft,{children:"Exchange Details"}),t[18]=k):k=t[18];let E;t[19]!==w?(E=w?w===Qe.HoldForManualExchangeProcessing?s.jsxs(it,{children:[s.jsx(vs,{}),il[w]]}):s.jsx(it,{children:il[w]}):null,t[19]=w,t[20]=E):E=t[20];let z;t[21]!==E?(z=s.jsxs("div",{className:"flex items-center gap-2",children:[k,E]}),t[21]=E,t[22]=z):z=t[22];let D;t[23]!==A||t[24]!==j||t[25]!==v||t[26]!==e?(D=A.size>0?s.jsxs(yt,{children:[s.jsx(vt,{render:_o}),s.jsxs(St,{className:"w-fit",children:[A.has("Process Exchange")?s.jsxs(Me,{onClick:()=>{e.open("processExchanges")},disabled:v||j,children:[s.jsx(Fl,{}),"Process Exchange"]}):null,A.has("Cancel Exchange")?s.jsxs(Me,{onClick:()=>{e.open("cancelExchange")},children:[s.jsx(In,{}),"Cancel Exchange"]}):null]})]}):null,t[23]=A,t[24]=j,t[25]=v,t[26]=e,t[27]=D):D=t[27];let $;t[28]!==D?($=s.jsx("div",{className:"flex items-center gap-2",children:D}),t[28]=D,t[29]=$):$=t[29];let O;t[30]!==z||t[31]!==$?(O=s.jsxs("div",{className:"flex justify-between items-center",children:[z,$]}),t[30]=z,t[31]=$,t[32]=O):O=t[32];let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(bo,{}),t[33]=q):q=t[33];let B;t[34]!==i||t[35]!==o||t[36]!==v||t[37]!==y||t[38]!==n.id?(B=o&&!i?s.jsx(So,{isPending:v,onSubmit:()=>y({returnGroupId:n.id})}):null,t[34]=i,t[35]=o,t[36]=v,t[37]=y,t[38]=n.id,t[39]=B):B=t[39];let V;t[40]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(ho,{}),t[40]=V):V=t[40];let L;t[41]!==O||t[42]!==B?(L=s.jsxs(Ze,{children:[O,q,B,V]}),t[41]=O,t[42]=B,t[43]=L):L=t[43];let K;t[44]!==P?(K=s.jsxs(M,{as:"h3",size:"lg",weight:"semibold",className:"mb-2",children:["Exchange Items (",P,")"]}),t[44]=P,t[45]=K):K=t[45];let W;t[46]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(yo,{}),t[46]=W):W=t[46];let te;t[47]!==K?(te=s.jsxs("div",{children:[K,W]}),t[47]=K,t[48]=te):te=t[48];let Z;return t[49]!==L||t[50]!==te?(Z=s.jsxs(s.Fragment,{children:[L,te]}),t[49]=L,t[50]=te,t[51]=Z):Z=t[51],Z},il={[Qe.HoldForManualExchangeProcessing]:"Held for Manual Exchange Processing",[Qe.PlatformCreated]:"Exchange on hold",[Qe.ExchangeProcessed]:"Exchange processed",[Qe.WaitingForPlatformCreation]:"Waiting for exch
35ange status"};function Co(){G.dismiss(),G.error("Failed to process exchanges")}function _o(t){const{children:e,...n}=t;return s.jsx(F,{variant:"ghost",size:"icon",...n,children:s.jsx(Ct,{})})}const Ro={[ct.ItemIsMissing]:"Item is missing",[ct.ItemRequiresCleaning]:"Item requires cleaning",[ct.PackagingMissing]:"Packaging missing",[ct.NotResellable]:"Not resellable",[ct.ReturnTagNotInPlace]:"Return tag not in place",[ct.SecurityTagNotInPlace]:"Security tag not in place",[ct.ShippingCarrierError]:"Shipping carrier error",[ct.SuspectedFraud]:"Suspected fraud",[ct.Other]:"Other",[ct.MetaOrder]:"Meta order"},wo=()=>{const t=T.c(14),{returnGroup:e}=se(),{flag:n}=e,{open:l}=Ee();if(!n)return null;let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(vs,{}),i=s.jsx(Tt,{children:"Flagged for Review"}),t[0]=r,t[1]=i):(r=t[0],i=t[1]);let o;t[2]!==n.reasons?(o=n.reasons.length>0?s.jsxs("p",{children:["Return has flagged for the following reasons:"," ",n.reasons.map((m,f)=>s.jsxs(le.Fragment,{children:[s.jsx("span",{className:"font-semibold",children:Ro[m]}),n.reasons.length-1===f?". ":", "]},m))]}):null,t[2]=n.reasons,t[3]=o):o=t[3];let a;t[4]!==n.comment?(a=n.comment?s.jsxs("div",{className:"mt-2",children:[s.jsx("span",{className:"font-semibold",children:"Comment:"}),s.jsx("div",{className:"whitespace-pre-line",children:n.comment})]}):null,t[4]=n.comment,t[5]=a):a=t[5];let d;t[6]!==o||t[7]!==a?(d=s.jsxs(Gt,{children:[o,a]}),t[6]=o,t[7]=a,t[8]=d):d=t[8];let c;t[9]!==l?(c=s.jsx(Mi,{children:s.jsx(F,{size:"xs",variant:"outline",className:"mt-2",onClick:()=>{l("flag")},children:"View Flag"})}),t[9]=l,t[10]=c):c=t[10];let u;return t[11]!==d||t[12]!==c?(u=s.jsxs(xt,{variant:"warning",children:[r,i,d,c]}),t[11]=d,t[12]=c,t[13]=u):u=t[13],u},Io=Pn({queryKey:["fraudCustomerAnomalies"],meta:{errorMessage:"Failed to load fraud anomalies"}},he` 36 query FraudCustomerAnomalies($email: String!) { 37 fraudCustomerAnomalies(email: $email) { 38 results { 39 anomalyType 40 metricType 41 value 42 expectedValue 43 deviation 44 severity 45 score 46 timestamp 47 } 48 } 49 } 50 `),Eo=Pn({queryKey:["fraudCustomerDetails"],meta:{errorMessage:"Failed to load fraud insights"}},he` 51 query FraudCustomerDetails($email: String!) { 52 fraudCustomerDetails(email: $email) { 53 abuseScore 54 action 55 triggeredWorkflow { 56 ruleName 57 ruleDesc 58 variables { 59 name 60 varDesc 61 value 62 } 63 } 64 reasoning 65 totalOrders 66 totalReturns 67 orderValue 68 averageOrderValue 69 lifetimeValue 70 returnRate 71 restockingRate 72 pin 73 email 74 connected { 75 email 76 customerName 77 lastEventTime 78 } 79 } 80 } 81 `),Ao=t=>t?!!(t.abuseScore!=null||t.action||t.reasoning||(t.triggeredWorkflow?.length??0)>0||t.totalOrders!=null||t.totalReturns!=null||t.orderValue!=null||t.averageOrderValue!=null||t.lifetimeValue!=null||t.returnRate!=null||t.restockingRate!=null||(t.connected??[]).some(e=>!!e.email)):!1,ql=t=>t==null?"none":t>=80?"high":t>=50?"medium":t>0?"low":"none",$o={high:"High risk",medium:"Medium risk",low:"Low risk",none:""},ko={high:"bg-destructive/10 text-destructive",medium:"bg-amber-50 text-amber-700",low:"bg-muted text-muted-foreground",none:""},Po=t=>{const e=(t??"").toLowerCase();return e.includes("decline")||e.includes("reject")?Wn:e.includes("review")||e.includes("flag")?An:Yl},To=(t,e)=>{const n=`${t??""} ${e??""}`.toLowerCase();return n.includes("ai")||n.includes("photo")||n.includes("image")?ta:n.includes("window")||n.includes("time")||n.includes("late")?Ri:An},Go=t=>{const e=(t??"").toLowerCase();return e==="high"||e==="critical"},zo=t=>t?t.replace(/[_-]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()):"Anomaly",Mo=t=>t==null?"â":`${Math.round(t*100)}%`,st=t=>{const e=T.c(16),{title:n,icon:l,headerRight:r,className:i,children:o}=t;let a;e[0]!==i?(a=mt("flex flex-col gap-3",i),e[0]=i,e[1]=a):a=e[1];let d;e[2]!==l?(d=l?s.jsx(l,{className:"w-4 h-4 text-muted-foreground"}):null,e[2]=l,e[3]=d):d=e[3];let c;e[4]!==n?(c=s.jsx(M,{as:"h4",size:"sm",weight:"semibold",children:n}),e[4]=n,e[5]=c):c=e[5];let u;e[6]!==d||e[7]!==c?(u=s.jsxs("div",{className:"flex items-center gap-2",children:[d,c]}),e[6]=d,e[7]=c,e[8]=u):u=e[8];let m;e[9]!==r||e[10]!==u?(m=s.jsxs("div",{className:"flex items-center justify-between",children:[u,r]}),e[9]=r,e[10]=u,e[11]=m):m=e[11];let f;return e[12]!==o||e[13]!==a||e[14]!==m?(f=s.jsxs("div",{className:a,children:[m,o]}),e[12]=o,e[13]=a,e[14]=m,e[15]=f):f=e[15],f},Bl=t=>{const e=T.c(6),{band:n,score:l}=t;if(n==="none"||l==null)return null;const r=ko[n];let i;e[0]!==r?(i=mt("text-xs font-medium px-2 py-0.5 rounded-full",r),e[0]=r,e[1]=i):i=e[1];const o=$o[n];let a;return e[2]!==l||e[3]!==i||e[4]!==o?(a=s.jsxs("span",{className:i,children:[o," · ",l]}),e[2]=l,e[3]=i,e[4]=o,e[5]=a):a=e[5],a},Kl=t=>{const e=T.c(2),{message:n}=t;let l;return e[0]!==n?(l=s.jsx("div",{className:"rounded-md border border-dashed border-border p-4 text-center",children:s.jsx(M,{size:"sm",tone:"muted",children:n})}),e[0]=n,e[1]=l):l=e[1],l},Fo=t=>{const e=T.c(2),{pin:n}=t;if(!n)return null;let l;return e[0]!==n?(l=s.jsxs(M,{as:"span",size:"xs",tone:"muted",className:"font-mono",children:["PIN-",n]}),e[0]=n,e[1]=l):l=e[1],l},Do=t=>{const e=T.c(20),{anomaly:n}=t;let l;e[0]!==n.anomalyType||e[1]!==n.metricType?(l=To(n.anomalyType,n.metricType),e[0]=n.anomalyType,e[1]=n.metricType,e[2]=l):l=e[2];const r=l,i=Go(n.severity);let o;e[3]!==n.expectedValue||e[4]!==n.metricType||e[5]!==n.value?(o=[],n.metricType&&o.push(n.metricType),n.value!=null&&n.expectedValue!=null&&o.push(`Value ${n.value} vs expected ${n.expectedValue}.`),e[3]=n.expectedValue,e[4]=n.metricType,e[5]=n.value,e[6]=o):o=e[6];const a=o.join(". "),d=i?"destructive":"warning";let c;e[7]!==r?(c=s.jsx(r,{}),e[7]=r,e[8]=c):c=e[8];let u;e[9]!==n.anomalyType?(u=zo(n.anomalyType),e[9]=n.anomalyType,e[10]=u):u=e[10];let m;e[11]!==u?(m=s.jsx(Tt,{children:u}),e[11]=u,e[12]=m):m=e[12];let f;e[13]!==a?(f=a?s.jsx(Gt,{children:a}):null,e[13]=a,e[14]=f):f=e[14];let h;return e[15]!==d||e[16]!==c||e[17]!==m||e[18]!==f?(h=s.jsxs(xt,{appearance:"soft",variant:d,children:[c,m,f]}),e[15]=d,e[16]=c,e[17]=m,e[18]=f,e[19]=h):h=e[19],h},al=t=>{const e=T.c(6),{anomalies:n,isLoading:l}=t;if(l){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(st,{title:"Behavior Alerts",icon:Cn,children:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(re,{className:"h-12 w-full"}),s.jsx(re,{className:"h-12 w-full"})]})}),e[0]=o):o=e[0],o}if(!n.length){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(st,{title:"Behavior Alerts",icon:Cn,children:s.jsx(Kl,{message:"No behavior alerts for this customer."})}),e[1]=o):o=e[1],o}let r;e[2]!==n?(r=n.map(Oo),e[2]=n,e[3]=r):r=e[3];let i;return e[4]!==r?(i=s.jsx(st,{title:"Behavior Alerts",icon:Cn,children:s.jsx("div",{className:"flex flex-col gap-2",children:r})}),e[4]=r,e[5]=i):i=e[5],i};function Oo(t,e){return s.jsx(Do,{anomaly:t},`${t.anomalyType}-${t.timestamp}-${e}`)}const _n=t=>{const e=T.c(13),{label:n,value:l,subtext:r,negative:i}=t;let o;e[0]!==n?(o=s.jsx("span",{className:"text-[10px] font-semibold tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=o):o=e[1];const a=i?"text-destructive":"text-foreground";let d;e[2]!==a?(d=mt("text-2xl font-semibold",a),e[2]=a,e[3]=d):d=e[3];let c;e[4]!==d||e[5]!==l?(c=s.jsx("span",{className:d,children:l}),e[4]=d,e[5]=l,e[6]=c):c=e[6];let u;e[7]!==r?(u=r?s.jsx(M,{size:"xs",tone:"muted",children:r}):null,e[7]=r,e[8]=u):u=e[8];let m;return e[9]!==o||e[10]!==c||e[11]!==u?(m=s.jsxs("div",{className:"bg-muted/40 rounded-lg p-3 flex flex-col gap-0.5",children:[o,c,u]}),e[9]=o,e[10]=c,e[11]=u,e[12]=m):m=e[12],m},Lo=t=>{const e=T.c(24),{details:n}=t,{shop:l}=Ce(),r=l.shopCurrencyCode;let i;e[0]!==r||e[1]!==n.orderValue?(i=n.orderValue!=null?fe({amount:n.orderValue,currencyCode:r}):null,e[0]=r,e[1]=n.orderValue,e[2]=i):i=e[2];const o=i;let a;e[3]!==r||e[4]!==n.averageOrderValue?(a=n.averageOrderValue!=null?fe({amount:n.averageOrderValue,currencyCode:r}):null,e[3]=r,e[4]=n.averageOrderValue,e[5]=a):a=e[5];const d=a;let c;e[6]!==r||e[7]!==n.lifetimeValue?(c=n.lifetimeValue!=null?fe({amount:n.lifetimeValue,currencyCode:r}):"â",e[6]=r,e[7]=n.lifetimeValue,e[8]=c):c=e[8];const u=c,m=n.totalOrders!=null?String(n.totalOrders):"â";let f;e[9]!==o||e[10]!==m?(f=s.jsx(_n,{label:"Orders",value:m,subtext:o}),e[9]=o,e[10]=m,e[11]=f):f=e[11];let h;e[12]!==n.returnRate?(h=Mo(n.returnRate),e[12]=n.returnRate,e[13]=h):h=e[13];let p;e[14]!==d||e[15]!==h?(p=s.jsx(_n,{label:"Return rate",value:h,subtext:d}),e[14]=d,e[15]=h,e[16]=p):p=e[16];const x=(n.lifetimeValue??0)<0;let j;e[17]!==u||e[18]!==x?(j=s.jsx(_n,{label:"True LTV",value:u,subtext:"net of costs",negative:x}),e[17]=u,e[18]=x,e[19]=j):j=e[19];let g;return e[20]!==f||e[21]!==p||e[22]!==j?(g=s.jsx(st,{title:"Customer Snapshot",icon:Jl,children:s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[f,p,j]})}),e[20]=f,e[21]=p,e[22]=j,e[23]=g):g=e[23],g},Vo=t=>{const e=T.c(2),{children:n}=t;let l;return e[0]!==n?(l=s.jsx("span",{className:"bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",children:n}),e[0]=n,e[1]=l):l=e[1],l},Wl=t=>{const e=T.c(7),{email:n,label:l}=t;let r;e[0]!==n?(r=s.jsx(M,{as:"span",size:"sm",className:"font-mono",children:n}),e[0]=n,e[1]=r):r=e[1];let i;e[2]!==l?(i=s.jsx(Vo,{children:l}),e[2]=l,e[3]=i):i=e[3];let o;return e[4]!==r||e[5]!==i?(o=s.jsxs("div",{className:"flex justify-between items-center py-2",children:[r,i]}),e[4]=r,e[5]=i,e[6]=o):o=e[6],o},Uo=t=>{const e=T.c(32),{details:n,primaryEmail:l}=t;let r,i,o,a,d,c,u,m,f;if(e[0]!==n.connected||e[1]!==n.email||e[2]!==n.pin||e[3]!==l){f=Symbol.for("react.early_return_sentinel");
81e:{const j=(n.connected??[]).map(qo).filter(Bo);if(!j.length){f=null;break e}const g=j.length+1;r=st,c="Related Identities",u=Fi,e[13]!==n.pin?(m=s.jsx(Fo,{pin:n.pin}),e[13]=n.pin,e[14]=m):m=e[14],e[15]!==g?(d=s.jsxs("span",{className:"text-[10px] font-semibold tracking-wide text-muted-foreground uppercase",children:["Emails (",g,")"]}),e[15]=g,e[16]=d):d=e[16],i="divide-y divide-border mt-1";const b=n.email??l;e[17]!==b?(o=s.jsx(Wl,{email:b,label:"primary"}),e[17]=b,e[18]=o):o=e[18],a=j.map(Ko)}e[0]=n.connected,e[1]=n.email,e[2]=n.pin,e[3]=l,e[4]=r,e[5]=i,e[6]=o,e[7]=a,e[8]=d,e[9]=c,e[10]=u,e[11]=m,e[12]=f}else r=e[4],i=e[5],o=e[6],a=e[7],d=e[8],c=e[9],u=e[10],m=e[11],f=e[12];if(f!==Symbol.for("react.early_return_sentinel"))return f;let h;e[19]!==i||e[20]!==o||e[21]!==a?(h=s.jsxs("div",{className:i,children:[o,a]}),e[19]=i,e[20]=o,e[21]=a,e[22]=h):h=e[22];let p;e[23]!==d||e[24]!==h?(p=s.jsxs("div",{children:[d,h]}),e[23]=d,e[24]=h,e[25]=p):p=e[25];let x;return e[26]!==r||e[27]!==p||e[28]!==c||e[29]!==u||e[30]!==m?(x=s.jsx(r,{title:c,icon:u,headerRight:m,children:p}),e[26]=r,e[27]=p,e[28]=c,e[29]=u,e[30]=m,e[31]=x):x=e[31],x};function qo(t){return t.email}function Bo(t){return!!t}function Ko(t){return s.jsx(Wl,{email:t,label:"alias"},t)}const Wo={high:"destructive",medium:"warning",low:"default",none:"default"},Qo=t=>{const e=T.c(20),{details:n,orderName:l}=t;let r;e[0]!==n.abuseScore?(r=ql(n.abuseScore),e[0]=n.abuseScore,e[1]=r):r=e[1];const i=r;let o;e[2]!==n.action?(o=Po(n.action),e[2]=n.action,e[3]=o):o=e[3];const a=o,d=n.action&&l?`${n.action} ${l}`:n.action??"",c=n.triggeredWorkflow.length>0;let u;e[4]!==i||e[5]!==n.abuseScore?(u=s.jsx(Bl,{band:i,score:n.abuseScore}),e[4]=i,e[5]=n.abuseScore,e[6]=u):u=e[6];let m;e[7]!==a||e[8]!==i||e[9]!==n.action||e[10]!==d?(m=n.action?s.jsxs(xt,{appearance:"soft",variant:Wo[i],children:[s.jsx(a,{}),s.jsx(Tt,{children:"Recommendation"}),s.jsx(Gt,{children:d})]}):null,e[7]=a,e[8]=i,e[9]=n.action,e[10]=d,e[11]=m):m=e[11];let f;e[12]!==n.reasoning||e[13]!==n.triggeredWorkflow||e[14]!==c?(f=n.reasoning||c?s.jsxs(M,{as:"ul",size:"sm",className:"list-disc pl-5 space-y-1",children:[n.reasoning?s.jsx("li",{children:n.reasoning}):null,c?s.jsxs("li",{children:["Triggered workflows:",s.jsx("ul",{className:"list-disc pl-5 mt-1 space-y-1",children:n.triggeredWorkflow.map(Ho)})]}):null]}):null,e[12]=n.reasoning,e[13]=n.triggeredWorkflow,e[14]=c,e[15]=f):f=e[15];let h;return e[16]!==u||e[17]!==m||e[18]!==f?(h=s.jsxs(st,{title:"Risk Assessment",icon:ms,headerRight:u,children:[m,f]}),e[16]=u,e[17]=m,e[18]=f,e[19]=h):h=e[19],h};function Ho(t){return s.jsxs("li",{children:[s.jsx(M,{as:"span",size:"sm",weight:"medium",children:t.ruleName}),t.ruleDesc?s.jsxs(M,{as:"span",size:"sm",tone:"muted",children:[" â ",t.ruleDesc]}):null]},t.ruleName)}const Zo=Date.now(),wt=t=>Zo-t*24*60*60*1e3,Yo={__typename:"FraudCustomerDetails",abuseScore:87,action:"Decline",triggeredWorkflow:[{__typename:"FraudTriggeredWorkflow",ruleName:"Short Usage Period",ruleDesc:"Flags potential wardrobing if the item is returned within a short time after purchase.",variables:[{__typename:"FraudWorkflowVariable",name:"Usage_Perio
81d",varDesc:"Number of days between order and return.",value:0},{__typename:"FraudWorkflowVariable",name:"Short_Usage_Days",varDesc:"The maximum number of days considered for short usage.",value:14}]},{__typename:"FraudTriggeredWorkflow",ruleName:"Repeat Offense",ruleDesc:"Flags potential abuse when a customer has multiple suspect orders.",variables:[{__typename:"FraudWorkflowVariable",name:"Suspect_Orders",varDesc:"Number of suspect orders.",value:96},{__typename:"FraudWorkflowVariable",name:"Suspect_Threshold",varDesc:"Threshold for suspect orders to flag abuse.",value:2}]}],reasoning:"Return rate of 75% is well above the store average of 18%, with repeated wardrobing patterns across multiple linked accounts.",totalOrders:24,totalReturns:18,orderValue:142.5,averageOrderValue:98.2,lifetimeValue:-340,returnRate:.75,restockingRate:.12,productReturnRate:.68,pin:"4827",email:"[email protected]",connected:[{__typename:"FraudConnectedAccount",email:"[email protected]",customerName:"Jordan Doe",lastEventTime:wt(3)},{__typename:"FraudConnectedAccount",email:"[email protected]",customerName:"Jordan D.",lastEventTime:wt(11)},{__typename:"FraudConnectedAccount",email:"[email protected]",customerName:"J Doe",lastEventTime:wt(42)}],items:[],keeps:[],lastReturnDate:wt(2),lastReturnDecision:"declined",storeAverageOrderValue:86,storeAverageRestockingRate:.45,storeAverageReturnRate:.18,topReturnReason:"Changed my mind",topReturnReasonPercentage:.41,topReturnReasons:["Changed my mind","Doesn't fit","Found cheaper elsewhere"],raw:{}},Jo=[{__typename:"FraudCustomerAnomaly",anomalyType:"ai_generated_photo",metricType:"Return evidence",value:.92,expectedValue:.05,deviation:.87,severity:"high",score:.94,timestamp:wt(2)},{__typename:"FraudCustomerAnomaly",anomalyType:"late_return_window",metricType:"Days since delivery",value:58,expectedValue:30,deviation:28,severity:"high",score:.81,timestamp:wt(5)},{__typename:"FraudCustomerAnomaly",anomalyType:"high_return_velocity",metricType:"Returns per 30 days",value:6,expectedValue:1,deviation:5,severity:"medium",score:.63,timestamp:wt(9)}],Xo={__typename:"FraudCustomerDetails",abuseScore:null,action:null,triggeredWorkflow:[],reasoning:null,totalOrders:null,totalReturns:null,orderValue:null,averageOrderValue:null,lifetimeValue:null,returnRate:null,restockingRate:null,productReturnRate:null,pin:null,email:"[email protected]",connected:[],items:[],keeps:[],lastReturnDate:null,lastReturnDecision:null,storeAverageOrderValue:null,storeAverageRestockingRate:null,storeAverageReturnRate:null,topReturnReason:null,topReturnReasonPercentage:null,topReturnReasons:[],raw:{}},ec=[];function tc(){return!1}function sc(){return!1}const nc=()=>{const t=T.c(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs(st,{title:"Risk Assessment",icon:ms,children:[s.jsx(re,{className:"h-14 w-full"}),s.jsx(re,{className:"h-3 w-3/4"}),s.jsx(re,{className:"h-3 w-1/2"})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(st,{title:"Customer Snapshot",icon:ms,children:s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsx(re,{className:"h-20"}),s.jsx(re,{className:"h-20"}),s.jsx(re,{className:"h-20"})]})}),t[1]=n):n=t[1];let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs(st,{title:"Behavior Alerts",icon:ms,children:[s.jsx(re,{className:"h-12 w-full"}),s.jsx(re,{className:"h-12 w-full"})]}),t[2]=l):l=t[2];let r;return t[3]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs(s.Fragment,{children:[e,n,l,s.jsxs(st,{title:"Related Identities",icon:ms,children:[s.jsx(re,{className:"h-5 w-1/3"}),s.jsx(re,{className:"h-5 w-full"}),s.jsx(re,{className:"h-5 w-full"})]})]}),t[3]=r):r=t[3],r},lc=()=>{const t=T.c(53),{settings:e}=Ce(),{returnGroup:n}=se();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=tc(),t[0]=l):l=t[0];const r=l;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=sc(),t[1]=i):i=t[1];const o=i,a=r||o,d=n.order.customer?.email??null,c=(e.fraudPolicy?.enabled??!1)||a,u=d??"";let m;t[2]!==u?(m=[u],t[2]=u,t[3]=m):m=t[3];const f=c&&!!d&&!a;let h;t[4]!==m||t[5]!==f?(h={queryKey:m,enabled:f},t[4]=m,t[5]=f,t[6]=h):h=t[6];const p=d??"";let x;t[7]!==p?(x={email:p},t[7]=p,t[8]=x):x=t[8];const j=Eo(h,x),g=d??"";let b;t[9]!==g?(b=[g],t[9]=g,t[10]=b):b=t[10];const y=c&&!!d&&!a;let v;t[11]!==y||t[12]!==b?(v={queryKey:b,enabled:y},t[11]=y,t[12]=b,t[13]=v):v=t[13];const S=d??"";let C;t[14]!==S?(C={email:S},t[14]=S,t[15]=C):C=t[15];const R=Io(v,C),[w,_]=le.useState(null),I=o?Xo:Yo,N=o?ec:Jo,A=d??I.email??"";if(!a&&(!c||!d))return null;const P=!a&&(j.isLoading||R.isLoading)&&!j.data&&!R.data,k=a?I:j.data?.fraudCustomerDetails;let E;t[16]!==R?(E=a?N:R.data?.fraudCustomerAnomalies?.results??[],t[16]=R,t[17]=E):E=t[17];const z=E;if(!a&&!P&&j.isError)return null;let D;t[18]!==k?(D=Ao(k),t[18]=k,t[19]=D):D=t[19];const $=!D,O=z.length>0,q=!P&&$&&!O,B=!!(k?.action||k?.reasoning||(k?.triggeredWorkflow?.length??0)>0);let V;t[20]!==k?.connected?(V=k?.connected??[],t[20]=k?.connected,t[21]=V):V=t[21];let L;t[22]!==V?(L=V.some(rc),t[22]=V,t[23]=L):L=t[23];const W=!B&&!O&&!L,te=k?.abuseScore;let Z;t[24]!==te?(Z=ql(te),t[24]=te,t[25]=Z):Z=t[25];
81const H=Z,X=q||!!k&&((k.abuseScore??0)<50||W),Q=w??!X;let Y;t[26]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-center",children:[s.jsx(Di,{className:"h-8 w-8 text-muted-foreground"}),s.jsx(M,{size:"sm",weight:"medium",children:"No fraud insights for this customer"}),s.jsx(M,{size:"xs",tone:"muted",children:"We didn't find any risk signals, behavior alerts, or related identities."})]}),t[26]=Y):Y=t[26];const ne=Y;let ee;t[27]!==z||t[28]!==R||t[29]!==k||t[30]!==$||t[31]!==A||t[32]!==P||t[33]!==n.order.name?(ee=s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-6",children:P?s.jsx(nc,{}):!k||$?s.jsxs(s.Fragment,{children:[s.jsx(st,{title:"Risk Assessment",icon:ms,children:s.jsx(Kl,{message:"No fraud profile available for this customer."})}),s.jsx(al,{anomalies:z,isLoading:!a&&R.isLoading})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qo,{details:k,orderName:n.order.name}),s.jsx(Lo,{details:k}),s.jsx(al,{anomalies:z,isLoading:!a&&R.isLoading}),s.jsx(Uo,{details:k,primaryEmail:A})]})}),t[27]=z,t[28]=R,t[29]=k,t[30]=$,t[31]=A,t[32]=P,t[33]=n.order.name,t[34]=ee):ee=t[34];const J=q?ne:ee;let de;t[35]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsxs(ft,{className:"flex items-center gap-2",children:[s.jsx("span",{"aria-hidden":!0,className:"bg-primary size-5 shrink-0",style:{maskImage:`url(${Zn})`,WebkitMaskImage:`url(${Zn})`,maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",maskSize:"contain",WebkitMaskSize:"contain",maskPosition:"center",WebkitMaskPosition:"center"}}),"Route Compass"]}),t[35]=de):de=t[35];const oe=de;let me;t[36]!==k?.abuseScore||t[37]!==Q||t[38]!==H?(me=Q?null:s.jsx(Bl,{band:H,score:k?.abuseScore}),t[36]=k?.abuseScore,t[37]=Q,t[38]=H,t[39]=me):me=t[39];const pe=Q&&"rotate-180";let Ae;t[40]!==pe?(Ae=mt("size-4 text-muted-foreground transition-transform",pe),t[40]=pe,t[41]=Ae):Ae=t[41];let $e;t[42]!==Ae?($e=s.jsx(Gl,{className:Ae}),t[42]=Ae,t[43]=$e):$e=t[43];let ke;t[44]!==me||t[45]!==$e?(ke=s.jsxs(ml,{className:"flex w-full items-center justify-between gap-2",children:[oe,s.jsxs("div",{className:"flex items-center gap-2",children:[me,$e]})]}),t[44]=me,t[45]=$e,t[46]=ke):ke=t[46];let Te;t[47]!==J?(Te=s.jsx(fl,{children:s.jsx("div",{className:"mt-4",children:J})}),t[47]=J,t[48]=Te):Te=t[48];let Le;return t[49]!==Q||t[50]!==ke||t[51]!==Te?(Le=s.jsx(Ze,{className:"w-full",children:s.jsxs(hl,{open:Q,onOpenChange:_,children:[ke,Te]})}),t[49]=Q,t[50]=ke,t[51]=Te,t[52]=Le):Le=t[52],Le};function rc(t){return!!t.email}const ic=()=>{const t=T.c(6),{returnGroup:e}=se(),{giftReceiverEmail:n}=e;if(!n)return null;let l,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(fr,{}),r=s.jsx(Tt,{children:"Gift return"}),t[0]=l,t[1]=r):(l=t[0],r=t[1]);let i;t[2]!==n?(i=n?s.jsxs(M,{as:"span",weight:"semibold",children:["The gift receiver email is ",n,"."]}):null,t[2]=n,t[3]=i):i=t[3];let o;return t[4]!==i?(o=s.jsxs(xt,{children:[l,r,s.jsxs(Gt,{children:[s.jsxs("p",{children:["This order is a gift. The return will be processed as a gift return."," ",i]})," "]})]}),t[4]=i,t[5]=o):o=t[5],o},ac=t=>{const e=T.c(10),{tags:n,overlap:l}=t,r=l===void 0?!0:l,i=r?"h-[26px]":"space-x-2";let o;e[0]!==i?(o=dt("relative flex",i),e[0]=i,e[1]=o):o=e[1];let a;if(e[2]!==r||e[3]!==n){let c;e[5]!==r?(c=(u,m)=>s.jsxs(hs,{children:[s.jsx(ps,{nativeButton:!1,render:s.jsx(it,{className:r?"absolute":void 0,style:r?{top:0,left:m*48}:void 0,children:u.name})}),s.jsx(xs,{children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx(M,{size:"xs",tone:"muted",children:"Description"}),s.jsx(ws,{as:"div",children:u.description})]})})]},u.name),e[5]=r,e[6]=c):c=e[6],a=n.map(c),e[2]=r,e[3]=n,e[4]=a}else a=e[4];let d;return e[7]!==o||e[8]!==a?(d=s.jsx("div",{className:o,children:a}),e[7]=o,e[8]=a,e[9]=d):d=e[9],d},oc=()=>{const t=T.c(22),{open:e}=Ee(),{returnGroup:n}=se(),{creditMethod:l,returnMethod:r,returns:i,exchangeLineItems:o,tags:a}=n,d=i.some(cc)||!!o?.length;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(be,{icon:un,children:"Return Method"}),t[0]=c):c=t[0];let u;t[1]!==r?(u=s.jsxs(Se,{children:[c,s.jsx(we,{className:"flex",children:s.jsx(Ur,{returnMethod:r})})]}),t[1]=r,t[2]=u):u=t[2];let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(be,{icon:En,children:"Credit Method"}),t[3]=m):m=t[3];const f=hr[l];let h;t[4]!==e||t[5]!==n?(h=Ln(n)?s.jsx(F,{className:"ml-1",size:"icon-xs",variant:"link",onClick:()=>{e("creditMethod")},children:s.jsx(bs,{})}):null,t[4]=e,t[5]=n,t[6]=h):h=t[6];let p;t[7]!==f.label||t[8]!==h?(p=s.jsxs(Se,{children:[m,s.jsxs(we,{className:"flex items-center",children:[f.label,h]})]}),t[7]=f.label,t[8]=h,t[9]=p):p=t[9];let x;t[10]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(be,{icon:Nl,children:"Is Exchange?"}),t[10]=x):x=t[10];const j=d?"Yes":"No";let g;t[11]!==j?(g=s.jsxs(Se,{children:[x,s.jsx(we,{children:j})]}),t[11]=j,t[12]=g):g=t[12];let b;t[13]!==u||t[14]!==p||t[15]!==g?(b=s.jsxs("div",{className:"grid grid-cols-3 gap-y-4",children:[u,p,g]}
81),t[13]=u,t[14]=p,t[15]=g,t[16]=b):b=t[16];let y;t[17]!==a?(y=a&&a.length>0?s.jsx("div",{className:"mt-3",children:s.jsxs(Se,{children:[s.jsx(be,{icon:Vn,children:"Tags"}),s.jsx(we,{children:s.jsx(ac,{overlap:!1,tags:a})})]})}):null,t[17]=a,t[18]=y):y=t[18];let v;return t[19]!==y||t[20]!==b?(v=s.jsxs(Ze,{children:[b,y]}),t[19]=y,t[20]=b,t[21]=v):v=t[21],v};function cc(t){return t.isExchange}const ol=t=>{const e=T.c(22),{text:n}=t,[l,r]=le.useState(!1),i=n.length>120;let o,a;e[0]!==l?(o=()=>r(!l),a=()=>{r(!l)},e[0]=l,e[1]=o,e[2]=a):(o=e[1],a=e[2]);const d=i?"cursor-pointer":"cursor-default";let c;e[3]!==d?(c=mt("text-sm text-left wrap-break-word",d),e[3]=d,e[4]=c):c=e[4];let u;e[5]!==l||e[6]!==n?(u=l?n:n.slice(0,120),e[5]=l,e[6]=n,e[7]=u):u=e[7];let m;e[8]!==l||e[9]!==i?(m=i&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"..."})," ",s.jsxs("span",{className:"text-primary font-semibold",children:["Show ",l?"less":"more"]})]}),e[8]=l,e[9]=i,e[10]=m):m=e[10];let f;e[11]!==o||e[12]!==a||e[13]!==c||e[14]!==u||e[15]!==m?(f=s.jsxs("button",{type:"button",tabIndex:-1,onClick:o,onKeyDown:a,className:c,children:[u,m]}),e[11]=o,e[12]=a,e[13]=c,e[14]=u,e[15]=m,e[16]=f):f=e[16];let h;e[17]!==n?(h=s.jsx("p",{className:"sr-only",children:n}),e[17]=n,e[18]=h):h=e[18];let p;return e[19]!==f||e[20]!==h?(p=s.jsxs("div",{children:[f,h]}),e[19]=f,e[20]=h,e[21]=p):p=e[21],p},dc=t=>{const e=T.c(49),{isOpen:n,onOpenChange:l,return_:r}=t,{returnGroup:i,refetch:o}=se(),{lineItem:a}=r,{productName:d}=a,[c,u]=le.useState(!0),[m,f]=le.useState("");let h;e[0]!==l||e[1]!==o?(h={onSuccess:()=>{G.success("Return canceled successfully"),l(!1),o()},onError:()=>{G.error("Something went wrong when canceling the return"),l(!1),o()}},e[0]=l,e[1]=o,e[2]=h):h=e[2];const{mutate:p,isPending:x}=qr(h);let j;e[3]!==l?(j=O=>l(O),e[3]=l,e[4]=j):j=e[4];let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(ye,{children:"Cancel This Return?"}),e[5]=g):g=e[5];let b,y;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx("li",{children:"Remove this item from the refund"}),y=s.jsx("li",{children:"Notify the customer that the return has been cancelled"}),e[6]=b,e[7]=y):(b=e[6],y=e[7]);let v;e[8]!==i.isExchange||e[9]!==i.isExchangeFulfilled?(v=i.isExchange?i.isExchangeFulfilled?s.jsx("li",{children:"Charge the customer for the exchange"}):s.jsx("li",{children:"Cancel the exchange order"}):null,e[8]=i.isExchange,e[9]=i.isExchangeFulfilled,e[10]=v):v=e[10];let S;e[11]!==v?(S=s.jsxs("ul",{className:"list-disc ml-4 mt-2 mb-2",children:[b,y,v]}),e[11]=v,e[12]=S):S=e[12];let C;e[13]!==d||e[14]!==S?(C=s.jsxs(Oe,{children:["Are you sure you want to cancel the return for ",d,"? This will:",S,"This action cannot be undone."]}),e[13]=d,e[14]=S,e[15]=C):C=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=O=>{u(!!O)},e[16]=R):R=e[16];let w;e[17]!==c?(w=s.jsx(fn,{id:"sendEmail",checked:c,onCheckedChange:R}),e[17]=c,e[18]=w):w=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(nt,{htmlFor:"sendEmail",children:"Notify Customer"}),e[19]=_):_=e[19];let I;e[20]!==w?(I=s.jsxs(xe,{orientation:"horizontal",children:[w,_]}),e[20]=w,e[21]=I):I=e[21];let N;e[22]!==m||e[23]!==c?(N=c?s.jsxs(xe,{children:[s.jsx(nt,{htmlFor:"cancellationNote",children:"Cancellation Note"}),s.jsx(mn,{id:"cancellationNote",className:"wrap-anywhere",rows:2,name:"cancellationNote",maxLength:300,value:m,onChange:O=>{f(O.currentTarget.value)},placeholder:"Please explain why this return is being cancelled..."})]}):null,e[22]=m,e[23]=c,e[24]=N):N=e[24];let A;e[25]!==I||e[26]!==N?(A=s.jsxs("div",{className:"space-y-2",children:[I,N]}),e[25]=I,e[26]=N,e[27]=A):A=e[27];let P;e[28]!==l?(P=s.jsx(F,{variant:"outline",onClick:()=>l(!1),children:"Keep Return"}),e[28]=l,e[29]=P):P=e[29];let k;e[30]!==m||e[31]!==p||e[32]!==r.id||e[33]!==c?(k=()=>p({returnId:r.id,cancellationNote:m,sendCancellationEmail:c}),e[30]=m,e[31]=p,e[32]=r.id,e[33]=c,e[34]=k):k=e[34];let E;e[35]!==x||e[36]!==k?(E=s.jsx(F,{variant:"destructive",onClick:k,disabled:x,children:"Cancel Return"}),e[35]=x,e[36]=k,e[37]=E):E=e[37];let z;e[38]!==P||e[39]!==E?(z=s.jsxs(Ne,{children:[P,E]}),e[38]=P,e[39]=E,e[40]=z):z=e[40];let D;e[41]!==A||e[42]!==z||e[43]!==C?(D=s.jsxs(ve,{children:[g,C,A,z]}),e[41]=A,e[42]=z,e[43]=C,e[44]=D):D=e[44];let $;return e[45]!==n||e[46]!==D||e[47]!==j?($=s.jsx(je,{open:n,onOpenChange:j,children:D}),e[45]=n,e[46]=D,e[47]=j,e[48]=$):$=e[48],$},uc=t=>bi(he` 82 query LineItemImageUrls($returnGroupId: Int!) { 83 lineItemImageUrls(returnGroupId: $returnGroupId) { 84 uuid 85 url 86 } 87 } 88 `)({queryKey:["lineItemImageUrls",t],enabled:!!t,refetchOnWindowFocus:!1,retry:!1},{returnGroupId:t}),mc=t=>{const e=T.c(16),{lineItemImages:n,returnGroupId:l}=t,[r,i]=le.useState(!1),{data:o,isFetching:a}=uc(r?l:void 0),[d,c]=le.useState(0);let u;if(e[0]!==o?.lineItemImageUrls||e[1]!==n){const b=n.map(fc);u=o?.lineItemImageUrls?.filter(y=>{const{uuid:v}=y;return b.includes(v)}).map(hc)??[],e[0]=o?.lineItemImageUrls,e[1]=n,e[2]=u}else u=e[2];const m=u;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{c(0),i(!0)},e[3]=f):f=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(Dl,{}),e[4]=h):h=e[4];const p=n.length>
881?"s":"";let x;e[5]!==a||e[6]!==n.length||e[7]!==p?(x=s.jsx("div",{className:"w-full mt-2",children:s.jsxs(F,{variant:"outline",size:"xs",onClick:f,disabled:a,children:[h,"View ",n.length," Image",p]})}),e[5]=a,e[6]=n.length,e[7]=p,e[8]=x):x=e[8];let j;e[9]!==d||e[10]!==r||e[11]!==m?(j=s.jsx(On,{open:r,onOpenChange:i,slides:m,index:d,onIndexChange:c}),e[9]=d,e[10]=r,e[11]=m,e[12]=j):j=e[12];let g;return e[13]!==x||e[14]!==j?(g=s.jsxs(s.Fragment,{children:[x,j]}),e[13]=x,e[14]=j,e[15]=g):g=e[15],g};function fc(t){return t.uuid}function hc(t){return{src:t.url}}function pc(t){return t===Et.Approved?"success":t===Et.Declined?"destructive":"warning"}const xc=t=>{const e=T.c(9),{return_:n}=t,{returnGroup:l}=se(),{returns:r,id:i}=l,{lineItem:o}=n,{lineItemImages:a}=o,d=r.filter(gc).length>0;if(!(a.length>0||d))return null;const u=n.suggestedReviewDecision;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Pt,{className:"mt-6",children:"Image Verification"}),e[0]=m):m=e[0];let f;e[1]!==i||e[2]!==a?(f=s.jsx(mc,{lineItemImages:a,returnGroupId:i}),e[1]=i,e[2]=a,e[3]=f):f=e[3];let h;e[4]!==u?(h=u?s.jsxs(xt,{appearance:"soft",variant:pc(u.decision),className:"mt-2",children:[s.jsx(Xl,{}),s.jsx(Tt,{children:"AI Insight"}),s.jsx(Gt,{children:u.decisionNote})]}):null,e[4]=u,e[5]=h):h=e[5];let p;return e[6]!==f||e[7]!==h?(p=s.jsxs("div",{className:"flex flex-col",children:[m,s.jsxs("div",{className:"grid grid-cols-2",children:[f,h]})]}),e[6]=f,e[7]=h,e[8]=p):p=e[8],p};function gc(t){return t.lineItem.lineItemImages.length>0}const jc=t=>{const e=T.c(5),{questionsAnswers:n}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(Pt,{className:"mb-1",children:"Questions"}),e[0]=l):l=e[0];let r;e[1]!==n?(r=n.map(bc),e[1]=n,e[2]=r):r=e[2];let i;return e[3]!==r?(i=s.jsxs("div",{className:"flex flex-col mt-6",children:[l,s.jsx("div",{className:"grid grid-cols-2 gap-y-2",children:r})]}),e[3]=r,e[4]=i):i=e[4],i};function bc(t){const{question:e,answers:n}=t,l=e.type===pr.Select?e.choices.find(r=>r.value===n[0])?.outcome:null;return s.jsxs(Se,{className:"",children:[s.jsx(be,{children:e.question}),s.jsx(we,{children:n.map(r=>s.jsxs("div",{children:[r," ",l?s.jsxs("span",{className:"capitalize font-semibold",children:["(",l.replaceAll("_"," ").toLowerCase(),")"]}):null]},r))})]},e.handle)}const yc=t=>{const e=T.c(17),{return_:n}=t,{isRestockItem:l,id:r}=n,{shop:i,settings:o}=Ce(),{refetch:a,isReturnGroupFetching:d,returnGroup:c}=se();let u;e[0]!==a?(u=()=>{a(),G.error("Restock inventory failed to update.")},e[0]=a,e[1]=u):u=e[1];const{mutate:m,isPending:f,reset:h}=Cl({onError:u,onSuccess:_=>{const{updateReturn:I}=_;I?.userErrors?.length?(a(),G.error("Restock inventory failed to update.")):(a(),G.success("Restock inventory updated successfully.")),p()}}),p=h;if(!i)return null;const x=o?.shippingPolicy?.restockInventory,j=o?.shippingPolicy?.restockInventoryDefault,g=l??(j||!1);if(!x)return null;let b;e[2]!==c?(b=mi(c),e[2]=c,e[3]=b):b=e[3];const y=b;let v;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(be,{icon:Oi,children:"Restock Item"}),e[4]=v):v=e[4];const S=g?"Restock":"Do not restock";let C;e[5]!==S?(C=s.jsx("div",{children:S}),e[5]=S,e[6]=C):C=e[6];let R;e[7]!==y||e[8]!==f||e[9]!==g||e[10]!==d||e[11]!==m||e[12]!==r?(R=y?s.jsxs(hs,{children:[s.jsx(ps,{render:vc}),s.jsx(xs,{className:"w-[320px]",align:"start",children:s.jsxs("div",{className:"flex flex-col",children:[s.jsxs(M,{size:"sm",children:["Currently set to"," ",s.jsx(M,{as:"span",size:"sm",weight:"semibold",children:g?"Restock":"Do not restock"})," ","when return is completed."]}),s.jsxs("div",{className:"mt-4 flex space-x-2 justify-end",children:[s.jsx(pl,{render:s.jsx(F,{variant:"outline",disabled:f||d,children:"Cancel"})}),s.jsx(F,{onClick:()=>{m({updateReturnInput:{returnId:r,isRestockItem:!g}})},disabled:f||d,children:g?"Do not restock":"Restock item"})]})]})})]}):null,e[7]=y,e[8]=f,e[9]=g,e[10]=d,e[11]=m,e[12]=r,e[13]=R):R=e[13];let w;return e[14]!==C||e[15]!==R?(w=s.jsxs(Se,{children:[v,s.jsxs(we,{className:"flex items-center space-x-1",children:[C,R]})]}),e[14]=C,e[15]=R,e[16]=w):w=e[16],w};function vc(t){return s.jsx(F,{...t,variant:"link",size:"icon-xs",children:s.jsx(bs,{})})}const dn=t=>`${t.value}-${t.label}`,Sc=t=>{const e=T.c(88),{return_:n}=t,{shippingGroupOptions:l,shippingGroups:r,returnValues:i,dispatch:o,enabled:a,isAllowShippingGroupsEdit:d,isAllowReturnGroupSubmit:c}=pn(),{returnGroup:u}=se(),{returns:m,availableShippingZones:f}=u,{settings:h}=Ce(),{id:p}=n;let x,j,g,b,y,v,S,C,R,w,_,I,N,A,P,k;if(e[0]!==f||e[1]!==o||e[2]!==a||e[3]!==c||e[4]!==d||e[5]!==p||e[6]!==i||e[7]!==m.length||e[8]!==h?.returnPolicy?.itemConditionChoices||e[9]!==l||e[10]!==r){C=Symbol.for("react.early_return_sentinel");e:{const W=h?.returnPolicy?.itemConditionChoices||[];b=i?.[p]||null;const te=b?.shippingGroup||null,Z=W.find(oe=>oe.value===b?.verificationDecision&&oe.label===b?.verificationDecisionLabel)||null,H=[...l];if(m.length>H.length&&d&&H.push({label:"Add Shipping Group",value:0,color:"text-muted-foreground"}),!a){C=null;break e}v="flex flex-col w-full bg-muted rounded-md py-4 px-6 mt-4 relative",e[27]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx("div",{className:"absolute top-2 right-2",children:s.jsx(vl,{})}),e[27]=S):S=e[27],k="grid grid-cols-3 gap-x-4";let X;e[28]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(nt,{children:"Item Condition"}),e[28]=X):X=e[28];const Q=Z?dn(Z):void 0;let Y;e[29]!==o||e[30]!==W||e[31]!==p||e[32]!==b?(Y=oe=>{const me=W.find(pe=>dn(pe)===oe);o({type:"updateReturnValue",returnId:p,returnValue:{...b,verificationDecision:me?.value||null,verificationDecisionLabel:me?.label||null}})},e[29]=o,e[30]=W,e[31]=p,e[32]=b,e[33]=Y):Y=e[33];const ne=Z?Z.label:"Select condition";let ee;e[34]!==ne?(ee=s.jsx(As,{className:"w-full",children:s.jsx($s,{placeholder:"Select condition",children:ne})}),e[34]=ne,e[35]=ee):ee=e[35];let U;e[36]!==W?(U=W.map(Nc),e[36]=W,e[37]=U):U=e[37];let J;e[38]!==U?(J=s.jsx(ks,{children:U}),e[38]=U,e[39]=J):J=e[39],e[40]!==Q||e[41]!==Y||e[42]!==ee||e[43]!==J?(y=s.jsxs(xe,{className:"flex flex-col gap-1.5",children:[X,s.jsxs(Es,{value:Q,onValueChange:Y,children:[ee,J]})]}),e[40]=Q,e[41]=Y,e[42]=ee,e[43]=J,e[44]=y):y=e[44],g=xe,A="flex flex-col gap-1.5",e[45]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(nt,{children:"Return Label Group"}),e[45]=P):P=e[45],j=Es,w=!c||!d,_=te!=null?String(te):void 0,e[46]!==f||e[47]!==o||e[48]!==p||e[49]!==b||e[50]!==l||e[51]!==r?(I=oe=>{const me=Number(oe);if(me===0){const pe=l.length+1;o({type:"setShippingGroupOptions",shippingGroupOptions:[...l,{label:`Return Label ${pe}`,value:pe,color:Vl(pe)}]}),o({type:"setShippingGroups",shippingGroups:[...r,{shippingGroupNumber:pe,expenseType:gs.MerchantPaid,shippingZoneName:f[0]?.name||"No zone found"}]}),o({type:"updateReturnValue",returnId:p,returnValue:{...b,shippingGroup:pe}})}else o({type:"updateReturnValue",returnId:p,returnValue:{...b,shippingGroup:me}})},e[46]=f,e[47]=o,e[48]=p,e[49]=b,e[50]=l,e[51]=r,e[52]=I):I=e[52];const de=te?`Return Label ${te}`:"Select label group";e[53]!==de?(N=s.jsx(As,{className:"w-full",children:s.jsx($s,{placeholder:"Select label group",children:de})}),e[53]=de,e[54]=N):N=e[54],x=ks,R=H.map(Cc)}e[0]=f,e[1]=o,e[2]=a,e[3]=c,e[4]=d,e[5]=p,e[6]=i,e[7]=m.length,e[8]=h?.returnPolicy?.itemConditionChoices,e[9]=l,e[10]=r,e[11]=x,e[12]=j,e[13]=g,e[14]=b,e[15]=y,e[16]=v,e[17]=S,e[18]=C,e[19]=R,e[20]=w,e[21]=_,e[22]=I,e[23]=N,e[24]=A,e[25]=P,e[26]=k}else x=e[11],j=e[12],g=e[13],b=e[14],y=e[15],v=e[16],S=e[17],C=e[18],R=e[19],w=e[20],_=e[21],I=e[22],N=e[23],A=e[24],P=e[25],k=e[26];if(C!==Symbol.for("react.early_return_sentinel"))return C;let E;e[55]!==x||e[56]!==R?(E=s.jsx(x,{children:R}),e[55]=x,e[56]=R,e[57]=E):E=e[57];let z;e[58]!==j||e[59]!==E||e[60]!==w||e[61]!==_||e[62]!==I||e[63]!==N?(z=s.jsxs(j,{disabled:w,value:_,onValueChange:I,children:[N,E]}),e[58]=j,e[59]=E,e[60]=w,e[61]=_,e[62]=I,e[63]=N,e[64]=z):z=e[64];let D;e[65]!==g||e[66]!==z||e[67]!==A||e[68]!==P?(D=s.jsxs(g,{className:A,children:[P,z]}),e[65]=g,e[66]=z,e[67]=A,e[68]=P,e[69]=D):D=e[69];let $;e[70]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(nt,{children:"Ship Back Item"}),e[70]=$):$=e[70];const O=!c||!d,q=!!(b?.shippingGroup&&b?.shippingGroup>0);let B;e[71]!==o||e[72]!==p||e[73]!==b?(B=W=>{o(W?{type:"updateReturnValue",returnId:p,returnValue:{...b,shippingGroup:1}}:{type:"updateReturnValue",returnId:p,returnValue:{...b,shippingGroup:null}})},e[71]=o,e[72]=p,e[73]=b,e[74]=B):B=e[74];let V;e[75]!==O||e[76]!==q||e[77]!==B?(V=s.jsxs(xe,{className:"flex flex-col gap-1.5",children:[$,s.jsx(Al,{disabled:O,checked:q,onCheckedChange:B})]}),e[75]=O,e[76]=q,e[77]=B,e[78]=V):V=e[78];let L;e[79]!==y||e[80]!==D||e[81]!==V||e[82]!==k?(L=s.jsxs("div",{className:k,children:[y,D,V]}),e[79]=y,e[80]=D,e[81]=V,e[82]=k,e[83]=L):L=e[83];let K;return e[84]!==v||e[85]!==S||e[86]!==L?(K=s.jsxs("div",{className:v,children:[S,L]}),e[84]=v,e[85]=S,e[86]=L,e[87]=K):K=e[87],K};function Nc(t){return s.jsx(Gs,{value:dn(t),children:t.label},dn(t))}function Cc(t){const{label:e,value:n,color:l}=t;return s.jsx(Gs,{value:String(n),children:s.jsxs("span",{className:"flex items-center gap-2",children:[n===0?s.jsx(Br,{className:dt("size-4 shrink-0",l)}):s.jsx(Vn,{className:dt("size-4 shrink-0",l)}),e]})},n)}const cl=t=>{const e=T.c(32),{return_:n,internal:l,className:r}=t,{id:i,lineItem:o}=n,{returnReason:a,returnReasonPath:d,internalReturnReasonSnapshot:c}=o,u=l===void 0?!1:l,{getPathLabels:m}=Ol(),{shop:f}=Ce(),{refetch:h,returnGroup:p}=se(),x=(u?"Internal ":"")+(p.groupType===xr.Warranty?"Warranty":"Return");let j;e[0]!==x||e[1]!==h?(j=()=>{h(),G.error(`${x} reason failed to update.`)},e[0]=x,e[1]=h,e[2]=j):j=e[2];const{mutate:g,isPending:b,reset:y}=Cl({onError:j,onSuccess:P=>{const{updateReturn:k}=P;k?.userErrors?.length?(h(),G.error(`${x} reason failed to update.`)):(h(),G.success(`${x} reason updated successfully.`)),v()}}),v=y;if(!f)return null;let S;e[3]!==m||e[4]!==u||e[5]!==c||e[6]!==d?(S=u?c?.pathLabels?.length?c.pathLabels:m(c?.path):m(d),e[3]=m,e[4]=u,e[5]=c,e[6]=d,e[7]=S):S=e[7];let C;e[8]!==S?(C=S.join(" / "),e[8]=S,e[9]=C):C=e[9];const R=C;let w;e[10]!==x?(w=s.jsxs(be,{icon:Kr,children:[x," Reason"]}),e[10]=x,e[11]=w):w=e[11];let _;e[12]!==R?(_=s.jsx("div",{children:R}),e[12]=R,e[13]=_):_=e[13];let I;e[14]!==x||e[15]!==u||e[16]!==c?.path||e[17]!==c?.value||e[18]!==b||e[19]!==g||e[20]!==p.status||e[21]!==i||e[22]!==a||e[23]!==d?(I=p.status!==Fe.Closed?s.jsxs(hs,{children:[s.jsx(ps,{render:_c}),s.jsx(xs,{className:"w-[320px]",align:"start",children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs(M,{size:"sm",weight:"medium",children:["Update ",x.toLowerCase()," reason"]}),s.jsx(Li,{value:u?c?.value||"":a,valuePath:u?c?.path?.join("/"):d,onChange:(P,k)=>{g({updateReturnInput:{returnId:i,...u?{internalReturnReason:k}:{returnReason:k}}})},multiple:!1}),s.jsx("div",{className:"flex justify-end",children:s.jsx(pl,{render:s.jsx(F,{variant:"outline",size:"sm",disabled:b,children:"Close"})})})]})})]}):null,e[14]=x,e[15]=u,e[16]=c?.path,e[17]=c?.value,e[18]=b,e[19]=g,e[20]=p.status,e[21]=i,e[22]=a,e[23]=d,e[24]=I):I=e[24];let N;e[25]!==_||e[26]!==I?(N=s.jsxs(we,{className:"flex items-start gap-1",children:[_,I]}),e[25]=_,e[26]=I,e[27]=N):N=e[27];let A;return e[28]!==r||e[29]!==N||e[30]!==w?(A=s.jsxs(Se,{className:r,children:[w,N]}),e[28]=r,e[29]=N,e[30]=w,e[31]=A):A=e[31],A};function _c(t){return s.jsx(F,{...t,variant:"link",size:"icon-xs",children:s.jsx(bs,{})})}const Rc=t=>{const e=T.c(8),{return_:n}=t,{settings:l}=Ce();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(be,{children:"Review Decision"}),e[0]=r):r=e[0];const i=wc[n.verificationDecision];let o;e[1]!==n.verificationDecision||e[2]!==n.verificationDecisionNote||e[3]!==l?.returnPolicy?.itemConditionChoices?(o=n.verificationDecisionNote||l?.returnPolicy?.itemConditionChoices?.find(d=>d.value===n.verificationDecision)?.label,e[1]=n.verificationDecision,e[2]=n.verificationDecisionNote,e[3]=l?.returnPolicy?.itemConditionChoices,e[4]=o):o=e[4];let a;return e[5]!==i.variant||e[6]!==o?(a=s.jsxs(Se,{children:[r,s.jsx(we,{children:s.jsx(it,{variant:i.variant,children:o})})]}),e[5]=i.variant,e[6]=o,e[7]=a):a=e[7],a},wc={[ge.DeclineDamaged]:{color:"red",variant:"destructive"},[ge.DeclineOther]:{color:"red",variant:"destructive"},[ge.Defective]:{color:"red",variant:"destructive"},[ge.Good]:{color:"emerald",variant:"success"},[ge.NoIssue]:{color:"emerald",variant:"success"},[ge.Perfect]:{color:"emerald",variant:"success"},[ge.Poor]:{color:"yellow",variant:"warning"},[ge.Reworks]:{color:"yellow",variant:"warning"},[ge.ReuploadImage]:{color:"yellow",variant:"warning"},[ge.Seconds]:{color:"yellow",variant:"warning"},[ge.WrongItem]:{color:"red",variant:"destructive"}},Ic=t=>{const e=T.c(23),{rmaImages:n,returnId:l}=t,[r,i]=le.useState(!1),o=String(l);let a;e[0]!==o?(a=[o],e[0]=o,e[1]=a):a=e[1];let d;e[2]!==r||e[3]!==a?(d={queryKey:a,enabled:r},e[2]=r,e[3]=a,e[4]=d):d=e[4];let c;e[5]!==l?(c={returnId:l},e[5]=l,e[6]=c):c=e[6];const u=Wr(d,c),[m,f]=le.useState(0);let h;if(e[7]!==u.data?.rmaImageUrls||e[8]!==n){const S=n.map(Ec);h=u.data?.rmaImageUrls?.filter(C=>{const{uuid:R}=C;return S.includes(R)}).map(Ac)??[],e[7]=u.data?.rmaImageUrls,e[8]=n,e[9]=h}else h=e[9];const p=h;let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{f(0),i(!0)},e[10]=x):x=e[10];let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Dl,{}),e[11]=j):j=e[11];const g=n.length>
881?"s":"";let b;e[12]!==u.isFetching||e[13]!==n.length||e[14]!==g?(b=s.jsx("div",{className:"w-full mt-2",children:s.jsxs(F,{variant:"outline",size:"xs",onClick:x,disabled:u.isFetching,children:[j,"View ",n.length," Image",g]})}),e[12]=u.isFetching,e[13]=n.length,e[14]=g,e[15]=b):b=e[15];let y;e[16]!==m||e[17]!==r||e[18]!==p?(y=s.jsx(On,{open:r,onOpenChange:i,slides:p,index:m,onIndexChange:f}),e[16]=m,e[17]=r,e[18]=p,e[19]=y):y=e[19];let v;return e[20]!==y||e[21]!==b?(v=s.jsxs(s.Fragment,{children:[b,y]}),e[20]=y,e[21]=b,e[22]=v):v=e[22],v};function Ec(t){return t.uuid}function Ac(t){return{src:t.url}}const $c=t=>{const e=T.c(8),{return_:n}=t,{rmaImages:l,id:r,rma:i}=n;if(l.length===0)return null;const o=i?.provider??"Manual";let a;e[0]!==o?(a=s.jsxs(Pt,{className:"mt-6",children:["RMA Images (",o,")"]}),e[0]=o,e[1]=a):a=e[1];let d;e[2]!==r||e[3]!==l?(d=s.jsx(Ic,{rmaImages:l,returnId:r}),e[2]=r,e[3]=l,e[4]=d):d=e[4];let c;return e[5]!==a||e[6]!==d?(c=s.jsxs("div",{className:"flex flex-col",children:[a,d]}),e[5]=a,e[6]=d,e[7]=c):c=e[7],c},kc=t=>t?t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",Pc=t=>{const e=T.c(85),{return_:n,creditMethod:l}=t,{returnGroup:r}=se(),{name:i,lineItem:o}=n,{productName:a,variantName:d,bundledQuantity:c,sku:u,returnNote:m,questionsAnswers:f,image:h,money:p,priceBreakdown:x}=o,{shop:j,settings:g}=Ce();let b;e:{if(x){b=x.price.shopMoney;break e}b=p}const y=b,[v,S]=le.useState(!1);if(!r||!j)return null;const R=g?.shippingPolicy?.restockInventory,w=n.rma&&n.rma.provider===Yn.TwoBoxes?n.rma:null,_=n.rma&&n.rma.provider===Yn.Blade?n.rma:null;let I;e[0]!==i?(I=s.jsx(ft,{children:i}),e[0]=i,e[1]=I):I=e[1];let N;e[2]!==n?(N=s.jsx(El,{returns:[n]}),e[2]=n,e[3]=N):N=e[3];let A;e[4]!==n.isExchange?(A=n.isExchange?s.jsxs(it,{children:[s.jsx(Nl,{}),"Exchange"]}):null,e[4]=n.isExchange,e[5]=A):A=e[5];let P;e[6]!==I||e[7]!==N||e[8]!==A?(P=s.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[I,N,A]}),e[6]=I,e[7]=N,e[8]=A,e[9]=P):P=e[9];let k;e[10]!==n.status?(k=[js.Open,js.InReview].includes(n.status)?s.jsxs(yt,{children:[s.jsx(vt,{render:Tc}),s.jsx(St,{align:"end",children:s.jsx(Me,{onClick:()=>S(!0),children:"Cancel Return"})})]}):null,e[10]=n.status,e[11]=k):k=e[11];let E;e[12]!==k?(E=s.jsx("div",{className:"flex items-center",children:k}),e[12]=k,e[13]=E):E=e[13];let z;e[14]!==P||e[15]!==E?(z=s.jsxs("div",{className:"flex justify-between items-center",children:[P,E]}),e[14]=P,e[15]=E,e[16]=z):z=e[16];let D;e[17]!==l||e[18]!==n.lineItem||e[19]!==j.shopName?(D=j.shopName==="msqc"&&l===on.StoreCredit&&n.lineItem.returnReason===gr.WrongItem&&s.jsx("div",{className:"border border-blue-500 bg-blue-50 self-start w-full text-center rounded-md px-4 py-2 mb-2",children:s.jsx(M,{size:"xs",tone:"muted",children:"Create a zero-cost order with this item and fulfill it to the customer. You may complete this return once you receive the customer's wrong item."})}),e[17]=l,e[18]=n.lineItem,e[19]=j.shopName,e[20]=D):D=e[20];let $;e[21]!==h||e[22]!==a?($=s.jsx(Hn,{image:h,productName:a}),e[21]=h,e[22]=a,e[23]=$):$=e[23];let O;e[24]!==c?(O=c>1?s.jsxs(s.Fragment,{children:[" Ã ",c]}):null,e[24]=c,e[25]=O):O=e[25];let q;e[26]!==a||e[27]!==O?(q=s.jsxs(Ms,{children:[a,O]}),e[26]=a,e[27]=O,e[28]=q):q=e[28];let B;e[29]!==u||e[30]!==d?(B=[d,u].filter(Boolean).length>0?s.jsx(Fs,{children:[d,u].filter(Boolean).join(" / ")}):null,e[29]=u,e[30]=d,e[31]=B):B=e[31];let V;e[32]!==y?(V=y?s.jsx(Ds,{children:fe(y,!0)}):null,e[32]=y,e[33]=V):V=e[33];let L;e[34]!==q||e[35]!==B||e[36]!==V?(L=s.jsxs(Os,{children:[q,B,V]}),e[34]=q,e[35]=B,e[36]=V,e[37]=L):L=e[37];let K;e[38]!==$||e[39]!==L?(K=s.jsxs(Ls,{size:"lg",variant:"default",className:"border-0 bg-transparent p-0 shadow-none",children:[$,L]}),e[38]=$,e[39]=L,e[40]=K):K=e[40];let W;e[41]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(yi,{className:"my-4"}),e[41]=W):W=e[41];let te;e[42]!==n?(te=s.jsx(cl,{return_:n,className:"col-span-2"}),e[42]=n,e[43]=te):te=e[43];let Z;e[44]!==n||e[45]!==g?.returnPolicy?.internalReturnReasonEnabled?(Z=g?.returnPolicy?.internalReturnReasonEnabled?s.jsx(cl,{return_:n,internal:!0,className:"col-span-2"}):null,e[44]=n,e[45]=g?.returnPolicy?.internalReturnReasonEnabled,e[46]=Z):Z=e[46];let H;e[47]!==m?(H=m?s.jsxs(Se,{children:[s.jsx(be,{icon:Zr,children:"Return Note"}),s.jsx(we,{children:s.jsx(ol,{text:m})})]}):null,e[47]=m,e[48]=H):H=e[48];let X;e[49]!==n?(X=n.verificationDecision&&n.verificationDecision!==ge.ReuploadImage?s.jsx(Rc,{return_:n}):null,e[49]=n,e[50]=X):X=e[50];let Q;e[51]!==R||e[52]!==n?(Q=R?s.jsx(yc,{return_:n}):null,e[51]=R,e[52]=n,e[53]=Q):Q=e[53];let Y;e[54]!==te||e[55]!==Z||e[56]!==H||e[57]!==X||e[58]!==Q?(Y=s.jsxs("div",{className:"grid grid-cols-4 w-full gap-x-2 gap-y-4",children:[te,Z,H,X,Q]}),e[54]=te,e[55]=Z,e[56]=H,e[57]=X,e[58]=Q,e[59]=Y):Y=e[59];let ne;e[60]!==w?(ne=w?s.jsxs(s.Fragment,{children:[s.jsx(Pt,{className:"mt-6",children:"Two Boxes"}),s.jsxs("div",{className:"grid grid-cols-3 w-full pt-2 gap-x-2 gap-y-4",children:[s.jsxs(Se,{children:[s.jsx(be,{children:"RMA ID"}),s.jsx(we,{children:w.id})]}),s.jsxs(Se,{children:[s.jsx(be,{children:"Grading"}),s.jsxs(we,{className:"capitalize flex items-center gap-x-2",children:[w.resolution===cs.NotYetSet?s.jsx(Xn,{className:"w-4 h-4 text-neutral-500"}):w.resolution===cs.Donate?s.jsx(Qr,{className:"w-4 h-4 text-neutral-500"}):w.resolution===cs.ReturnToStock?s.jsx(el,{className:"w-4 h-4 text-green-500"}):w.resolution===cs.ReturnToStockResale?s.jsx(el,{className:"w-4 h-4 text-green-500"}):w.resolution===cs.Dispose?s.jsx(Ui,{className:"w-4 h-4 text-red-500"}):w.resolution===cs.Recycle?s.jsx(Hr,{className:"w-4 h-4 text-red-500"}):s.jsx(Xn,{className:"w-4 h-4 text-green-500"}),kc(w.resolution)]})]}),s.jsxs(Se,{children:[s.jsx(be,{children:"Comments"}),s.jsx(we,{children:s.jsx(ol,{text:w.comments.join(", ")})})]})]})]}
88):null,e[60]=w,e[61]=ne):ne=e[61];let ee;e[62]!==_?(ee=_?s.jsx("div",{className:"grid grid-cols-3 w-full mt-2 gap-x-2 gap-y-4",children:s.jsxs(Se,{children:[s.jsx(be,{children:"Batch ID"}),s.jsxs(we,{className:"capitalize flex items-center gap-x-2",children:[s.jsx(er,{className:"w-4 h-4 ml-2 fill-neutral-500"}),_.batchId]})]})}):null,e[62]=_,e[63]=ee):ee=e[63];let U;e[64]!==f?(U=f&&f.length>0?s.jsx(jc,{questionsAnswers:f}):null,e[64]=f,e[65]=U):U=e[65];let J;e[66]!==n?(J=s.jsxs("div",{className:"grid grid-cols-2 gap-x-2",children:[s.jsx(xc,{return_:n}),s.jsx($c,{return_:n})]}),e[66]=n,e[67]=J):J=e[67];let de;e[68]!==n?(de=s.jsx("div",{"data-anchor":"return-actions",children:s.jsx(Sc,{return_:n})}),e[68]=n,e[69]=de):de=e[69];let oe;e[70]===Symbol.for("react.memo_cache_sentinel")?(oe=Ae=>S(Ae),e[70]=oe):oe=e[70];let me;e[71]!==v||e[72]!==n?(me=s.jsx(dc,{return_:n,isOpen:v,onOpenChange:oe}),e[71]=v,e[72]=n,e[73]=me):me=e[73];let pe;return e[74]!==D||e[75]!==K||e[76]!==Y||e[77]!==ne||e[78]!==ee||e[79]!==U||e[80]!==J||e[81]!==de||e[82]!==me||e[83]!==z?(pe=s.jsxs(zs,{className:"gap-0 p-4",children:[z,D,K,W,Y,ne,ee,U,J,de,me]}),e[74]=D,e[75]=K,e[76]=Y,e[77]=ne,e[78]=ee,e[79]=U,e[80]=J,e[81]=de,e[82]=me,e[83]=z,e[84]=pe):pe=e[84],pe};function Tc(t){const{...e}=t;return s.jsx(F,{variant:"ghost",size:"icon",...e,children:s.jsx(Ct,{})})}const Gc=()=>{const t=T.c(9),{returnGroup:e}=se(),{returns:n}=e;let l;t[0]!==n.length?(l=s.jsxs(M,{as:"h3",size:"lg",weight:"semibold",className:"mb-2",children:["Return Items (",n.length,")"]}),t[0]=n.length,t[1]=l):l=t[1];let r;t[2]!==n?(r=n.map(zc),t[2]=n,t[3]=r):r=t[3];let i;t[4]!==r?(i=s.jsx("div",{className:"flex flex-col relative space-y-4",children:r}),t[4]=r,t[5]=i):i=t[5];let o;return t[6]!==l||t[7]!==i?(o=s.jsxs("div",{children:[l,i]}),t[6]=l,t[7]=i,t[8]=o):o=t[8],o};function zc(t){return s.jsx(Pc,{return_:t},t.id)}const Mc=()=>{const t=T.c(7),{settings:e}=Ce(),{returnGroup:n}=se(),{returns:l,reuploadNote:r}=n,i=e?.imageVerificationPolicy.enabled,o=!!l.find(Fc);if(!i||!o)return null;let a,d;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(kl,{}),d=s.jsx(Tt,{children:"Image reupload requested"}),t[0]=a,t[1]=d):(a=t[0],d=t[1]);let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("p",{children:"An email has been sent to the customer requesting new images."}),t[2]=c):c=t[2];let u;t[3]!==r?(u=r?s.jsxs("div",{className:"flex flex-col",children:[s.jsx(M,{weight:"semibold",className:"mt-4",children:"Additional Info Note:"}),s.jsx("div",{className:"mt-1",children:r})]}):null,t[3]=r,t[4]=u):u=t[4];let m;return t[5]!==u?(m=s.jsxs(xt,{children:[a,d,s.jsxs(Gt,{children:[c,u]})]}),t[5]=u,t[6]=m):m=t[6],m};function Fc(t){const{verificationDecision:e}=t;return e===ge.ReuploadImage}const Dc=()=>{const t=T.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"flex-auto flex flex-col pb-[160px] gap-4",children:[s.jsx(lc,{}),s.jsx(ic,{}),s.jsx(Mc,{}),s.jsx(wo,{}),s.jsx(oc,{}),s.jsx(No,{}),s.jsx(Gc,{}),s.jsx(Ta,{}),s.jsx(ao,{})]}),t[0]=e):e=t[0],e},Oc=()=>{const t=T.c(44),e=$r(),n=fi(),{returnGroup:l,returnGroupQuery:r}=Yr(),{prevPageQuery:i,nextPageQuery:o,nextReturnGroupId:a,prevReturnGroupId:d}=Jr(),c=l?.hasUnresolvedRefundError,u=l?.order.name;jr(u?`Return ${u}`:null);let m;t[0]!==c?(m=c?s.jsx(Lc,{}):null,t[0]=c,t[1]=m):m=t[1];let f;t[2]!==l?.returns?(f=l?.returns??[],t[2]=l?.returns,t[3]=f):f=t[3];let h;t[4]!==f?(h=s.jsx(El,{returns:f,overlap:!1}),t[4]=f,t[5]=h):h=t[5];let p;t[6]!==m||t[7]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[m,h]}),t[6]=m,t[7]=h,t[8]=p):p=t[8];const x=l?.createdAt??"";let j;t[9]!==x?(j=s.jsx($t,{prefix:"Created",timestamp:x}),t[9]=x,t[10]=j):j=t[10];let g;t[11]!==p||t[12]!==j?(g=s.jsxs("div",{className:"flex flex-col",children:[p,j]}),t[11]=p,t[12]=j,t[13]=g):g=t[13];let b;t[14]!==r?(b=()=>{r.refetch()},t[14]=r,t[15]=b):b=t[15];let y;t[16]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx($l,{}),t[16]=y):y=t[16];let v;t[17]!==b?(v=s.jsx(Nn,{children:s.jsx(F,{variant:"outline",size:"icon",onClick:b,children:y})}),t[17]=b,t[18]=v):v=t[18];const S=i.isFetching||i.data?.returnGroups.nodes.length===0;let C;t[19]!==n.search||t[20]!==e||t[21]!==d?(C=()=>{e({to:`/${d}`,search:n.search})},t[19]=n.search,t[20]=e,t[21]=d,t[22]=C):C=t[22];let R;t[23]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(gi,{}),t[23]=R):R=t[23];let w;t[24]!==S||t[25]!==C?(w=s.jsx(F,{variant:"outline",size:"icon","aria-label":"Previous",disabled:S,onClick:C,children:R}),t[24]=S,t[25]=C,t[26]=w):w=t[26];const _=o.isFetching||o.data?.returnGroups.nodes.length===0;let I;t[27]!==n.search||t[28]!==e||t[29]!==a?(I=()=>{e({to:`/${a}`,search:n.search})},t[27]=n.search,t[28]=e,t[29]=a,t[30]=I):I=t[30];let N;t[31]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(Fl,{}),t[31]=N):N=t[31];let A;t[32]!==_||t[33]!==I?(A=s.jsx(F,{variant:"outline",size:"icon","aria-label":"Next",disabled:_,onClick:I,children:N}),t[32]=_,t[33]=I,t[34]=A):A=t[34];let P;t[35]!==w||t[36]!==A?(P=s.jsxs(Nn,{children:[w,A]}),t[35]=w,t[36]=A,t[37]=P):P=t[37];let k;t[38]!==P||t[39]!==v?(k=s.jsxs(Nn,{children:[v,P]}),t[38]=P,t[39]=v,t[40]=k):k=t[40];let E;return t[41]!==k||t[42]!==g?(E=s.jsxs("div",{className:"flex items-center justify-between rounded-lg",children:[g,k]}),t[41]=k,t[42]=g,t[43]=E):E=t[43],E},Lc=()=>{const t=T.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs(hs,{children:[s.jsx(ps,{children:s.jsx(it,{variant:"destructive",children:"Refund Error"})}),s.jsx(xs,{align:"start",children:"Unable to refund via Route Returns. Issue refund externally and mark the return as refunded."})]}),t[0]=e):e=t[0],e},Vc=hn.map(({key:t})=>t),dl=new Map(hn.map(({key:t,label:e})=>[t,e])),Uc=t=>{const e=Nt({defaultValues:{...t.formData}}),{emailType:n,returnGroupId:l}=e.watch();return s.jsx(kt,{...e,children:s.jsxs("form",{onSubmit:e.handleSubmit(t.onSubmit),className:"flex flex-col h-full gap-2",children:[s.jsxs(br,{className:"flex flex-row items-center justify-between",children:[s.jsx(yr,{children:"Send Email"}),s.jsxs(F,{type:"submit",className:"px-8",disabled:e.formState.isSubmitting,children:[s.jsx(Sl,{className:"size-4"}),"Send"]})]}),s.jsxs("div",{className:"flex flex-col gap-2 px-4 pb-4 relative border-b",children:[s.jsx(lt,{control:e.control,name:"destinationEmail",rules:{required:"To email address is required",pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Invalid email address"}},render:({field:r})=>s.jsxs(rt,{children:[s.jsx(pt,{render:i=>s.jsx($n,{...i,prefix:"To:",className:"flex-1",children:s.jsx(kn,{placeholder:"Email address",...r})})}),s.jsx(bt,{})]})}),s.jsx(lt,{control:e.control,name:"emailType",render:({field:r})=>s.jsxs(rt,{children:[s.jsxs(Tn,{items:Vc,value:r.value,onValueChange:r.onChange,children:[s.jsx(Gn,{render:s.jsxs(F,{variant:"input",className:"w-full justify-between",children:[s.jsx("div",{className:"truncate text-left",children:s.jsx(gl,{children:i=>dl.get(i)??i})}),s.jsx(zn,{})]})}),s.jsxs(Mn,{children:[s.jsx(jl,{showTrigger:!1,placeholder:"Search"}),s.jsx(bl,{children:"No email types."}),s.jsx(Fn,{children:i=>s.jsx(Dn,{value:i,children:dl.get(i)??i},i)})]})]}),s.jsx(bt,{})]})})]}),s.jsx(qi,{emailType:n,returnGroupId:l})]})})},qc=Re(he` 89 mutation ResendEmail( 90 $returnGroupId: Int! 91 $emailType: EmailTypeEnum!
92 $destinationEmail: String 93 ) { 94 resendEmail( 95 returnGroupId: $returnGroupId 96 emailType: $emailType 97 destinationEmail: $destinationEmail 98 ) { 99 success 100 userErrors { 101 message 102 } 103 } 104 } 105`),Bc=()=>{const t=T.c(37),e=Ee(),{returnGroup:n,refetch:l}=se(),{emails:r,order:i}=n;let o;t[0]!==e||t[1]!==l?(o={onSuccess:C=>{if(C.resendEmail.userErrors?.length){G.error(C.resendEmail.userErrors[0].message);return}l(),G.success("Email sent"),e.close("resendEmail")},onError:Kc},t[0]=e,t[1]=l,t[2]=o):o=t[2];const a=qc(o);let d;t[3]!==r.length?(d=s.jsxs(ft,{children:["Emails (",r.length,")"]}),t[3]=r.length,t[4]=d):d=t[4];let c;t[5]!==e||t[6]!==i?.customer?.email||t[7]!==n.id||t[8]!==n.status?(c=[Fe.Open,Fe.Closed].includes(n.status)&&s.jsxs(yt,{children:[s.jsx(vt,{render:Wc}),s.jsx(St,{align:"end",children:s.jsx(Me,{onClick:()=>{e.open("resendEmail",{emailType:yl.ShipBackRequest,returnGroupId:n.id,destinationEmail:i?.customer?.email})},children:"Send Email"})})]}),t[5]=e,t[6]=i?.customer?.email,t[7]=n.id,t[8]=n.status,t[9]=c):c=t[9];let u;t[10]!==d||t[11]!==c?(u=s.jsxs("div",{className:"flex flex-row items-center justify-between",children:[d,c]}),t[10]=d,t[11]=c,t[12]=u):u=t[12];let m;t[13]!==r?(m=r.map(Qc),t[13]=r,t[14]=m):m=t[14];let f;t[15]!==r.length?(f=r.length===0&&s.jsx(Ss,{children:"No emails have been sent."}),t[15]=r.length,t[16]=f):f=t[16];let h;t[17]!==m||t[18]!==f?(h=s.jsxs("div",{className:"flex flex-col space-y-4",children:[m,f]}),t[17]=m,t[18]=f,t[19]=h):h=t[19];let p;t[20]!==e?(p=e.getDialogProps("resendEmail"),t[20]=e,t[21]=p):p=t[21];let x;t[22]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Sr,{}),t[22]=x):x=t[22];let j;t[23]!==e?(j=e.getValue("resendEmail"),t[23]=e,t[24]=j):j=t[24];const g=j;let b;t[25]!==a?(b=C=>a.mutateAsync(C),t[25]=a,t[26]=b):b=t[26];let y;t[27]!==g||t[28]!==b?(y=s.jsxs(Nr,{className:"flex flex-col w-2xl! rounded-none!",children:[x,s.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:s.jsx(Uc,{formData:g,onSubmit:b})})]}),t[27]=g,t[28]=b,t[29]=y):y=t[29];let v;t[30]!==y||t[31]!==p?(v=s.jsx(vr,{...p,swipeDirection:"right",children:y}),t[30]=y,t[31]=p,t[32]=v):v=t[32];let S;return t[33]!==v||t[34]!==u||t[35]!==h?(S=s.jsxs(Ze,{className:"gap-1",children:[u,h,v]}),t[33]=v,t[34]=u,t[35]=h,t[36]=S):S=t[36],S};function Kc(){G.error("Failed to send email")}function Wc(t){const{...e}=t;return s.jsx(F,{variant:"ghost",size:"icon",...e,children:s.jsx(Ct,{className:"h-4 w-4"})})}function Qc(t){const{id:e,createdAt:n,emailType:l}=t;return s.jsxs(Se,{children:[s.jsx(be,{className:"capitalize",children:l.replaceAll("_"," ").toLowerCase().replaceAll("ecodrop","EcoDrop")}),s.jsx($t,{prefix:"Sent",timestamp:n})]},e)}const Hc=Pn({queryKey:["klaviyoEvents"]},he` 106 query KlaviyoEvents($returnGroupId: Int!) { 107 klaviyoEvents(returnGroupId: $returnGroupId) { 108 id 109 metricName 110 createdAt 111 properties 112 } 113 } 114 `),Zc=new Map(hn.map(({key:t,label:e})=>[t,e])),Yc=t=>{const e=T.c(27),{destinationEmail:n,isPending:l,onCancel:r,onSubmit:i}=t,[o,a]=le.useState(yl.ShipBackRequest);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Send Klaviyo event"}),s.jsx(Oe,{children:"Sends the event to Klaviyo again, re-triggering any flow that listens for it."})]}),e[0]=d):d=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(De,{htmlFor:"klaviyo-event-type",children:"Event"}),e[1]=c):c=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=R=>a(R),e[2]=u):u=e[2];let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(As,{id:"klaviyo-event-type",className:"w-full",children:s.jsx($s,{placeholder:"Select an event",children:Jc})}),e[3]=m):m=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(ks,{children:hn.map(Xc)}),e[4]=f):f=e[4];let h;e[5]!==o?(h=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,s.jsxs(Es,{value:o,onValueChange:u,children:[m,f]})]}),e[5]=o,e[6]=h):h=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(De,{children:"To"}),e[7]=p):p=e[7];let x;
114e[8]!==n?(x=s.jsxs("div",{className:"flex flex-col gap-1",children:[p,n?s.jsx("p",{className:"text-sm",children:n}):s.jsx("p",{className:"text-sm text-muted-foreground",children:"This return has no customer email, so the event cannot be sent."})]}),e[8]=n,e[9]=x):x=e[9];let j;e[10]!==h||e[11]!==x?(j=s.jsxs("div",{className:"flex flex-col gap-4",children:[h,x]}),e[10]=h,e[11]=x,e[12]=j):j=e[12];let g;e[13]!==r?(g=s.jsx(F,{type:"button",variant:"outline",onClick:r,"data-amp-track-name":"cancel-resend-klaviyo-event-btn",children:"Cancel"}),e[13]=r,e[14]=g):g=e[14];const b=l||!n;let y;e[15]!==o||e[16]!==i?(y=()=>i(o),e[15]=o,e[16]=i,e[17]=y):y=e[17];let v;e[18]!==b||e[19]!==y?(v=s.jsx(F,{type:"button",disabled:b,onClick:y,"data-amp-track-name":"confirm-resend-klaviyo-event-btn",children:"Send"}),e[18]=b,e[19]=y,e[20]=v):v=e[20];let S;e[21]!==g||e[22]!==v?(S=s.jsxs(Ne,{children:[g,v]}),e[21]=g,e[22]=v,e[23]=S):S=e[23];let C;return e[24]!==S||e[25]!==j?(C=s.jsxs(s.Fragment,{children:[d,j,S]}),e[24]=S,e[25]=j,e[26]=C):C=e[26],C};function Jc(t){return Zc.get(t)??"Select an event"}function Xc(t){const{key:e,label:n}=t;return s.jsx(Gs,{value:e,children:n},e)}const ed=Re(he` 115 mutation ResendKlaviyoEvent( 116 $returnGroupId: Int! 117 $emailType: EmailTypeEnum! 118 ) { 119 resendKlaviyoEvent( 120 returnGroupId: $returnGroupId 121 emailType: $emailType 122 ) { 123 success 124 userErrors { 125 message 126 } 127 } 128 } 129`),td=()=>{const t=T.c(47),{shop:e}=Ce(),n=Ee(),{returnGroup:l}=se(),{id:r,order:i}=l,o=i?.customer?.email,a=String(r);let d;t[0]!==a?(d=[a],t[0]=a,t[1]=d):d=t[1];const c=e.isKlaviyoEnabled&&!!r;let u;t[2]!==d||t[3]!==c?(u={queryKey:d,enabled:c},t[2]=d,t[3]=c,t[4]=u):u=t[4];let m;t[5]!==r?(m={returnGroupId:r},t[5]=r,t[6]=m):m=t[6];const{data:f,isLoading:h,refetch:p}=Hc(u,m);let x;t[7]!==n||t[8]!==p?(x={onSuccess:E=>{if(E.resendKlaviyoEvent.userErrors?.length){G.error(E.resendKlaviyoEvent.userErrors[0].message);return}p(),G.success("Klaviyo event queued"),n.close("resendKlaviyoEvent")},onError:nd},t[7]=n,t[8]=p,t[9]=x):x=t[9];const j=ed(x);let g;t[10]!==f?.klaviyoEvents?(g=f?.klaviyoEvents??[],t[10]=f?.klaviyoEvents,t[11]=g):g=t[11];const b=g;if(!e.isKlaviyoEnabled)return null;let y;t[12]!==b.length?(y=s.jsxs(ft,{children:["Klaviyo Events (",b.length,")"]}),t[12]=b.length,t[13]=y):y=t[13];let v;t[14]!==n||t[15]!==l.status?(v=[Fe.Open,Fe.Closed].includes(l.status)&&s.jsxs(yt,{children:[s.jsx(vt,{render:ld}),s.jsx(St,{align:"end",className:"w-auto",children:s.jsx(Me,{onClick:()=>n.open("resendKlaviyoEvent"),children:"Send Klaviyo Event"})})]}),t[14]=n,t[15]=l.status,t[16]=v):v=t[16];let S;t[17]!==y||t[18]!==v?(S=s.jsxs("div",{className:"flex flex-row items-center justify-between",children:[y,v]}),t[17]=y,t[18]=v,t[19]=S):S=t[19];let C;t[20]!==b?(C=b.map(rd),t[20]=b,t[21]=C):C=t[21];let R;t[22]!==b.length||t[23]!==h?(R=!h&&b.length===0&&s.jsx(Ss,{children:"No Klaviyo events."}),t[22]=b.length,t[23]=h,t[24]=R):R=t[24];let w;t[25]!==C||t[26]!==R?(w=s.jsxs("div",{className:"flex flex-col space-y-4",children:[C,R]}),t[25]=C,t[26]=R,t[27]=w):w=t[27];let _;t[28]!==n?(_=n.getDialogProps("resendKlaviyoEvent"),t[28]=n,t[29]=_):_=t[29];let I;t[30]!==n?(I=()=>n.close("resendKlaviyoEvent"),t[30]=n,t[31]=I):I=t[31];let N;t[32]!==j||t[33]!==r?(N=E=>j.mutate({returnGroupId:r,emailType:E}),t[32]=j,t[33]=r,t[34]=N):N=t[34];let A;t[35]!==o||t[36]!==j.isPending||t[37]!==I||t[38]!==N?(A=s.jsx(vi,{children:s.jsx(Yc,{destinationEmail:o,isPending:j.isPending,onCancel:I,onSubmit:N})}),t[35]=o,t[36]=j.isPending,t[37]=I,t[38]=N,t[39]=A):A=t[39];let P;t[40]!==_||t[41]!==A?(P=s.jsx(je,{..._,children:A}),t[40]=_,t[41]=A,t[42]=P):P=t[42];let k;return t[43]!==w||t[44]!==P||t[45]!==S?(k=s.jsxs(Ze,{className:"gap-1",children:[S,w,P]}),t[43]=w,t[44]=P,t[45]=S,t[46]=k):k=t[46],k},sd=t=>{const e=T.c(22),{metricName:n,createdAt:l,properties:r}=t,[i,o]=le.useState(!1);let a;e[0]!==n?(a=s.jsx(be,{className:"capitalize",children:n}),e[0]=n,e[1]=a):a=e[1];let d;e[2]!==l?(d=s.jsx($t,{prefix:"Sent",timestamp:l}),e[2]=l,e[3]=d):d=e[3];let c;e[4]!==a||e[5]!==d?(c=s.jsxs(Se,{children:[a,d]}),e[4]=a,e[5]=d,e[6]=c):c=e[6];const u=i&&"rotate-180";let m;e[7]!==u?(m=mt("size-4 shrink-0 text-muted-foreground transition-transform",u),e[7]=u,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(Gl,{className:m}),e[9]=m,e[10]=f):f=e[10];let h;e[11]!==c||e[12]!==f?(h=s.jsxs(ml,{className:"flex w-full items-start justify-between gap-2 text-left",children:[c,f]}),e[11]=c,e[12]=f,e[13]=h):h=e[13];let p;e[14]!==r?(p=JSON.stringify(r,null,2),e[14]=r,e[15]=p):p=e[15];let x;e[16]!==p?(x=s.jsx(fl,{children:s.jsx("pre",{className:"bg-muted text-muted-foreground mt-2 max-h-64 overflow-y-auto rounded p-2 text-xs break-words whitespace-pre-wrap",children:p})}),e[16]=p,e[17]=x):x=e[17];let j;return e[18]!==i||e[19]!==h||e[20]!==x?(j=s.jsxs(hl,{open:i,onOpenChange:o,children:[h,x]}),e[18]=i,e[19]=h,e[20]=x,e[21]=j):j=e[21],j};
129function nd(){G.error("Failed to send Klaviyo event")}function ld(t){const{...e}=t;return s.jsx(F,{variant:"ghost",size:"icon",...e,children:s.jsx(Ct,{className:"h-4 w-4"})})}function rd(t){const{id:e,metricName:n,createdAt:l,properties:r}=t;return s.jsx(sd,{metricName:n,createdAt:l,properties:r},e)}const id=Re(he` 130 mutation setPlatformOrderNote($platformOrderId: String!, $input: PlatformOrderNoteInput!) { 131 setPlatformOrderNote(platformOrderId: $platformOrderId, input: $input) 132 } 133`),ad=()=>{const t=T.c(27),{shop:e}=Ce(),{returnGroup:n}=se(),l=n.order.platformId,i=e?.platform===Is.Shopify&&!!l;let o;t[0]!==l?(o=[l],t[0]=l,t[1]=o):o=t[1];let a;t[2]!==i||t[3]!==o?(a={enabled:i,queryKey:o},t[2]=i,t[3]=o,t[4]=a):a=t[4];let d;t[5]!==l?(d={platformOrderId:l},t[5]=l,t[6]=d):d=t[6];const{data:c,isFetching:u,isError:m,refetch:f}=_l(a,d),[h,p]=le.useState(""),[x,j]=le.useState(!1);let g;t[7]!==c?.platformOrderNote?(g=()=>{c?.platformOrderNote&&p(c?.platformOrderNote)},t[7]=c?.platformOrderNote,t[8]=g):g=t[8];const b=c?.platformOrderNote;let y;if(t[9]!==b?(y=[b],t[9]=b,t[10]=y):y=t[10],le.useEffect(g,y),e?.platform!==Is.Shopify||m)return null;let v;if(u){let N;t[11]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(Ps,{})}),t[11]=N):N=t[11],v=N}else if(h.length>0){let N;t[12]!==h?(N=s.jsx("p",{className:"whitespace-pre-wrap",children:h}),t[12]=h,t[13]=N):N=t[13],v=N}else{let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(Ss,{children:"No Shopify Order Note"}),t[14]=N):N=t[14],v=N}let S;t[15]!==f?(S=N=>{j(!1),N&&f()},t[15]=f,t[16]=S):S=t[16];let C;t[17]!==x||t[18]!==S?(C=s.jsx(od,{open:x,onClose:S}),t[17]=x,t[18]=S,t[19]=C):C=t[19];let R;t[20]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(Xr,{className:"w-4 h-4"}),t[20]=R):R=t[20];let w;t[21]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsxs(be,{className:"inline-flex items-center",children:[R,"Shopify Order Note",s.jsx(F,{size:"icon-xs",variant:"link",onClick:()=>{j(!0)},children:s.jsx(bs,{})})]}),t[21]=w):w=t[21];let _;t[22]!==v?(_=s.jsxs(Se,{className:"mt-4",children:[w,s.jsx(we,{children:v})]}),t[22]=v,t[23]=_):_=t[23];let I;return t[24]!==_||t[25]!==C?(I=s.jsxs(s.Fragment,{children:[C,_]}),t[24]=_,t[25]=C,t[26]=I):I=t[26],I},od=t=>{const e=T.c(45),{open:n,onClose:l}=t,{shop:r}=Ce(),{returnGroup:i}=se(),o=i.order.platformId,d=r?.platform===Is.Shopify&&!!o;let c;e[0]!==o?(c=[o],e[0]=o,e[1]=c):c=e[1];let u;e[2]!==d||e[3]!==c?(u={enabled:d,queryKey:c},e[2]=d,e[3]=c,e[4]=u):u=e[4];let m;e[5]!==o?(m={platformOrderId:o},e[5]=o,e[6]=m):m=e[6];const{data:f,isFetching:h}=_l(u,m);let p;e[7]!==l?(p={onSuccess:()=>{G.success("Order note updated."),l(!0)},onError:cd},e[7]=l,e[8]=p):p=e[8];const{isPending:x,mutate:j}=id(p),[g,b]=le.useState("");let y;e[9]!==f?.platformOrderNote||e[10]!==n?(y=()=>{n&&b(f?.platformOrderNote??"")},e[9]=f?.platformOrderNote,e[10]=n,e[11]=y):y=e[11];const v=f?.platformOrderNote;let S;if(e[12]!==n||e[13]!==v?(S=[n,v],e[12]=n,e[13]=v,e[14]=S):S=e[14],le.useEffect(y,S),r?.platform!==Is.Shopify)return null;let C;e[15]!==l?(C=O=>{O||l(!1)},e[15]=l,e[16]=C):C=e[16];let R,w;e[17]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(ye,{children:"Sync Shopify Order Note"}),w=s.jsx(Oe,{children:"Note will be synced to the order note on Shopify."}),e[17]=R,e[18]=w):(R=e[17],w=e[18]);let _;e[19]!==h||e[20]!==x||e[21]!==g?(_=h?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(Ps,{})}):s.jsx(xe,{children:s.jsx(mn,{id:"reuploadNote",rows:3,name:"reuploadNote",maxLength:200,value:g,disabled:h||x,onChange:O=>{b(O.currentTarget.value)}})}
133),e[19]=h,e[20]=x,e[21]=g,e[22]=_):_=e[22];let I;e[23]!==l?(I=()=>{l(!1)},e[23]=l,e[24]=I):I=e[24];const N=h||x;let A;e[25]!==I||e[26]!==N?(A=s.jsx(F,{variant:"outline",onClick:I,disabled:N,children:"Cancel"}),e[25]=I,e[26]=N,e[27]=A):A=e[27];let P;e[28]!==j||e[29]!==g||e[30]!==o?(P=()=>{j({platformOrderId:o,input:{note:g}})},e[28]=j,e[29]=g,e[30]=o,e[31]=P):P=e[31];const k=h||x;let E;e[32]!==P||e[33]!==k?(E=s.jsx(F,{onClick:P,disabled:k,children:"Update"}),e[32]=P,e[33]=k,e[34]=E):E=e[34];let z;e[35]!==A||e[36]!==E?(z=s.jsxs(Ne,{children:[A,E]}),e[35]=A,e[36]=E,e[37]=z):z=e[37];let D;e[38]!==_||e[39]!==z?(D=s.jsxs(ve,{children:[R,w,_,z]}),e[38]=_,e[39]=z,e[40]=D):D=e[40];let $;return e[41]!==n||e[42]!==D||e[43]!==C?($=s.jsx(je,{open:n,onOpenChange:C,children:D}),e[41]=n,e[42]=D,e[43]=C,e[44]=$):$=e[44],$};function cd(){G.error(`Failed to update order note. Please contact ${ut}.`)}const dd=Re(he` 134 mutation UpdateCustomerEmail($email: String!, $returnGroupId: Int!) { 135 updateCustomerEmail(email: $email, returnGroupId: $returnGroupId) { 136 customer { 137 email 138 } 139 userErrors { 140 message 141 } 142 } 143 } 144`),ud=()=>{const t=T.c(50),e=Ee(),{returnGroup:n,refetch:l}=se(),{order:r,legacyExchangeOrder:i}=n,{name:o,customer:a,platformId:d}=r;let c;t[0]!==e||t[1]!==l?(c={onSuccess:E=>{if(E.updateCustomerEmail.userErrors?.length){G.error(E.updateCustomerEmail.userErrors[0].message);return}G.success("Customer email updated"),e.close("updateCustomerEmail"),l()},onError:fd},t[0]=e,t[1]=l,t[2]=c):c=t[2];const u=dd(c);let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(fs,{className:"size-4"}),t[3]=m):m=t[3];let f;t[4]!==d?(f=s.jsx(cn,{className:"ml-2",platformOrderId:d,children:m}),t[4]=d,t[5]=f):f=t[5];let h;t[6]!==o||t[7]!==f?(h=s.jsxs(ft,{className:"flex",children:["Order ",o,f]}),t[6]=o,t[7]=f,t[8]=h):h=t[8];let p;t[9]!==n.order.platformCreatedAt?(p=n.order.platformCreatedAt?s.jsx($t,{prefix:"Created",timestamp:n.order.platformCreatedAt}):null,t[9]=n.order.platformCreatedAt,t[10]=p):p=t[10];let x;t[11]!==h||t[12]!==p?(x=s.jsxs("div",{children:[h,p]}),t[11]=h,t[12]=p,t[13]=x):x=t[13];let j;t[14]!==a||t[15]!==e?(j=a?s.jsxs(yt,{children:[s.jsx(vt,{render:hd}),s.jsx(St,{className:"w-fit",children:s.jsx(Me,{onClick:()=>{e.open("updateCustomerEmail")},children:"Update Customer Email"})})]}):null,t[14]=a,t[15]=e,t[16]=j):j=t[16];let g;t[17]!==x||t[18]!==j?(g=s.jsxs("div",{className:"flex justify-between items-center",children:[x,j]}),t[17]=x,t[18]=j,t[19]=g):g=t[19];let b;t[20]!==a?(b=a?.shippingAddress?s.jsxs(Se,{className:"mt-4",children:[s.jsx(be,{icon:Bi,children:"Shipping Address"}),s.jsxs(we,{children:[a.shippingAddress.fullName,s.jsx("br",{}),a.shippingAddress.address1,s.jsx("br",{}),a.shippingAddress.address2?s.jsxs(s.Fragment,{children:[a.shippingAddress.address2,s.jsx("br",{})]}):null,a.shippingAddress.city," ",a.shippingAddress.province,","," ",a.shippingAddress.country," ",a.shippingAddress.zip]})]}):null,t[20]=a,t[21]=b):b=t[21];let y;t[22]!==a?(y=a?.email?s.jsxs(Se,{className:"mt-4",children:[s.jsx(be,{icon:Un,children:"Email"}),s.jsx(we,{children:a.email})]}):null,t[22]=a,t[23]=y):y=t[23];let v;t[24]!==a?(v=a?.phone?s.jsxs(Se,{className:"mt-4",children:[s.jsx(be,{icon:hi,children:"Phone"}),s.jsx(we,{children:a.phone})]}):null,t[24]=a,t[25]=v):v=t[25];let S;t[26]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(ad,{}),t[26]=S):S=t[26];let C;t[27]!==i?(C=i?s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{className:"flex mt-4",children:["Original Order for Exchange (",s.jsx(ei,{to:`/${i?.returnGroupId}${location.search}`,className:tr({variant:"link",className:"h-auto p-0"}),children:i?.name}),")",i?.platformId?s.jsx(cn,{className:"ml-2",platformOrderId:i?.platformId,children:s.jsx(fs,{className:"size-4"})}):null]}),i?.platformCreatedAt?s.jsx($t,{prefix:"Created",timestamp:i.platformCreatedAt}):null]}):null,t[27]=i,t[28]=C):C=t[28];let R;t[29]!==e?(R=e.getDialogProps("updateCustomerEmail"),t[29]=e,t[30]=R):R=t[30];let w;t[31]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Ie,{children:s.jsx(ye,{children:"Update Customer Email"})}
144),t[31]=w):w=t[31];const _=a?.email||"";let I;t[32]!==n.id||t[33]!==_?(I={returnGroupId:n.id,email:_},t[32]=n.id,t[33]=_,t[34]=I):I=t[34];let N;t[35]!==u?(N=E=>u.mutateAsync(E),t[35]=u,t[36]=N):N=t[36];let A;t[37]!==I||t[38]!==N?(A=s.jsxs(ve,{children:[w,s.jsx(md,{data:I,onSubmit:N})]}),t[37]=I,t[38]=N,t[39]=A):A=t[39];let P;t[40]!==R||t[41]!==A?(P=s.jsx(je,{...R,children:A}),t[40]=R,t[41]=A,t[42]=P):P=t[42];let k;return t[43]!==y||t[44]!==v||t[45]!==C||t[46]!==P||t[47]!==g||t[48]!==b?(k=s.jsxs(Ze,{className:"w-full",children:[g,b,y,v,S,C,P]}),t[43]=y,t[44]=v,t[45]=C,t[46]=P,t[47]=g,t[48]=b,t[49]=k):k=t[49],k},md=t=>{const e=T.c(18),{data:n,onSubmit:l}=t;let r;e[0]!==n.email||e[1]!==n.returnGroupId?(r={defaultValues:{email:n.email,returnGroupId:n.returnGroupId}},e[0]=n.email,e[1]=n.returnGroupId,e[2]=r):r=e[2];const i=Nt(r);let o;e[3]!==i||e[4]!==l?(o=i.handleSubmit(l),e[3]=i,e[4]=l,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a={required:"Email is required",pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Invalid email address"}},e[6]=a):a=e[6];let d;e[7]!==i.control?(d=s.jsx(lt,{control:i.control,name:"email",rules:a,render:pd}),e[7]=i.control,e[8]=d):d=e[8];let c;e[9]!==o||e[10]!==d?(c=s.jsx("form",{onSubmit:o,className:"flex flex-col gap-4 h-full",id:"update-customer-email-form",children:d}),e[9]=o,e[10]=d,e[11]=c):c=e[11];let u;e[12]!==i.formState.isSubmitting?(u=s.jsx(Ne,{children:s.jsx(F,{type:"submit",form:"update-customer-email-form",disabled:i.formState.isSubmitting,children:"Save"})}),e[12]=i.formState.isSubmitting,e[13]=u):u=e[13];let m;return e[14]!==i||e[15]!==c||e[16]!==u?(m=s.jsxs(kt,{...i,children:[c,u]}),e[14]=i,e[15]=c,e[16]=u,e[17]=m):m=e[17],m};function fd(){G.error("Failed to update customer email")}function hd(t){const{...e}=t;return s.jsx(F,{variant:"ghost",size:"icon",...e,children:s.jsx(Ct,{})})}function pd(t){const{field:e}=t;return s.jsxs(rt,{children:[s.jsx(Ts,{children:"Email"}),s.jsx(pt,{render:()=>s.jsx(Pe,{type:"email",...e})}),s.jsx(bt,{})]})}const ht=t=>Math.round(t*100)/100,Ql=t=>t.flatMap(({refunds:e})=>e).map(({transactions:e,status:n})=>n===_s.Succesfull?e.map(l=>l.amount.shopMoney.amount).reduce((l,r)=>l+r,0):0).reduce((e,n)=>e+n,0),xd=t=>{const e=T.c(26),{refundGroups:n}=t,{settings:l}=Ce();if(!l)return null;const r=l.localization.currencyCode;if(n.length===0)return null;let i,o,a,d,c,u,m;if(e[0]!==r||e[1]!==n){const j={amount:Ql(n),currencyCode:r};let g;e[9]!==n?(g=n.map(yd),e[9]=n,e[10]=g):g=e[10],e[11]!==g?(m=s.jsx("div",{className:"flex flex-col space-y-2",children:g}),e[11]=g,e[12]=m):m=e[12],c="flex justify-between mt-2",e[13]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(be,{children:"Total Refunded Amount"}),e[13]=u):u=e[13],i=It,o="sm",a="semibold",d=fe(j,!0),e[0]=r,e[1]=n,e[2]=i,e[3]=o,e[4]=a,e[5]=d,e[6]=c,e[7]=u,e[8]=m}else i=e[2],o=e[3],a=e[4],d=e[5],c=e[6],u=e[7],m=e[8];let f;e[14]!==i||e[15]!==o||e[16]!==a||e[17]!==d?(f=s.jsx(i,{size:o,weight:a,children:d}),e[14]=i,e[15]=o,e[16]=a,e[17]=d,e[18]=f):f=e[18];let h;e[19]!==c||e[20]!==u||e[21]!==f?(h=s.jsxs("div",{className:c,children:[u,f]}),e[19]=c,e[20]=u,e[21]=f,e[22]=h):h=e[22];let p;return e[23]!==m||e[24]!==h?(p=s.jsxs("div",{children:[m,h]}),e[23]=m,e[24]=h,e[25]=p):p=e[25],p},gd={[He.Failed]:"Failed",[He.PartiallyFailed]:"Partially Failed",[He.Succesfull]:"Successful",[He.Unknown]:"Unknown"},jd={[_s.Failed]:"Failed",[_s.Ready]:"Partially Failed",[_s.Succesfull]:"Successful",[_s.Unknown]:"Unknown"},bd=t=>{const e=T.c(34),{refundGroup:n}=t,{createdAt:l,refundType:r,refunds:i,status:o}=n,{settings:a}=Ce();if(!a)return null;const d=a.localization.currencyCode;let c,u,m,f,h,p;if(e[0]!==d||e[1]!==r||e[2]!==i){const w={amount:i.map(Nd).reduce(Cd,0),currencyCode:d};h="flex justify-between";let _;e[9]!==r?(_=r.replaceAll("_"," ").toLowerCase(),e[9]=r,e[10]=_):_=e[10],e[11]!==_?(p=s.jsx(be,{className:"capitalize",children:_}),e[11]=_,e[12]=p):p=e[12],c=It,u="sm",m="semibold",f=fe(w,!0),e[0]=d,e[1]=r,e[2]=i,e[3]=c,e[4]=u,e[5]=m,e[6]=f,e[7]=h,e[8]=p}else c=e[3],u=e[4],m=e[5],f=e[6],h=e[7],p=e[8];let x;e[13]!==c||e[14]!==u||e[15]!==m||e[16]!==f?(x=s.jsx(c,{size:u,weight:m,children:f}),e[13]=c,e[14]=u,e[15]=m,e[16]=f,e[17]=x):x=e[17];let j;e[18]!==h||e[19]!==p||e[20]!==x?(j=s.jsxs("div",{className:h,children:[p,x]}),e[18]=h,e[19]=p,e[20]=x,e[21]=j):j=e[21];const g=gd[o];let b;e[22]!==g?(b=s.jsxs(M,{size:"xs",tone:"muted",children:["Status: ",s.jsx(ws,{children:g})]}),e[22]=g,e[23]=b):b=e[23];let y;e[24]!==l?(y=s.jsx($t,{prefix:"Issued",timestamp:l}),e[24]=l,e[25]=y):y=e[25];let v;e[26]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(Pt,{className:"mt-2 mb-1",children:"Transactions"}),e[26]=v):v=e[26];let S;e[27]!==i?(S=i.map(_d),e[27]=i,e[28]=S):S=e[28];let C;return e[29]!==b||e[30]!==y||e[31]!==S||e[32]!==j?(C=s.jsxs("div",{children:[j,b,y,v,S]}),e[29]=b,e[30]=y,e[31]=S,e[32]=j,e[33]=C):C=e[33],C};function yd(t){return s.jsx(bd,{refundGroup:t},t.id)}function vd(t){return t.amount.shopMoney.amount}function Sd(t,e){return t+e}function Nd(t){const{transactions:e}=t;return e.map(vd).reduce(Sd,0)}function Cd(t,e){return t+e}function _d(t){return s.jsxs("div",{className:"space-y-1",children:[t.transactions.map(e=>s.jsxs("div",{className:"flex justify-between",children:[s.jsxs(M,{size:"xs",tone:"muted",className:"flex flex-col",children:[s.jsx(ws,{children:e.formattedGateway}),s.jsxs("span",{children:["Status: ",s.jsx(ws,{children:jd[t.status]})]})]}),s.jsx(It,{size:"xs",children:fe(e.amount.shopMoney,!0)})]},e.platformId)),t.giftCard&&!t.transactions[0]?.gateway?.includes(ti)?s.jsx(si,{platformGiftCardId:t.giftCard.platformId.split("/").pop()||"",children:"View Gift Card"},t.giftCard.id):null]},t.id)}const Hl=()=>{const t=T.c(7),e=Ee();let n;t[0]!==e?(n=e.getDialogProps("refundAdvancedModal"),t[0]=e,t[1]=n):n=t[1];const l=n;let r;t[2]!==l.open?(r=l.open?s.jsx(Rd,{}):null,t[2]=l.open,t[3]=r):r=t[3];let i;return t[4]!==l||t[5]!==r?(i=s.jsx(je,{...l,children:r}),t[4]=l,t[5]=r,t[6]=i):i=t[6],i},Rd=()=>{const{close:t}=Ee(),{returnGroup:e,refetch:n,refundTransactions:l}=se(),{settings:r}=Ce(),i=wd({onError:()=>{G.error(`Failed to issue refund. Please email ${ut} for support.`),n()},onSuccess:_=>{_?.issueRefund?.status===He.Succesfull?G.success("Refund has been issued."):G.error(`Failed to issue refund. Please email ${ut} for support.`),n()}}),[o,a]=le.useState(!1),d=Nt({defaultValues:{selectedReturnIds:[],refundAmountExpression:""},mode:"onChange"}),c=Jn({control:d.control,name:"refundAmountExpression"}),u=Jn({control:d.control,name:"selectedReturnIds"}),m=Cs(c)??0,{returns:f}=e,{id:h,creditMethod:p,status:x}=e,j=l?.__typename==="Transactions"?l.transactions:[];if(!r)return null;const g=r.localization.currencyCode,b=qn(g)||"$",y=ht(j.map(_=>_.maximumRefundable?.shopMoney.amount||0).reduce((_,I)=>_+I,0)),v=x===Fe.InReview||!e.refundAllowed,S=d.formState.isSubmitting,C=S?"Processing...":`Refund ${b}${m?m.toFixed(2):"0.00"}`,R=async _=>{try{await i.mutateAsync({input:{returnGroupId:h,refundAmount:Cs(_.refundAmountExpression)??0,processReturnIds:_.selectedReturnIds}})}catch{}},w=async _=>{if((Cs(_.refundAmountExpression)??0)>e.refundQuote.amount.shopMoney.amount){a(!0);return}await R(_)};return s.jsxs(s.Fragment,{children:[s.jsxs(ve,{className:"sm:max-w-4xl",children:[s.jsx(Ie,{children:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(ye,{children:"Refund Advanced"}),s.jsx(Oe,{children:"Select return items and specify the refund amount to process the refund."})]})}),x===Fe.InReview?s.jsxs(xt,{children:[s.jsx(sr,{}),s.jsx(Tt,{children:"Refunds can not be issued until return has been reviewed."})]}
144):null,s.jsx(kt,{...d,children:s.jsx("form",{onSubmit:d.handleSubmit(w),className:"flex flex-col gap-4",children:s.jsxs(zs,{size:"sm",children:[s.jsxs(Pl,{children:[s.jsx(Tl,{children:"Return items to confirm"}),p?s.jsx(wi,{children:s.jsxs(it,{variant:"secondary",className:"capitalize",children:[p===on.StoreCredit?s.jsx(ni,{}):s.jsx(En,{}),p.toString().replaceAll("_"," ").toLowerCase()]})}):null]}),s.jsxs(Bn,{className:"flex flex-col gap-3",children:[s.jsx(lt,{control:d.control,name:"selectedReturnIds",rules:{validate:_=>_&&_.length>0||"Select at least one return to refund"},render:({field:_})=>{const I=_.value??[];return s.jsxs(rt,{children:[s.jsx(Ml,{className:"gap-2",children:f.map(N=>{const{productName:A,bundledQuantity:P,image:k,variantName:E,sku:z,priceBreakdown:D,money:$}=N.lineItem,O=D?.price.shopMoney??$,q=I.includes(N.id),B=N.status===js.Completed||N.status===js.Canceled,V=[E,z?`SKU: ${z}`:null].filter(Boolean).join(" · ");return s.jsxs(Ls,{size:"sm",className:dt(!B&&"cursor-pointer",q&&"bg-muted"),onClick:()=>{B||_.onChange(q?I.filter(L=>L!==N.id):[...I,N.id])},children:[s.jsx(fn,{disabled:B,checked:q,tabIndex:-1,className:"pointer-events-none"}),s.jsx(Hn,{image:k,productName:A,className:"size-12!",onClick:L=>L.stopPropagation()}),s.jsxs(Os,{children:[s.jsxs(Ms,{children:[A,P>1?s.jsxs(s.Fragment,{children:[" à ",P]}):null]}),V?s.jsx(Fs,{children:V}):null]}),O?s.jsx(zl,{children:s.jsx(Ds,{weight:"regular",children:fe(O,!0)})}):null]},N.id)})}),s.jsx("div",{className:"min-h-5",children:s.jsx(bt,{})})]})}}),s.jsx(Id,{returnGroup:e,selectedReturns:f.filter(_=>u.includes(_.id)),availableForRefund:{amount:y,currencyCode:g}}),s.jsx(lt,{control:d.control,name:"refundAmountExpression",rules:{validate:_=>{if(_.trim()==="")return"Enter an amount to refund";const N=Cs(_);return N===null?"Enter a valid amount or expression":N<=0?"Amount must be greater than 0":!0}},render:({field:_,fieldState:I})=>{const N=_.value.trim()==="",A=Cs(_.value),P=!N&&A===null;return s.jsxs(rt,{children:[s.jsx(pt,{render:()=>s.jsxs($n,{children:[s.jsx(an,{children:s.jsx(li,{})}),s.jsx(kn,{type:"text",inputMode:"decimal",autoComplete:"off",spellCheck:!1,placeholder:"e.g. (240 - 15) / 2",disabled:S||v,..._}),s.jsx(an,{align:"inline-end",children:s.jsx("span",{className:dt("font-semibold tabular-nums pr-1",(P||I.error)&&"text-destructive"),children:P?"Invalid":fe({amount:A??0,currencyCode:g},!0)})})]})}),s.jsx("div",{className:"min-h-5",children:s.jsx(bt,{})})]})}})]})]})})}),s.jsxs(Ne,{children:[s.jsx(F,{variant:"outline",onClick:()=>t("refundAdvancedModal"),disabled:S,children:"Cancel"}),s.jsx(F,{disabled:v||S,onClick:d.handleSubmit(w),children:C})]})]}),s.jsx(je,{open:o,onOpenChange:a,children:s.jsxs(ve,{className:"sm:max-w-md",forceOverlay:!0,children:[s.jsx(Ie,{children:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(ye,{children:"Confirm refund"}),s.jsxs(Oe,{children:["Are you sure you want to refund ",b,m?m.toFixed(2):"0.00","? This is more than the amount owed."]})]})}),s.jsxs(Ne,{children:[s.jsx(F,{variant:"outline",onClick:()=>a(!1),disabled:S,children:"Cancel"}),s.jsx(F,{disabled:S,onClick:()=>{a(!1),d.handleSubmit(R)()},children:S?"Processing...":"Confirm"})]})]})})]})},Cs=t=>{const e=t.trim();if(!e||!/^[\d+\-*/().\s]+$/.test(e))return null;try{const n=new Function(`"use strict"; return (${e});`)();return typeof n!="number"||!Number.isFinite(n)?null:Math.round(n*100)/100}catch{return null}},wd=Re(he` 145 mutation IssueRefund($input: IssueRefundInput!) { 146 issueRefund(input: $input) { 147 id 148 status 149 } 150 } 151`),Id=t=>{const e=T.c(34),{returnGroup:n,selectedReturns:l,availableForRefund:r}=t,{refundQuote:i}=n,{adjustments:o,lineItemPrices:a,totalShipping:d}=i;if(a.length===0)return null;const c=a[0].price.discountedPrice.presentmentMoney.currencyCode,u=a[0].price.taxesIncluded;let m;e[0]!==l?(m=new Set(l.map(Ed)),e[0]=l,e[1]=m):m=e[1];const f=m;let h;if(e[2]!==a||e[3]!==f||e[4]!==u){let R;e[6]!==f?(R=I=>f.has(I.platformId),e[6]=f,e[7]=R):R=e[7];const w=a.filter(R),_=w.length>0?w:a.filter(Rl);h=u?0:ht(_.map(Ad).reduce($d,0)),e[2]=a,e[3]=f,e[4]=u,e[5]=h}else h=e[5];const p=h,x=d?.presentmentMoney.amount??0;let j,g,b,y,v;if(e[8]!==o||e[9]!==r||e[10]!==c||e[11]!==x||e[12]!==p){v=Symbol.for("react.early_return_sentinel");e:{const R=o.filter(kd);if(!(p>0||x>0||R.some(Pd)||r&&r.amount>0)){v=null;break e}j="flex flex-col gap-4 pr-3",e[18]!==c||e[19]!==p?(g=p>0?s.jsx(rn,{label:"Tax",amount:p,currencyCode:c}):null,e[18]=c,e[19]=p,e[20]=g):g=e[20],e[21]!==c||e[22]!==x?(b=x>0?s.jsx(rn,{label:"Shipping",amount:x,currencyCode:c}):null,e[21]=c,e[22]=x,e[23]=b):b=e[23];let _;e[24]!==c?(_=(I,N)=>{const{reason:A,amount:P}=I,k=P.presentmentMoney.amount;return k===0?null:s.jsx(rn,{label:A,amount:k,currencyCode:c},A+N.toString())},e[24]=c,e[25]=_):_=e[25],y=R.map(_)}e[8]=o,e[9]=r,e[10]=c,e[11]=x,e[12]=p,e[13]=j,e[14]=g,e[15]=b,e[16]=y,e[17]=v}else j=e[13],g=e[14],b=e[15],y=e[16],v=e[17];if(v!==Symbol.for("react.early_return_sentinel"))return v;let S;e[26]!==r?(S=r&&r.amount>0?s.jsx(rn,{label:"Available for refund",amount:r.amount,currencyCode:r.currencyCode,textClassName:"text-sm font-semibold"}):null,e[26]=r,e[27]=S):S=e[27];let C;return e[28]!==j||e[29]!==g||e[30]!==b||e[31]!==y||e[32]!==S?(C=s.jsxs("dl",{className:j,children:[g,b,y,S]}),e[28]=j,e[29]=g,e[30]=b,e[31]=y,e[32]=S,e[33]=C):C=e[33],C},rn=t=>{const e=T.c(13),{label:n,amount:l,currencyCode:r,textClassName:i}=t,o=i===void 0?"text-xs/3":i;let a;e[0]!==o?(a=dt("flex items-center justify-between",o),e[0]=o,e[1]=a):a=e[1];let d;e[2]!==n?(d=s.jsx("dt",{className:"text-foreground flex-1 truncate",children:n}),e[2]=n,e[3]=d):d=e[3];const c=r;let u;e[4]!==l||e[5]!==c?(u=fe({amount:l,currencyCode:c},!0),e[4]=l,e[5]=c,e[6]=u):u=e[6];let m;e[7]!==u?(m=s.jsx("dd",{className:"flex-none tabular-nums",children:u}),e[7]=u,e[8]=m):m=e[8];let f;return e[9]!==a||e[10]!==d||e[11]!==m?(f=s.jsxs("div",{className:a,children:[d,m]}),e[9]=a,e[10]=d,e[11]=m,e[12]=f):f=e[12],f};function Ed(t){return t.lineItem.platformLineItemId}function Ad(t){return t.price.totalTax.presentmentMoney.amount}function $d(t,e){return t+e}function kd(t){return t.isApplied}function Pd(t){return t.amount.presentmentMoney.amount!==0}const Zl={[We.DiscountCarryOver]:"Discount Carry Over",[We.EvenExchange]:"Even Exchange",[We.ExchangeCredit]:"Exchange Credit",[We.ExchangeOrderDiscount]:"Exchange Order Discount",[We.ExchangeUpsellIncentive]:"Exchange Upsell Incentive",[We.HandlingFee]:"Handling Fee",[We.Other]:"Other",[We.RestockingFee]:"Restocking Fee",[We.ShippingFee]:"Shipping Fee",[We.StoreCreditIncentive]:"Store Credit Incentive"},Td=[We.ShippingFee,We.Other],ul="refund-edit-form",Gd=({returnGroup:t,currencyCode:e,onSubmit:n,onClose:l,isPending:r})=>{const i=Nt({defaultValues:{adjustments:(t.adminFeeOverrides??[]).map(f=>({kind:f.kind,amount:Math.round(Math.abs(f.amount.presentmentMoney.amount)*100),reason:f.reason}))}}),{fields:o,append:a,remove:d}=Cr({control:i.control,name:"adjustments"}),c=i.watch("adjustments"),u=new Set(c.map(f=>f.kind)),m=Td.filter(f=>!u.has(f));return s.jsxs(s.Fragment,{children:[s.jsxs(Ie,{children:[s.jsx(ye,{children:"Update Refund Adjustments"}),s.jsx(Oe,{children:"Enter fee amounts as positive values."})]}),s.jsx(kt,{...i,children:s.jsxs("form",{id:ul,onSubmit:i.handleSubmit(n),className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"grid grid-cols-[160px_1fr_1fr_32px] items-center gap-x-3 gap-y-2",children:[o.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(bn,{children:"Fee"}),s.jsx(bn,{children:"Amount"}),s.jsx(bn,{children:"Reason"}),s.jsx("div",{})]}),o.map((f,h)=>s.jsx(zd,{index:h,currencyCode:e,onRemove:()=>d(h)},f.id))]}),m.length>0&&s.jsxs(Tn,{items:m,value:null,onValueChange:f=>{f&&a({kind:f,amount:0,reason:""})},children:[s.jsx(Gn,{render:s.jsxs(F,{type:"button",variant:"input",className:"w-48 justify-between",children:[s.jsx("div",{className:"truncate",children:"+ Add adjustment"}),s.jsx(zn,{})]})}),s.jsx(Mn,{children:s.jsx(Fn,{children:f=>s.jsx(Dn,{value:f,children:Zl[f]},f)})})]})]})}),s.jsxs(Ne,{children:[s.jsx(F,{variant:"outline",onClick:l,disabled:r,children:"Close"}),s.jsx(F,{type:"submit",form:ul,disabled:r,children:"Apply"})]})]})},zd=t=>{const e=T.c(19),{index:n,currencyCode:l,onRemove:r}=t,{control:i,watch:o}=_r(),a=o(`adjustments.${n}.kind`),d=Zl[a];let c;e[0]!==d?(c=s.jsx(M,{size:"sm",weight:"medium",children:d}),e[0]=d,e[1]=c):c=e[1];const u=`adjustments.${n}.amount`;let m;e[2]!==l?(m=b=>{const{field:y}=b;return s.jsx(rt,{className:"contents",children:s.jsx(pt,{render:s.jsx(Qn,{value:y.value,onValueChange:v=>y.onChange(v??0),currencyCode:l,allowDecimals:!0,clearOnFocus:y.value===0})})})},e[2]=l,e[3]=m):m=e[3];let f;e[4]!==i||e[5]!==u||e[6]!==m?(f=s.jsx(lt,{control:i,name:u,render:m}),e[4]=i,e[5]=u,e[6]=m,e[7]=f):f=e[7];const h=`adjustments.${n}.reason`;let p;e[8]!==i||e[9]!==h?(p=s.jsx(lt,{control:i,name:h,render:Md}),e[8]=i,e[9]=h,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(In,{className:"h-4 w-4"}),e[11]=x):x=e[11];let j;e[12]!==r?(j=s.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"text-zinc-400 hover:text-red-500",onClick:r,children:x}),e[12]=r,e[13]=j):j=e[13];let g;return e[14]!==c||e[15]!==f||e[16]!==p||e[17]!==j?(g=s.jsxs(s.Fragment,{children:[c,f,p,j]}),e[14]=c,e[15]=f,e[16]=p,e[17]=j,e[18]=g):g=e[18],g};function Md(t){const{field:e}=t;return s.jsx(rt,{className:"contents",children:s.jsx(pt,{render:s.jsx(Pe,{type:"text",placeholder:"Optional",...e,value:e.value??""})})})}const Fd=()=>{const t=T.c(87),{returnGroup:e}=se(),{refundQuote:n,refundGroups:l,paymentIntent:r,returnIntentShippingFee:i,exchangeLineItems:o,returns:a}
151=e,{adjustments:d,amount:c,lineItemPrices:u,currencyConversionRate:m,totalShipping:f}=n;let h,p,x,j,g,b,y,v,S,C;if(t[0]!==d||t[1]!==c||t[2]!==m||t[3]!==o||t[4]!==u||t[5]!==r||t[6]!==l||t[7]!==i||t[8]!==a||t[9]!==f){C=Symbol.for("react.early_return_sentinel");e:{const P=d.find(Dd)?.amount.presentmentMoney,k=!!r&&Math.abs(P?.amount??0)!==Math.abs(i?.amount??0);if(u.length===0){C=null;break e}p=c.presentmentMoney.currencyCode,x=c.shopMoney.currencyCode;const E=u[0].price.taxesIncluded;if(t[20]!==d||t[21]!==c.presentmentMoney.amount||t[22]!==m||t[23]!==o.length||t[24]!==u||t[25]!==p||t[26]!==l||t[27]!==a||t[28]!==E){const z=d.filter(Od),D=ht(z.map(Ld).reduce(Vd,0));let $;t[34]!==a?($=new Set(a.map(Ud)),t[34]=a,t[35]=$):$=t[35];const O=$;let q,B;if(t[36]!==u||t[37]!==O||t[38]!==E){let ee;t[41]!==O?(ee=de=>O.has(de.platformId),t[41]=O,t[42]=ee):ee=t[42];const U=u.filter(ee),J=U.length>0?U:u.filter(Rl);q=ht(J.map(qd).reduce(Bd,0)),B=E?0:ht(J.map(Kd).reduce(Wd,0)),t[36]=u,t[37]=O,t[38]=E,t[39]=q,t[40]=B}else q=t[39],B=t[40];const V=B;let L,K,W;t[43]!==u||t[44]!==E?(K=u.filter(ri),L=ht(K.map(Qd).reduce(Hd,0)),W=E?0:ht(K.map(Zd).reduce(Yd,0)),t[43]=u,t[44]=E,t[45]=L,t[46]=K,t[47]=W):(L=t[45],K=t[46],W=t[47]);const te=W,Z=E?0:(q+V+L+te-c.presentmentMoney.amount+D)*-1,H=te+Z,X=o.length>0,Q=K.length>0,Y=Q?L:0,ne=Q?H:0;h=Ql(l)*Number(m),j="flex flex-col space-y-3",t[48]!==p||t[49]!==q||t[50]!==V||t[51]!==a.length?(g=a.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{label:`Return Credits (${a.length})`,amount:q,currencyCode:p}),s.jsx(gt,{label:"Tax",amount:V,currencyCode:p})]}),t[48]=p,t[49]=q,t[50]=V,t[51]=a.length,t[52]=g):g=t[52],t[53]!==o.length||t[54]!==X||t[55]!==Y||t[56]!==ne||t[57]!==p?(b=X&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{label:`New Items (${o.length})`,amount:Y,currencyCode:p}),s.jsx(gt,{label:"Tax",amount:ne,currencyCode:p})]}),t[53]=o.length,t[54]=X,t[55]=Y,t[56]=ne,t[57]=p,t[58]=b):b=t[58],y=z.length>0?z.map((ee,U)=>{const{reason:J,amount:de}=ee,oe=de.presentmentMoney.amount;return oe===0?null:s.jsx(gt,{label:J,amount:oe,currencyCode:p},J+U.toString())}):null,t[20]=d,t[21]=c.presentmentMoney.amount,t[22]=m,t[23]=o.length,t[24]=u,t[25]=p,t[26]=l,t[27]=a,t[28]=E,t[29]=h,t[30]=j,t[31]=g,t[32]=b,t[33]=y}else h=t[29],j=t[30],g=t[31],b=t[32],y=t[33];t[59]!==p||t[60]!==f?(v=f&&f.presentmentMoney.amount>0?s.jsx(gt,{label:"Shipping",amount:f.presentmentMoney.amount,currencyCode:p}):null,t[59]=p,t[60]=f,t[61]=v):v=t[61],S=k?s.jsxs(xt,{className:"border-amber-200 bg-amber-50 text-amber-900",children:[s.jsx(An,{className:"size-4 text-amber-500"}),s.jsx(Gt,{children:`Shipping fee changed from ${i?fe({...i,amount:Math.abs(i.amount)}):"none"} to ${P?fe({...P,amount:Math.abs(P.amount)}):"none"}`})]}):null}t[0]=d,t[1]=c,t[2]=m,t[3]=o,t[4]=u,t[5]=r,t[6]=l,t[7]=i,t[8]=a,t[9]=f,t[10]=h,t[11]=p,t[12]=x,t[13]=j,t[14]=g,t[15]=b,t[16]=y,t[17]=v,t[18]=S,t[19]=C}else h=t[10],p=t[11],x=t[12],j=t[13],g=t[14],b=t[15],y=t[16],v=t[17],S=t[18],C=t[19];if(C!==Symbol.for("react.early_return_sentinel"))return C;let R;t[62]!==h||t[63]!==p?(R=h>0?s.jsx(gt,{label:"Already Refunded",amount:-h,currencyCode:p}):null,t[62]=h,t[63]=p,t[64]=R):R=t[64];const w=c.presentmentMoney.amount>=0?`Total Refund Amount ${p}`:`Total Amount Owed ${p}`;let _;t[65]!==c.presentmentMoney.amount||t[66]!==h?(_=c.presentmentMoney.amount>=0?c.presentmentMoney.amount-h:Math.abs(c.presentmentMoney.amount),t[65]=c.presentmentMoney.amount,t[66]=h,t[67]=_):_=t[67];let I;t[68]!==p||t[69]!==_||t[70]!==w?(I=s.jsx(gt,{size:"sm",weight:"semibold",label:w,amount:_,currencyCode:p}),t[68]=p,t[69]=_,t[70]=w,t[71]=I):I=t[71];let N;t[72]!==c.presentmentMoney.amount||t[73]!==c.shopMoney.amount||t[74]!==p||t[75]!==x?(N=p!==x&&s.jsx(M,{size:"sm",tone:"muted",className:"flex items-center justify-between py-2",children:`${fe({amount:Math.abs(c.presentmentMoney.amount),currencyCode:p},!0)} converts to ${fe({amount:Math.abs(c.shopMoney.amount),currencyCode:x},!0)}`}),t[72]=c.presentmentMoney.amount,t[73]=c.shopMoney.amount,t[74]=p,t[75]=x,t[76]=N):N=t[76];let A;return t[77]!==j||t[78]!==I||t[79]!==N||t[80]!==g||t[81]!==b||t[82]!==y||t[83]!==v||t[84]!==S||t[85]!==R?(A=s.jsxs("dl",{className:j,children:[g,b,y,v,S,R,I,N]}
151),t[77]=j,t[78]=I,t[79]=N,t[80]=g,t[81]=b,t[82]=y,t[83]=v,t[84]=S,t[85]=R,t[86]=A):A=t[86],A},gt=t=>{const e=T.c(31),{label:n,currencyCode:l,amount:r,className:i,size:o,weight:a}=t,d=o===void 0?"xs":o,c=a===void 0?"regular":a,u=l;let m,f,h,p,x,j,g,b;if(e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==d||e[4]!==u||e[5]!==c){const S={amount:r,currencyCode:u};e[14]!==i?(b=dt("flex items-center justify-between",i),e[14]=i,e[15]=b):b=e[15],e[16]!==n||e[17]!==d||e[18]!==c?(f=s.jsx(M,{as:"dt",size:d,weight:c,className:"flex-1 truncate",children:n}),e[16]=n,e[17]=d,e[18]=c,e[19]=f):f=e[19],m=It,h="dd",p=d,x=c,j="flex-none",g=fe(S),e[0]=r,e[1]=i,e[2]=n,e[3]=d,e[4]=u,e[5]=c,e[6]=m,e[7]=f,e[8]=h,e[9]=p,e[10]=x,e[11]=j,e[12]=g,e[13]=b}else m=e[6],f=e[7],h=e[8],p=e[9],x=e[10],j=e[11],g=e[12],b=e[13];let y;e[20]!==m||e[21]!==h||e[22]!==p||e[23]!==x||e[24]!==j||e[25]!==g?(y=s.jsx(m,{as:h,size:p,weight:x,className:j,children:g}),e[20]=m,e[21]=h,e[22]=p,e[23]=x,e[24]=j,e[25]=g,e[26]=y):y=e[26];let v;return e[27]!==f||e[28]!==y||e[29]!==b?(v=s.jsxs("div",{className:b,children:[f,y]}),e[27]=f,e[28]=y,e[29]=b,e[30]=v):v=e[30],v};function Dd(t){return t.kind===We.ShippingFee}function Od(t){return t.isApplied}function Ld(t){return t.amount.presentmentMoney.amount}function Vd(t,e){return t+e}function Ud(t){return t.lineItem.platformLineItemId}function qd(t){return t.price.discountedPrice.presentmentMoney.amount}function Bd(t,e){return t+e}function Kd(t){return t.price.totalTax.presentmentMoney.amount}function Wd(t,e){return t+e}function Qd(t){return t.price.discountedPrice.presentmentMoney.amount}function Hd(t,e){return t+e}function Zd(t){return t.price.totalTax.presentmentMoney.amount}function Yd(t,e){return t+e}const Jd=()=>{const t=T.c(50),{settings:e}=Ce(),{returnGroup:n,refetch:l,refundTransactions:r,refundTransactionsRefetch:i}=se(),{id:o,creditMethod:a,status:d}=n,c=Ee(),u=String(o);let m;t[0]!==u?(m=[u],t[0]=u,t[1]=m):m=t[1];const f=!!o;let h;t[2]!==m||t[3]!==f?(h={queryKey:m,enabled:f},t[2]=m,t[3]=f,t[4]=h):h=t[4];let p;t[5]!==o?(p={returnGroupId:o},t[5]=o,t[6]=p):p=t[6];const x=wl(h,p),j=r?.__typename==="Transactions"?r.transactions:[],g=ht(j.map(tu).reduce(su,0)),b=ht(j.map(nu).reduce(lu,0)),[y,v]=le.useState(String(g)),S=Number(y)||0;let C;t[7]!==l||t[8]!==i?(C=()=>{l(),i()},t[7]=l,t[8]=i,t[9]=C):C=t[9];const R=C,w=le.useRef(g);le.useEffect(()=>{w.current!==g&&(w.current=g,v(String(g)),R())},[g,R]);let _;t[10]!==R?(_={onError:()=>{G.error(`Failed to issue refund. Please email ${ut} for support.`),R()},onSuccess:()=>{G.success("Refund has been issued."),R()}},t[10]=R,t[11]=_):_=t[11];const{mutate:I,isPending:N}=Xd(_);let A;t[12]!==R?(A={onSuccess:()=>{G.success("Return has been marked as refunded."),R()}},t[12]=R,t[13]=A):A=t[13];const{mutate:P,isPending:k}=eu(A);let E;t[14]!==c||t[15]!==R?(E={onSuccess:()=>{G.success("Refund adjustments have been updated."),R(),c.close("refundEditModal")}},t[14]=c,t[15]=R,t[16]=E):E=t[16];const z=Il(E);if(!e)return null;const D=e.localization.currencyCode;let $;t[17]!==D?($=qn(D)||"$",t[17]=D,t[18]=$):$=t[18];const O=$,q=N||k;let B;t[19]!==c?(B=c.getDialogProps("refundEditModal"),t[19]=c,t[20]=B):B=t[20];let V;t[21]!==n.id||t[22]!==z?(V=J=>{z.mutate({input:{returnGroupId:n.id,refundAdjustments:J.adjustments.map(ru)}})},t[21]=n.id,t[22]=z,t[23]=V):V=t[23];let L;t[24]!==c?(L=()=>c.close("refundEditModal"),t[24]=c,t[25]=L):L=t[25];let K;t[26]!==D||t[27]!==n||t[28]!==V||t[29]!==L||t[30]!==z.isPending?(K=s.jsx(ve,{className:"max-w-3xl!",children:s.jsx(Gd,{returnGroup:n,currencyCode:D,onSubmit:V,onClose:L,isPending:z.isPending})}),t[26]=D,t[27]=n,t[28]=V,t[29]=L,t[30]=z.isPending,t[31]=K):K=t[31];let W;t[32]!==B||t[33]!==K?(W=s.jsx(je,{...B,children:K}),t[32]=B,t[33]=K,t[34]=W):W=t[34];const te="flex flex-col";let Z;t[35]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Pt,{children:"Summary"}),t[35]=Z):Z=t[35];let H;t[36]!==c||t[37]!==n?(H=pi(n)?s.jsx(F,{className:"ml-2",size:"icon-xs",variant:"link",onClick:()=>c.open("refundEditModal",null),children:s.jsx(bs,{})}):null,t[36]=c,t[37]=n,t[38]=H):H=t[38];let X;t[39]!==H?(X=s.jsxs("div",{className:"flex flex-row mb-2 items-center",children:[Z,H]}),t[39]=H,t[40]=X):X=t[40];let Q;t[41]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(Fd,{}),t[41]=Q):Q=t[41];const Y=d===Fe.InReview?s.jsx("div",{className:"border border-border rounded p-2 bg-muted mt-4",children:s.jsx(M,{size:"xs",weight:"semibold",tone:"muted",children:"Refunds can not be issued until return has been reviewed."})}):n.refundAllowed?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mt-6",children:[s.jsxs("div",{className:"capitalize mb-2 flex items-center",children:[s.jsxs(M,{size:"sm",children:[a===on.StoreCredit?"Issuing":"Refunding"," ",s.jsx(M,{as:"span",size:"sm",weight:"semibold",children:a?.toString().replaceAll("_"," ").toLowerCase()})]}),Ln(n)?s.jsx(F,{size:"icon-xs",variant:"link",className:"ml-2",onClick:()=>c.open("creditMethod",null),children:s.jsx(bs,{})}):null]}),s.jsxs($n,{children:[s.jsx(kn,{type:"number",value:y,disabled:q,step:"0.01",onChange:J=>{v(J.currentTarget.value)},onBlur:J=>{const de=J.currentTarget.value.trim(),oe=Number(de.replace(",","."));if(Number.isNaN(oe)||oe<=0){v(String(g));return}v(oe.toFixed(2))}}),s.jsx(an,{children:O}),s.jsx(an,{align:"inline-end",children:D})]})]}),s.jsx(M,{size:"xs",tone:"muted",className:"mt-2",children:`${O}${b.toFixed(2)} available for refund`}),x.data?.ruleCalculations.some(iu)?s.jsxs(xt,{color:"yellow",title:"Held for Manual Refund",className:"mt-4 p-4 bg-amber-50 border border-amber-200 rounded-lg text-center",children:[s.jsx(vs,{className:"w-4 h-4 text-amber-500"}),"Held for Manual Refund"]}):null,S>n.refundQuote.amount.shopMoney.amount?s.jsxs(hs,{children:[s.jsx(ps,{render:J=>s.jsxs(F,{className:"w-full mt-6 mb-2",disabled:q,...J,children:["Refund ",O,S?S.toFixed(2):"0.00"]})}),s.jsx(xs,{className:"w-[360px] bg-popover p-4 rounded shadow-sm border border-border mt-1",children:s.jsxs("div",{className:"flex flex-col",children:[s.jsxs(M,{size:"sm",children:["Are you sure you want to refund ",O,S?S.toFixed(2):"0.00","? This is more than the amount owed."]}),s.jsx("div",{className:"grid grid-cols-2 mt-4 gap-x-2",children:s.jsx(F,{onClick:()=>{I({input:{returnGroupId:o,refundAmount:S}})},disabled:q,children:"Confirm"})})]})})]}):s.jsxs(F,{className:"w-full mt-6 mb-2",disabled:S<=0||S>b||q,onClick:()=>{I({input:{returnGroupId:o,refundAmount:S}})},children:["Refund ",O,S?S.toFixed(2):"0.00"]}),n.creditMethod===on.OriginalPaymentMethod&&n.returns.filter(au).length>1?s.jsxs(F,{variant:"outline",onClick:()=>{c.open("refundAdvancedModal",null)},className:"mb-2.5",children:["Refund Advanced",s.jsx(fs,{})]}
151):null,s.jsxs(hs,{children:[s.jsx(ps,{render:J=>s.jsx(F,{variant:"outline",className:"w-full",disabled:q,...J,children:"Mark as Refunded"})}),s.jsx(xs,{className:"w-[360px] bg-popover p-4 rounded shadow-sm border border-border mt-1",children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx(M,{size:"sm",children:"Are you sure you want to mark this return as refunded? This usually means refund was issued outside of Route Returns or Shopify."}),s.jsx("div",{className:"grid grid-cols-2 mt-4 gap-x-2",children:s.jsx(F,{onClick:()=>P({input:{returnGroupId:o,refundAmount:S||0}}),disabled:q,children:"Confirm"})})]})})]})]}):s.jsx(Ss,{className:"mt-2",children:"No eligible refunds to issue."});let ne;t[42]!==X||t[43]!==Q||t[44]!==Y?(ne=s.jsxs("div",{className:te,children:[X,Q,Y]}),t[42]=X,t[43]=Q,t[44]=Y,t[45]=ne):ne=t[45];let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(Hl,{}),t[46]=ee):ee=t[46];let U;return t[47]!==W||t[48]!==ne?(U=s.jsxs(s.Fragment,{children:[W,ne,ee]}),t[47]=W,t[48]=ne,t[49]=U):U=t[49],U},Xd=Re(he` 152 mutation IssueRefund($input: IssueRefundInput!) { 153 issueRefund(input: $input) { 154 id 155 status 156 } 157 } 158`),eu=Re(he` 159 mutation MarkAsRefunded($input: IssueRefundInput!) { 160 markAsRefunded(input: $input) { 161 id 162 } 163 } 164`);function tu(t){return t.amount.shopMoney.amount}function su(t,e){return t+e}function nu(t){return t.maximumRefundable?.shopMoney.amount||0}function lu(t,e){return t+e}function ru(t){return{kind:t.kind,amount:-Math.abs(t.amount)/100,reason:t.reason||void 0}}function iu(t){return t.ruleDefinitionSnapshot.action===us.HoldForManualRefund}function au(t){return t.status===js.Open}const ou=()=>{const t=T.c(21),{settings:e,shop:n}=Ce(),{returnGroup:l,refundTransactions:r,isRefundTransactionsError:i}=se(),{refundGroups:o}=l,a=e?.refundPolicy.refundIsAutomatic,d=e?.refundPolicy.refundEligibleMinState,c=i||r?.__typename==="Errors";let u;t[0]!==o.length?(u=s.jsxs(ft,{children:["Refunds (",o.length,")"]}),t[0]=o.length,t[1]=u):u=t[1];let m;t[2]!==o?(m=s.jsx(xd,{refundGroups:o}),t[2]=o,t[3]=m):m=t[3];let f;t[4]!==i||t[5]!==r||t[6]!==l.order||t[7]!==n?.platform||t[8]!==n?.shopName||t[9]!==c?(f=!r&&!i?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(Ps,{})}):s.jsxs(s.Fragment,{children:[c?s.jsxs(M,{size:"sm",tone:"destructive",className:"mb-3",children:[r?.__typename==="Errors"&&r.errors?.[0]?.message||"Couldn't find a refundable payment method."," ","You can mark this return as refunded if the refund was handled outside Route Returns.",n?.platform===Is.Shopify?s.jsxs(s.Fragment,{children:[s.jsx("br",{}),"You can also process a refund manually through your"," ",l.order.legacyExchangeOrderPlatformId?s.jsx("a",{className:ii,href:`https://admin.shopify.com/store/${n?.shopName}/orders/${l.order.legacyExchangeOrderPlatformId}/`,target:"_blank",rel:"noreferrer",children:"Shopify dashboard"}):s.jsx(s.Fragment,{children:"Shopify dashboard"}),"."]}):null]}):null,s.jsx(Jd,{})]}),t[4]=i,t[5]=r,t[6]=l.order,t[7]=n?.platform,t[8]=n?.shopName,t[9]=c,t[10]=f):f=t[10];let h;t[11]!==d||t[12]!==a||t[13]!==i||t[14]!==r?(h=a&&(r||i)?s.jsxs(M,{size:"xs",tone:"muted",children:["Automatic refunds are enabled."," ",d?s.jsxs(s.Fragment,{children:["Refunds will be process when return is"," ",s.jsx(ws,{as:"span",className:"capitalize",children:Rr(d)}),"."]}):null]}):null,t[11]=d,t[12]=a,t[13]=i,t[14]=r,t[15]=h):h=t[15];let p;return t[16]!==u||t[17]!==m||t[18]!==f||t[19]!==h?(p=s.jsxs(Ze,{className:"gap-1",children:[u,m,f,h]}),t[16]=u,t[17]=m,t[18]=f,t[19]=h,t[20]=p):p=t[20],p},cu=t=>{const e=T.c(33),{ruleCalculation:n}=t,{shop:l}=Ce(),{get:r}=Ol(),i=wr(),o=Vi(),a=n.ruleDefinitionSnapshot;let d;e[0]!==i.data?.shippingZones?(d=i.data?.shippingZones??[],e[0]=i.data?.shippingZones,e[1]=d):d=e[1];const c=d;let u;e[2]!==o.data?.termsAndAgreements?(u=o.data?.termsAndAgreements??[],e[2]=o.data?.termsAndAgreements,e[3]=u):u=e[3];const m=u;let f;e[4]!==c?(f=w=>c.find(_=>_.id===w),e[4]=c,e[5]=f):f=e[5];const h=f;let p;e[6]!==m?(p=w=>m.find(_=>_.id===w),e[6]=m,e[7]=p):p=e[7];const x=p,j=Ki[a.action];let g;e[8]!==j?(g=s.jsx("span",{className:"font-medium",children:j}),e[8]=j,e[9]=g):g=e[9];let b;
164e[10]!==l||e[11]!==a.actionParams?(b=a.actionParams?.paramsCents!=null?s.jsx("span",{className:"font-medium bg-muted/80 py-0.5 px-1 rounded-sm",children:l?.shopCurrencyCode?jt(a.actionParams.paramsCents,{fromCents:!0,symbol:qn(l.shopCurrencyCode)}).format():null}):null,e[10]=l,e[11]=a.actionParams,e[12]=b):b=e[12];let y;e[13]!==x||e[14]!==r||e[15]!==h||e[16]!==a.action||e[17]!==a.actionParams?(y=a.actionParams?.paramsInt!=null?s.jsx("span",{className:"font-medium bg-muted/80 py-0.5 px-1 rounded-sm",children:a.action===us.OverrideReturnReasons?r(a.actionParams.paramsInt)?.label:a.action===us.OverrideReturnWindow?`${a.actionParams.paramsInt} days`:a.action===us.OverrideImageVerificationNumberOfImagesRequired?`${a.actionParams.paramsInt} images`:a.action===us.AssignShippingZone?h(a.actionParams.paramsInt)?.name:a.action===us.RequireAgreement?x(a.actionParams.paramsInt)?.title:a.actionParams.paramsInt}):null,e[13]=x,e[14]=r,e[15]=h,e[16]=a.action,e[17]=a.actionParams,e[18]=y):y=e[18];let v;e[19]!==a.actionParams?(v=a.actionParams?.paramsFloat!=null?s.jsxs("span",{className:"font-medium bg-muted/80 py-0.5 px-1 rounded-sm",children:[a.actionParams.paramsFloat,"%"]}):null,e[19]=a.actionParams,e[20]=v):v=e[20];let S;e[21]!==a.action||e[22]!==a.actionParams?(S=a.actionParams?.paramsStr?s.jsx("span",{className:"font-medium bg-muted/80 py-0.5 px-1 rounded-sm max-w-full wrap-break-word",children:Wi.get(a.action)?.(a.actionParams.paramsStr)||a.actionParams.paramsStr}):null,e[21]=a.action,e[22]=a.actionParams,e[23]=S):S=e[23];let C;e[24]!==a.actionParams?(C=a.actionParams?.paramsDatetime?s.jsx("span",{className:"font-medium bg-muted/80 py-0.5 px-1 rounded-sm",children:Rs(At(a.actionParams.paramsDatetime),"PP")}):null,e[24]=a.actionParams,e[25]=C):C=e[25];let R;return e[26]!==S||e[27]!==C||e[28]!==g||e[29]!==b||e[30]!==y||e[31]!==v?(R=s.jsxs(M,{as:"span",size:"xs",className:"inline-flex flex-wrap items-center gap-x-1 gap-y-0.5",children:[g,b,y,v,S,C]}),e[26]=S,e[27]=C,e[28]=g,e[29]=b,e[30]=y,e[31]=v,e[32]=R):R=e[32],R},du=t=>{const e=T.c(10),{ruleCalculation:n}=t;let l;e[0]!==n.ruleDefinitionSnapshot.conditions.andList?(l=n.ruleDefinitionSnapshot.conditions.andList||[],e[0]=n.ruleDefinitionSnapshot.conditions.andList,e[1]=l):l=e[1];const r=l;if(r.length===0){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(M,{size:"xs",tone:"muted",className:"p-2 italic",children:"Always applies"}),e[2]=d):d=e[2],d}let i;e[3]!==n.ruleDefinitionSnapshot.name?(i=s.jsx(M,{size:"sm",weight:"medium",className:"truncate",children:n.ruleDefinitionSnapshot.name}),e[3]=n.ruleDefinitionSnapshot.name,e[4]=i):i=e[4];let o;e[5]!==r?(o=r.map(uu),e[5]=r,e[6]=o):o=e[6];let a;return e[7]!==i||e[8]!==o?(a=s.jsxs("div",{className:"flex flex-col gap-1",children:[i,o]}),e[7]=i,e[8]=o,e[9]=a):a=e[9],a};function uu(t,e){return s.jsx("div",{children:s.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-2",children:[s.jsx(M,{size:"xs",weight:"semibold",className:"whitespace-nowrap flex flex-row items-center",children:e===0?"when":"and"}),s.jsx(M,{size:"xs",children:Qi[t.fieldName]}),s.jsx(M,{size:"xs",weight:"semibold",className:"whitespace-nowrap flex flex-row items-center",children:Hi(t.predicate,t.fieldName)}),s.jsx(M,{size:"xs",children:s.jsx(Zi,{fieldNameValue:t.fieldName,predicateValue:t.predicate,value:t.value})})]})},`${t.fieldName}-${String(e)}`)}const mu={[yn.Applied]:{label:"Applied",variant:"success"},[yn.Calculated]:{label:"Calculated",variant:"neutral"},[yn.Failed]:{label:"Failed",variant:"destructive"}},fu=()=>{const t=T.c(25),{returnGroup:e}=se(),n=String(e.id);let l;t[0]!==n?(l=[n],t[0]=n,t[1]=l):l=t[1];const r=!!e.id;let i;t[2]!==l||t[3]!==r?(i={queryKey:l,enabled:r},t[2]=l,t[3]=r,t[4]=i):i=t[4];let o;t[5]!==e.id?(o={returnGroupId:e.id},t[5]=e.id,t[6]=o):o=t[6];const a=wl(i,o),d=a.data?.ruleCalculations,c=a.isLoading;let u;t[7]!==c||t[8]!==d?.length?(u=c?null:s.jsxs(M,{as:"span",size:"base",weight:"regular",tone:"muted",children:["(",d?.length??0,")"]}),t[7]=c,t[8]=d?.length,t[9]=u):u=t[9];let m;t[10]!==u?(m=s.jsxs(ft,{className:"flex items-baseline gap-1",children:["Workflows",u]}),t[10]=u,t[11]=m):m=t[11];let f;t[12]!==c?(f=c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(Ps,{})}):null,t[12]=c,t[13]=f):f=t[13];let h;t[14]!==d?(h=d?.map(hu),t[14]=d,t[15]=h):h=t[15];let p;t[16]!==d?.length?(p=d?.length===0?s.jsx(Ss,{children:"No workflows have been applied."}):null,t[16]=d?.length,t[17]=p):p=t[17];let x;t[18]!==f||t[19]!==h||t[20]!==p?(x=s.jsxs("div",{className:"flex flex-col space-y-2",children:[f,h,p]}),t[18]=f,t[19]=h,t[20]=p,t[21]=x):x=t[21];let j;return t[22]!==x||t[23]!==m?(j=s.jsxs(Ze,{className:"gap-1 w-full",children:[m,x]}),t[22]=x,t[23]=m,t[24]=j):j=t[24],j};function hu(t){const{label:e,variant:n}=mu[t.status]??{label:t.status,variant:"secondary"};return s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs(nr,{children:[s.jsx(lr,{delay:200,closeDelay:100,className:"text-left cursor-default rounded-sm outline-offset-2 focus-visible:outline-2 focus-visible:outline-ring",children:s.jsx(M,{as:"div",size:"xs",tone:"muted",className:"flex flex-row items-center gap-x-1 transition-colors mt-0.5 truncate",children:s.jsx(cu,{ruleCalculation:t})})}),s.jsx(rr,{side:"top",align:"start",className:"w-auto p-2",children:s.jsx(du,{ruleCalculation:t})})]}),s.jsx(M,{as:"time",size:"xs",tone:"muted",className:"block tabular-nums mt-0.5",dateTime:t.updatedAt,children:Rs(At(t.updatedAt),"PPpp")})]}),s.jsx(it,{variant:n,className:"shrink-0 mt-0.5",children:e})]},t.id)}const pu=t=>{const e=T.c(208),{shipment:n,onSubmit:l,isLoading:r}=t,i=n.originAddress?.fullName||"",o=n.originAddress?.address1||"",a=n.originAddress?.address2||"",d=n.originAddress?.city||"",c=n.originAddress?.province||"",u=n.originAddress?.provinceCode||"",m=n.originAddress?.zip||"",f=n.originAddress?.country||"",h=n.originAddress?.countryCode||"",p=n.originAddress?.company||"",x=n.originAddress?.phone||"",j=n.originAddress?.email||"";let g;e[0]!==i||e[1]!==p||e[2]!==x||e[3]!==j||e[4]!==o||e[5]!==a||e[6]!==d||e[7]!==c||e[8]!==u||e[9]!==m||e[10]!==f||e[11]!==h?(g={fullName:i,address1:o,address2:a,city:d,province:c,provinceCode:u,z
164ip:m,country:f,countryCode:h,company:p,phone:x,email:j},e[0]=i,e[1]=p,e[2]=x,e[3]=j,e[4]=o,e[5]=a,e[6]=d,e[7]=c,e[8]=u,e[9]=m,e[10]=f,e[11]=h,e[12]=g):g=e[12];const b=n.parcel?.weight?.value||0,y=n.parcel?.weight?.unit;let v;e[13]!==b||e[14]!==y?(v={value:b,unit:y},e[13]=b,e[14]=y,e[15]=v):v=e[15];const S=n.parcel?.length||0,C=n.parcel?.width||0,R=n.parcel?.height||0;let w;e[16]!==v||e[17]!==S||e[18]!==C||e[19]!==R?(w={weight:v,length:S,width:C,height:R},e[16]=v,e[17]=S,e[18]=C,e[19]=R,e[20]=w):w=e[20];let _;e[21]!==n.id||e[22]!==g||e[23]!==w?(_={id:n.id,originAddress:g,parcel:w},e[21]=n.id,e[22]=g,e[23]=w,e[24]=_):_=e[24];const I=_,N=n.status===tt.Draft,A=r||!N;let P;e[25]!==I||e[26]!==A?(P={disabled:A,defaultValues:I},e[25]=I,e[26]=A,e[27]=P):P=e[27];const{handleSubmit:k,control:E,reset:z,formState:D}=Nt(P),{errors:$}=D;let O;e[28]!==l?(O=ae=>{l(ae)},e[28]=l,e[29]=O):O=e[29];const q=O;let B,V;e[30]!==I||e[31]!==z?(B=()=>{z(I)},V=[z,I],e[30]=I,e[31]=z,e[32]=B,e[33]=V):(B=e[32],V=e[33]),le.useEffect(B,V);let L;e[34]!==k||e[35]!==q?(L=k(q),e[34]=k,e[35]=q,e[36]=L):L=e[36];let K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(M,{as:"h3",size:"base",weight:"semibold",className:"flex-1 border-b pb-2",children:"Origin Address"}),e[37]=K):K=e[37];let W;e[38]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(De,{className:"mt-1.5",children:"Full name"}),e[38]=W):W=e[38];let te;e[39]===Symbol.for("react.memo_cache_sentinel")?(te={required:"Full name is required"},e[39]=te):te=e[39];let Z;e[40]!==$.originAddress?.fullName||e[41]!==N?(Z=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{className:"flex-1",children:[s.jsx(Pe,{...ce,placeholder:"John Doe",className:"!mt-0",disabled:!N}),$.originAddress?.fullName&&s.jsx(Ve,{children:$.originAddress?.fullName.message})]})},e[40]=$.originAddress?.fullName,e[41]=N,e[42]=Z):Z=e[42];let H;e[43]!==E||e[44]!==Z?(H=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[W,s.jsx(ze,{name:"originAddress.fullName",control:E,rules:te,render:Z})]}),e[43]=E,e[44]=Z,e[45]=H):H=e[45];let X;e[46]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(De,{className:"mt-1.5",children:"Company"}),e[46]=X):X=e[46];let Q;e[47]!==N?(Q=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsx("div",{children:s.jsx(Pe,{...ce,placeholder:"Acme Inc.",className:"!mt-0",disabled:!N})})},e[47]=N,e[48]=Q):Q=e[48];let Y;e[49]!==E||e[50]!==Q?(Y=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[X,s.jsx(ze,{name:"originAddress.company",control:E,render:Q})]}),e[49]=E,e[50]=Q,e[51]=Y):Y=e[51];let ne;e[52]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(De,{className:"mt-1.5",children:"Address 1"}),e[52]=ne):ne=e[52];let ee;e[53]===Symbol.for("react.memo_cache_sentinel")?(ee={required:"Address1 is required"},e[53]=ee):ee=e[53];let U;e[54]!==$.originAddress?.address1||e[55]!==N?(U=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{...ce,placeholder:"123 Main Street",className:"!mt-0",disabled:!N}),$.originAddress?.address1&&s.jsx(Ve,{children:$.originAddress?.address1.message})]})},e[54]=$.originAddress?.address1,e[55]=N,e[56]=U):U=e[56];let J;e[57]!==E||e[58]!==U?(J=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[ne,s.jsx(ze,{name:"originAddress.address1",control:E,rules:ee,render:U})]}),e[57]=E,e[58]=U,e[59]=J):J=e[59];let de;e[60]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(De,{className:"mt-1.5",children:"Address 2"}),e[60]=de):de=e[60];let oe;e[61]!==N?(oe=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsx("div",{children:s.jsx(Pe,{...ce,placeholder:"Apt 4B",className:"!mt-0",disabled:!N})})},e[61]=N,e[62]=oe):oe=e[62];let me;e[63]!==E||e[64]!==oe?(me=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[de,s.jsx(ze,{name:"originAddress.address2",control:E,render:oe})]}),e[63]=E,e[64]=oe,e[65]=me):me=e[65];let pe;e[66]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(De,{className:"mt-1.5",children:"City"}),e[66]=pe):pe=e[66];let Ae;e[67]===Symbol.for("react.memo_cache_sentinel")?(Ae={required:"City is required"},e[67]=Ae):Ae=e[67];let $e;e[68]!==$.originAddress?.city||e[69]!==N?($e=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{className:"flex-1",children:[s.jsx(Pe,{...ce,placeholder:"Los Angeles",className:"!mt-0",disabled:!N}),$.originAddress?.city&&s.jsx(Ve,{children:$.originAddress?.city.message})]})},e[68]=$.originAddress?.city,e[69]=N,e[70]=$e):$e=e[70];let ke;e[71]!==E||e[72]!==$e?(ke=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[pe,s.jsx(ze,{name:"originAddress.city",control:E,rules:Ae,render:$e})]}),e[71]=E,e[72]=$e,e[73]=ke):ke=e[73];let Te;e[74]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(De,{className:"mt-1.5",children:"Province / Code"}),e[74]=Te):Te=e[74];let Le;e[75]===Symbol.for("react.memo_cache_sentinel")?(Le={required:"Province is required"},e[75]=Le):Le=e[75];let at;e[76]!==$.originAddress?.province||e[77]!==N?(at=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{...ce,placeholder:"California",className:"!mt-0",disabled:!N}),$.originAddress?.province&&s.jsx(Ve,{children:$.originAddress?.province.message})]})},e[76]=$.originAddress?.province,e[77]=N,e[78]=at):at=e[78];let Ue;e[79]!==E||e[80]!==at?(Ue=s.jsx(ze,{name:"originAddress.province",control:E,rules:Le,render:at}),e[79]=E,e[80]=at,e[81]=Ue):Ue=e[81];let Ye;e[82]===Symbol.for("react.memo_cache_sentinel")?(Ye={required:"Province code is required"},e[82]=Ye):Ye=e[82];let qe;e[83]!==$.originAddress?.provinceCode||e[84]!==N?(qe=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{className:"flex-1",children:[s.jsx(Pe,{...ce,placeholder:"CA",className:"!mt-0",disabled:!N}),$.originAddress?.provinceCode&&s.jsx(Ve,{children:$.originAddress?.provinceCode.message})]})},e[83]=$.originAddress?.provinceCode,e[84]=N,e[85]=qe):qe=e[85];let ot;e[86]!==E||e[87]!==qe?(ot=s.jsx(ze,{name:"originAddress.provinceCode",control:E,rules:Ye,render:qe}),e[86]=E,e[87]=qe,e[88]=ot):ot=e[88];let Be;e[89]!==Ue||e[90]!==ot?(Be=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[Te,s.jsxs("div",{className:"flex flex-row flex-1 gap-4",children:[Ue,ot]})]}),e[89]=Ue,e[90]=ot,e[91]=Be):Be=e[91];let Je;e[92]===Symbol.for("react.memo_cache_sentinel")?(Je=s.jsx(De,{className:"mt-1.5",children:"Country / Code"}),e[92]=Je):Je=e[92];let Xe;e[93]===Symbol.for("react.memo_cache_sentinel")?(Xe={required:"Country is required"},e[93]=Xe):Xe=e[93];let Ke;e[94]!==$.originAddress?.country||e[95]!==N?(Ke=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{...ce,placeholder:"United States",className:"!mt-0",disabled:!N}),$.originAddress?.country&&s.jsx(Ve,{children:$.originAddress?.country.message})]})},e[94]=$.originAddress?.country,e[95]=N,e[96]=Ke):Ke=e[96];let et;e[97]!==E||e[98]!==Ke?(et=s.jsx(ze,{name:"originAddress.country",control:E,rules:Xe,render:Ke}),e[97]=E,e[98]=Ke,e[99]=et):et=e[99];let _e;e[100]===Symbol.for("react.memo_cache_sentinel")?(_e={required:"Country code is required"},e[100]=_e):_e=e[100];let zt;e[101]!==$.originAddress?.countryCode||e[102]!==N?(zt=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{className:"flex-1",children:[s.jsx(Pe,{...ce,placeholder:"US",className:"!mt-0",disabled:!N}),$.originAddress?.countryCode&&s.jsx(Ve,{children:$.originAddress?.countryCode.message})]})},e[101]=$.originAddress?.countryCode,e[102]=N,e[103]=zt):zt=e[103];let Mt;e[104]!==E||e[105]!==zt?(Mt=s.jsx(ze,{name:"originAddress.countryCode",control:E,rules:_e,render:zt}),e[104]=E,e[105]=zt,e[106]=Mt):Mt=e[106];let Ft;e[107]!==et||e[108]!==Mt?(Ft=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4 items-center",children:[Je,s.jsxs("div",{className:"flex flex-row flex-1 gap-4",children:[et,Mt]})]}),e[107]=et,e[108]=Mt,e[109]=Ft):Ft=e[109];let Vs;e[110]===Symbol.for("react.memo_cache_sentinel")?(Vs=s.jsx(De,{className:"mt-1.5",children:"Zip"}),e[110]=Vs):Vs=e[110];let Us;e[111]===Symbol.for("react.memo_cache_sentinel")?(Us={required:"Zip is required"},e[111]=Us):Us=e[111];let Dt;e[112]!==$.originAddress?.zip||e[113]!==N?(Dt=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{...ce,placeholder:"90001",className:"!mt-0",disabled:!N}),$.originAddress?.zip&&s.jsx(Ve,{children:$.originAddress?.zip.message})]})},e[112]=$.originAddress?.zip,e[113]=N,e[114]=Dt):Dt=e[114];let Ot;e[115]!==E||e[116]!==Dt?(Ot=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[Vs,s.jsx(ze,{name:"originAddress.zip",control:E,rules:Us,render:Dt})]}),e[115]=E,e[116]=Dt,e[117]=Ot):Ot=e[117];let qs;e[118]===Symbol.for("react.memo_cache_sentinel")?(qs=s.jsx(De,{className:"mt-1.5",children:"Email"}),e[118]=qs):qs=e[118];let Bs;e[119]===Symbol.for("react.memo_cache_sentinel")?(Bs={required:"Email is required"},e[119]=Bs):Bs=e[119];let Lt;e[120]!==$.originAddress?.email||e[121]!==N?(Lt=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{className:"flex-1",children:[s.jsx(Pe,{...ce,placeholder:"[email protected]",className:"!mt-0",type:"email",disabled:!N}),$.originAddress?.email&&s.jsx(Ve,{children:$.originAddress?.email.message})]})},e[120]=$.originAddress?.email,e[121]=N,e[122]=Lt):Lt=e[122];let Vt;e[123]!==E||e[124]!==Lt?(Vt=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[qs,s.jsx(ze,{name:"originAddress.email",control:E,rules:Bs,render:Lt})]}),e[123]=E,e[124]=Lt,e[125]=Vt):Vt=e[125];let Ks;e[126]===Symbol.for("react.memo_cache_sentinel")?(Ks=s.jsx(De,{className:"mt-1.5",children:"Phone"}),e[126]=Ks):Ks=e[126];let Ws;e[127]===Symbol.for("react.memo_cache_sentinel")?(Ws={required:"Phone is required"},e[127]=Ws):Ws=e[127];let Ut;e[128]!==$.originAddress?.phone||e[129]!==N?(Ut=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{className:"flex-1",children:[s.jsx(Pe,{...ce,placeholder:"(555) 123-4567",className:"!mt-0",disabled:!N}),$.originAddress?.phone&&s.jsx(Ve,{children:$.originAddress?.phone.message})]})},e[128]=$.originAddress?.phone,e[129]=N,e[130]=Ut):Ut=e[130];let qt;e[131]!==E||e[132]!==Ut?(qt=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[Ks,s.jsx(ze,{name:"originAddress.phone",control:E,rules:Ws,render:Ut})]}),e[131]=E,e[132]=Ut,e[133]=qt):qt=e[133];let Bt;e[134]!==H||e[135]!==Y||e[136]!==J||e[137]!==me||e[138]!==ke||e[139]!==Be||e[140]!==Ft||e[141]!==Ot||e[142]!==Vt||e[143]!==qt?(Bt=s.jsx("div",{className:"space-y-4",children:s.jsxs(sl,{className:"gap-3",children:[K,H,Y,J,me,ke,Be,Ft,Ot,Vt,qt]})}),e[134]=H,e[135]=Y,e[136]=J,e[137]=me,e[138]=ke,e[139]=Be,e[140]=Ft,e[141]=Ot,e[142]=Vt,e[143]=qt,e[144]=Bt):Bt=e[144];let Qs;e[145]===Symbol.for("react.memo_cache_sentinel")?(Qs=s.jsx(M,{as:"h3",size:"base",weight:"semibold",className:"flex-1 border-b pb-2",children:"Destination Address"}),e[145]=Qs):Qs=e[145];const gn=n.destinationAddress?.formattedAddress;let Kt;e[146]!==gn?(Kt=s.jsxs("div",{children:[Qs,s.jsx(Yi,{className:"pt-2",children:gn})]}),e[146]=gn,e[147]=Kt):Kt=e[147];let Hs;e[148]===Symbol.for("react.memo_cache_sentinel")?(Hs=s.jsx(M,{as:"h3",size:"base",weight:"semibold",className:"flex-1 border-b pb-2",children:"Parcel Details"}),e[148]=Hs):Hs=e[148];let Zs;e[149]===Symbol.for("react.memo_cache_sentinel")?(Zs=s.jsx(De,{className:"mt-1.5",children:"Weight"}),e[149]=Zs):Zs=e[149];let Ys;e[150]===Symbol.for("react.memo_cache_sentinel")?(Ys={required:"Weight is required"},e[150]=Ys):Ys=e[150];let Wt;e[151]!==$.parcel?.weight?.value||e[152]!==N?(Wt=ae=>{const{field:ue}=ae,{onChange:ce,..._t}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{..._t,placeholder:"10",type:"number",className:"!mt-0",disabled:!N,onChange:Rt=>ce(Number(Rt.target.value))}),$.parcel?.weight?.value&&s.jsx(Ve,{children:$.parcel?.weight?.value.message})]})},e[151]=$.parcel?.weight?.value,e[152]=N,e[153]=Wt):Wt=e[153];let Qt;e[154]!==E||e[155]!==Wt?(Qt=s.jsx(ze,{name:"parcel.weight.value",control:E,rules:Ys,render:Wt}),e[154]=E,e[155]=Wt,e[156]=Qt):Qt=e[156];let Js;e[157]===Symbol.for("react.memo_cache_sentinel")?(Js={required:"Weight unit is required"},e[157]=Js):Js=e[157];let Ht;e[158]!==$.parcel?.weight?.unit||e[159]!==N?(Ht=ae=>{const{field:ue}=ae,{...ce}=ue;return s.jsxs("div",{children:[s.jsxs(Es,{value:ce.value,onValueChange:ce.onChange,disabled:!N,children:[s.jsx(As,{className:mt("w-full",$.parcel?.weight?.unit&&"border-red-300 focus:ring-red-500"),children:s.jsx($s,{})}),s.jsx(ks,{children:Object.values(Ir).map(xu)})]}),$.parcel?.weight?.unit&&s.jsx(Ve,{children:$.parcel?.weight?.unit.message})]})},e[158]=$.parcel?.weight?.unit,e[159]=N,e[160]=Ht):Ht=e[160];let Zt;e[161]!==E||e[162]!==Ht?(Zt=s.jsx(ze,{name:"parcel.weight.unit",control:E,rules:Js,render:Ht}),e[161]=E,e[162]=Ht,e[163]=Zt):Zt=e[163];let Yt;e[164]!==Qt||e[165]!==Zt?(Yt=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[Zs,s.jsxs("div",{className:"flex flex-row flex-1 gap-4",children:[Qt,Zt]})]}),e[164]=Qt,e[165]=Zt,e[166]=Yt):Yt=e[166];let Xs;e[167]===Symbol.for("react.memo_cache_sentinel")?(Xs=s.jsx(De,{className:"mt-1.5",children:"Height"}),e[167]=Xs):Xs=e[167];let Jt;e[168]!==N?(Jt=ae=>{const{field:ue}=ae,{onChange:ce,..._t}=ue;return s.jsx("div",{children:s.jsx(Pe,{..._t,type:"number",placeholder:"10",className:"!mt-0",disabled:!N,onChange:Rt=>ce(Number(Rt.target.value))})})},e[168]=N,e[169]=Jt):Jt=e[169];let Xt;e[170]!==E||e[171]!==Jt?(Xt=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[Xs,s.jsx(ze,{name:"parcel.height",control:E,render:Jt})]}),e[170]=E,e[171]=Jt,e[172]=Xt):Xt=e[172];let en;e[173]===Symbol.for("react.memo_cache_sentinel")?(en=s.jsx(De,{className:"mt-1.5",children:"Width"}),e[173]=en):en=e[173];let tn;e[174]===Symbol.for("react.memo_cache_sentinel")?(tn={required:"Width is required"},e[174]=tn):tn=e[174];let es;e[175]!==$.parcel?.width||e[176]!==N?(es=ae=>{const{field:ue}=ae,{onChange:ce,..._t}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{..._t,type:"number",placeholder:"10",className:"!mt-0",disabled:!N,onChange:Rt=>ce(Number(Rt.target.value))}),$.parcel?.width&&s.jsx(Ve,{children:$.parcel?.width.message})]})},e[175]=$.parcel?.width,e[176]=N,e[177]=es):es=e[177];let ts;e[178]!==E||e[179]!==es?(ts=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[en,s.jsx(ze,{name:"parcel.width",control:E,rules:tn,render:es})]}),e[178]=E,e[179]=es,e[180]=ts):ts=e[180];let sn;e[181]===Symbol.for("react.memo_cache_sentinel")?(sn=s.jsx(De,{className:"mt-1.5",children:"Length"}),e[181]=sn):sn=e[181];let nn;e[182]===Symbol.for("react.memo_cache_sentinel")?(nn={required:"Length is required"},e[182]=nn):nn=e[182];let ss;e[183]!==$.parcel?.length||e[184]!==N?(ss=ae=>{const{field:ue}=ae,{onChange:ce,..._t}=ue;return s.jsxs("div",{children:[s.jsx(Pe,{..._t,type:"number",placeholder:"10",className:"!mt-0",disabled:!N,onChange:Rt=>ce(Number(Rt.target.value))}),$.parcel?.length&&s.jsx(Ve,{children:$.parcel?.length.message})]})},e[183]=$.parcel?.length,e[184]=N,e[185]=ss):ss=e[185];let ns;e[186]!==E||e[187]!==ss?(ns=s.jsxs(xe,{className:"grid grid-cols-[140px_auto] gap-4",children:[sn,s.jsx(ze,{name:"parcel.length",control:E,rules:nn,render:ss})]}),e[186]=E,e[187]=ss,e[188]=ns):ns=e[188];let ls;e[189]!==Yt||e[190]!==Xt||e[191]!==ts||e[192]!==ns?(ls=s.jsxs(sl,{className:"gap-3",children:[Hs,Yt,Xt,ts,ns]}),e[189]=Yt,e[190]=Xt,e[191]=ts,e[192]=ns,e[193]=ls):ls=e[193];let rs;e[194]!==ls||e[195]!==Kt?(rs=s.jsxs("div",{className:"space-y-4",children:[Kt,ls]}),e[194]=ls,e[195]=Kt,e[196]=rs):rs=e[196];let is;e[197]!==rs||e[198]!==Bt?(is=s.jsx(Bn,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[Bt,rs]})}),e[197]=rs,e[198]=Bt,e[199]=is):is=e[199];const jn=r||!N;let as;e[200]!==jn?(as=s.jsx(Ii,{className:"justify-end",children:s.jsx(F,{type:"submit",disabled:jn,children:"Generate"})}),e[200]=jn,e[201]=as):as=e[201];let os;e[202]!==is||e[203]!==as?(os=s.jsxs(zs,{className:"shadow-md pt-6",children:[is,as]}),e[202]=is,e[203]=as,e[204]=os):os=e[204];let ln;return e[205]!==os||e[206]!==L?(ln=s.jsx("form",{onSubmit:L,children:os}),e[205]=os,e[206]=L,e[207]=ln):ln=e[207],ln};function xu(t){return s.jsx(Gs,{value:t,children:t},t)}const gu=t=>{const e=T.c(34),{open:n,onClose:l}=t,{returnGroup:r,refetch:i}=se();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[a,d]=le.useState(o);let
164 c;e[1]!==i?(c=()=>{i(),G.error("Failed to generate shipping label.")},e[1]=i,e[2]=c):c=e[2];let u;e[3]!==l||e[4]!==i?(u=w=>{const{quickCreateShippingLabel:_}=w;i(),_.userErrors?.length?d(_.userErrors.map(bu)):(G.success("Shipping label generated successfully."),l())},e[3]=l,e[4]=i,e[5]=u):u=e[5];let m;e[6]!==c||e[7]!==u?(m={onError:c,onSuccess:u},e[6]=c,e[7]=u,e[8]=m):m=e[8];const{mutate:f,isPending:h}=ju(m);let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(ye,{children:"Generate Shipping Label"}),e[9]=p):p=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsxs(Oe,{children:["Review and update shipping details for each shipment before generating the label. ",s.jsx("br",{}),"You can modify dimensions, weight, and address information as needed."]}),e[10]=x):x=e[10];let j;e[11]!==a?(j=a.length>0&&s.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-4",children:[s.jsx(M,{size:"lg",weight:"bold",tone:"destructive",children:"Error generating shipping label"}),s.jsx(M,{as:"div",size:"sm",tone:"destructive",className:"mt-2",children:s.jsx("ul",{className:"list-disc ml-4",children:a.map(yu)})})]}),e[11]=a,e[12]=j):j=e[12];let g;e[13]!==r.shipments.length?(g=s.jsxs(Ji,{children:["Shipments (",r.shipments.length,")"]}),e[13]=r.shipments.length,e[14]=g):g=e[14];let b;e[15]!==r.shipments?(b=r.shipments.map(vu),e[15]=r.shipments,e[16]=b):b=e[16];let y;e[17]!==b?(y=s.jsx(Ci,{children:b}),e[17]=b,e[18]=y):y=e[18];let v;e[19]!==h||e[20]!==f||e[21]!==r.shipments?(v=h?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(Ps,{})}):r.shipments.map(w=>s.jsx(Si,{value:w.id.toString(),children:s.jsx(pu,{shipment:w,onSubmit:_=>{f({quickCreateShippingLabelInput:{..._,parcel:{height:_.parcel.height,length:_.parcel.length,weight:_.parcel.weight.value,weightUnit:_.parcel.weight.unit,width:_.parcel.width}}})},isLoading:h})},w.id)),e[19]=h,e[20]=f,e[21]=r.shipments,e[22]=v):v=e[22];let S;e[23]!==y||e[24]!==v?(S=s.jsx("div",{className:"flex flex-col gap-4",children:s.jsxs(_i,{defaultValue:"Shipment",className:"w-full",children:[y,v]})}),e[23]=y,e[24]=v,e[25]=S):S=e[25];let C;e[26]!==S||e[27]!==j||e[28]!==g?(C=s.jsxs(ve,{className:"!min-w-[1000px]",children:[p,x,j,g,S]}),e[26]=S,e[27]=j,e[28]=g,e[29]=C):C=e[29];let R;return e[30]!==l||e[31]!==n||e[32]!==C?(R=s.jsx(je,{open:n,onOpenChange:l,children:C}),e[30]=l,e[31]=n,e[32]=C,e[33]=R):R=e[33],R},ju=Re(he` 165 mutation QuickCreateShippingLabel( 166 $quickCreateShippingLabelInput: QuickCreateShippingLabelInput! 167 ) { 168 quickCreateShippingLabel(quickCreateShippingLabelInput: $quickCreateShippingLabelInput) { 169 id 170 userErrors { 171 message 172 } 173 } 174 } 175`);function bu(t){return t.message}function yu(t,e){return s.jsx("li",{children:t},String(e))}function vu(t,e){return s.jsxs(Ni,{value:t.id.toString(),children:["Shipment ",e+1]},t.id)}const Su=Re(he` 176 mutation RegenerateShipment($regenerateShipmentInput: RegenerateShipmentInput!) { 177 regenerateShipment(regenerateShipmentInput: $regenerateShipmentInput) { 178 success 179 userErrors { 180 message 181 } 182 } 183 } 184`),Nu=Re(he` 185 mutation SubmitDelivered($submitDeliveredInput: SubmitDeliveredInput!) { 186 submitDelivered(submitDeliveredInput: $submitDeliveredInput) { 187 success 188 userErrors { 189 message 190 } 191 } 192 } 193`),Cu=Re(he` 194 mutation SubmitInspectionComplete( 195 $submitInspectionCompleteInput: SubmitInspectionCompleteInput! 196 ) { 197 submitInspectionComplete(submitInspectionCompleteInput: $submitInspectionCompleteInput) { 198 success 199 userErrors { 200 message 201 } 202 } 203 } 204`),_u=Re(he` 205 mutation SubmitShipped($submitShippedInput: SubmitShippedInput!) { 206 submitShipped(submitShippedInput: $submitShippedInput) { 207 success 208 userErrors { 209 message 210 } 211 } 212 } 213`),Ru=Re(he` 214 mutation UpdateTrackingInfo($updateTrackingInfoInput: UpdateTrackingInfoInput!) { 215 updateTrackingInfo(updateTrackingInfoInput: $updateTrackingInfoInput) { 216 success 217 userErrors { 218 message 219 } 220 } 221 } 222`),wu=t=>{const e=T.c(142),{shipment:n}=t,{refetch:l,returnGroup:r}=se(),i=Ee();let o;e[0]!==i||e[1]!==l?(o={onSuccess:_e=>{if(G.dismiss(),_e.submitShipped.userErrors?.length){G.error(_e.submitShipped.userErrors[0].message);return}i.close("triggerShipped"),G.success("Shipment triggered as shipped."),l()},onError:$u},e[0]=i,e[1]=l,e[2]=o):o=e[2];const a=_u(o);let d;e[3]!==i||e[4]!==l?(d={onSuccess:_e=>{if(G.dismiss(),_e.submitDelivered.userErrors?.length){G.error(_e.submitDelivered.userErrors[0].message);return}i.close("triggerDelivered"),G.success("Shipment triggered as delivered."),l()},onError:ku},e[3]=i,e[4]=l,e[5]=d):d=e[5];const c=Nu(d);let u;e[6]!==i||e[7]!==l?(u={onSuccess:_e=>{if(G.dismiss(),_e.submitInspectionComplete.userErrors?.length){G.error(_e.submitInspectionComplete.userErrors[0].message);return}i.close("triggerInspectionComplete"),G.success("Shipment triggered as inspection complete."),l()},onError:Pu},e[6]=i,e[7]=l,e[8]=u):u=e[8];const m=Cu(u);let f;e[9]!==i||e[10]!==l?(f=_e=>
222{if(G.dismiss(),_e.regenerateShipment.userErrors.length>0){G.error(_e.regenerateShipment.userErrors[0].message),l();return}i.close("regenerateShippingLabel"),G.success("Shipment label regenerated."),l()},e[9]=i,e[10]=l,e[11]=f):f=e[11];let h;e[12]!==l?(h=()=>{G.error("Failed to regenerate shipping label."),l()},e[12]=l,e[13]=h):h=e[13];let p;e[14]!==f||e[15]!==h?(p={onSuccess:f,onError:h},e[14]=f,e[15]=h,e[16]=p):p=e[16];const x=Su(p);let j;e[17]!==i||e[18]!==l?(j={onSuccess:_e=>{if(G.dismiss(),_e.updateTrackingInfo.userErrors?.length){G.error(_e.updateTrackingInfo.userErrors[0].message);return}i.close("updateTrackingInfo"),G.success("Tracking info updated."),l()},onError:Tu},e[17]=i,e[18]=l,e[19]=j):j=e[19];const g=Ru(j);let b;e[20]!==r.status||e[21]!==n.isRmaReviewed||e[22]!==n.status?(b=new Set,n.status===tt.Created&&(b.add("Trigger Shipped"),b.add("Regenerate Shipping Label"),r.status===Fe.Open&&b.add("Update Tracking Info")),n.status===tt.InTransit&&b.add("Trigger Delivered"),n.status===tt.Delivered&&!n.isRmaReviewed&&b.add("Trigger Inspection Complete"),e[20]=r.status,e[21]=n.isRmaReviewed,e[22]=n.status,e[23]=b):b=e[23];const y=b,v=n.carrier?n.carrier:"Package",S=n.status===tt.Canceled?"destructive":"secondary";let C;e[24]!==n.status||e[25]!==S?(C=s.jsx(it,{variant:S,children:n.status}),e[24]=n.status,e[25]=S,e[26]=C):C=e[26];let R;e[27]!==C||e[28]!==v?(R=s.jsxs(be,{children:[v,C]}),e[27]=C,e[28]=v,e[29]=R):R=e[29];let w;e[30]!==n.returnNames?(w=n.returnNames.map(Gu),e[30]=n.returnNames,e[31]=w):w=e[31];let _;e[32]!==w?(_=s.jsx("div",{className:"flex flex-col space-y-0.5",children:w}),e[32]=w,e[33]=_):_=e[33];let I;e[34]!==n.trackingCode||e[35]!==n.trackingUrl?(I=n.trackingUrl&&s.jsxs(Sn,{href:n.trackingUrl,children:["View Tracking ",n.trackingCode&&n.trackingCode," ",s.jsx(fs,{className:"inline size-4"})]}),e[34]=n.trackingCode,e[35]=n.trackingUrl,e[36]=I):I=e[36];let N;e[37]!==n.labelUrl?(N=n.labelUrl?s.jsxs(Sn,{href:n.labelUrl,children:["View Label ",s.jsx(fs,{className:"inline size-4"})]}):null,e[37]=n.labelUrl,e[38]=N):N=e[38];let A;e[39]!==n.qrCode?(A=n.qrCode?s.jsxs(Sn,{href:n.qrCode,children:["View QR Code ",s.jsx(fs,{className:"inline size-4"})]}):null,e[39]=n.qrCode,e[40]=A):A=e[40];let P;e[41]!==I||e[42]!==N||e[43]!==A?(P=s.jsxs("div",{className:"flex flex-col justify-start items-start",children:[I,N,A]}),e[41]=I,e[42]=N,e[43]=A,e[44]=P):P=e[44];let k;e[45]!==n.createdAt?(k=s.jsx($t,{prefix:"Created",timestamp:n.createdAt}),e[45]=n.createdAt,e[46]=k):k=e[46];let E;e[47]!==_||e[48]!==P||e[49]!==k?(E=s.jsxs(we,{children:[_,P,k]}),e[47]=_,e[48]=P,e[49]=k,e[50]=E):E=e[50];let z;e[51]!==R||e[52]!==E?(z=s.jsxs(Se,{children:[R,E]}),e[51]=R,e[52]=E,e[53]=z):z=e[53];let D;e[54]!==y||e[55]!==i?(D=y.size>0?s.jsxs(yt,{children:[s.jsx(vt,{render:zu}),s.jsxs(St,{align:"end",className:"w-auto min-w-48",children:[y.has("Trigger Shipped")&&s.jsx(Me,{onClick:()=>i.open("triggerShipped"),children:"Trigger Shipped"}),y.has("Regenerate Shipping Label")&&s.jsx(Me,{onClick:()=>i.open("regenerateShippingLabel"),children:"Regenerate Shipping Label"}),y.has("Update Tracking Info")&&s.jsx(Me,{onClick:()=>i.open("updateTrackingInfo"),children:"Update Tracking Info"}),y.has("Trigger Delivered")&&s.jsx(Me,{onClick:()=>i.open("triggerDelivered"),children:"Trigger Delivered"}),y.has("Trigger Inspection Complete")&&s.jsx(Me,{onClick:()=>i.open("triggerInspectionComplete"),children:"Trigger Inspection Complete"})]})]}):null,e[54]=y,e[55]=i,e[56]=D):D=e[56];let $;e[57]!==z||e[58]!==D?($=s.jsxs("div",{className:"flex flex-row items-start justify-between",children:[z,D]}),e[57]=z,e[58]=D,e[59]=$):$=e[59];let O;e[60]!==i?(O=i.getDialogProps("triggerShipped"),e[60]=i,e[61]=O):O=e[61];let q,B;e[62]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Ie,{children:s.jsx(ye,{children:"Trigger Shipped"})}),B=s.jsx(M,{size:"sm",className:"py-4",children:"This action cannot be undone. Are you sure you want to trigger this shipment as shipped?"}),e[62]=q,e[63]=B):(q=e[62],B=e[63]);let V;e[64]!==n.id||e[65]!==a?(V=()=>a.mutate({submitShippedInput:{id:n.id}}),e[64]=n.id,e[65]=a,e[66]=V):V=e[66];let L;e[67]!==a.isPending||e[68]!==V?(L=s.jsxs(ve,{children:[q,B,s.jsx(Ne,{children:s.jsx(F,{disabled:a.isPending,onClick:V,children:"Confirm"})})]}),e[67]=a.isPending,e[68]=V,e[69]=L):L=e[69];let K;e[70]!==O||e[71]!==L?(K=s.jsx(je,{...O,children:L}),e[70]=O,e[71]=L,e[72]=K):K=e[72];let W;e[73]!==i?(W=i.getDialogProps("regenerateShippingLabel"),e[73]=i,e[74]=W):W=e[74];let te,Z;e[75]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Ie,{children:s.jsx(ye,{children:"Regenerate Shipping Label"})}),Z=s.jsx(M,{size:"sm",className:"py-4",children:"This action cannot be undone. Are you sure you want to regenerate the shipping label for this shipment?"}),e[75]=te,e[76]=Z):(te=e[75],Z=e[76]);let H;e[77]!==n.id||e[78]!==x?(H=()=>x.mutate({regenerateShipmentInput:{id:n.id}}),e[77]=n.id,e[78]=x,e[79]=H):H=e[79];let X;e[80]!==x.isPending||e[81]!==H?(X=s.jsxs(ve,{children:[te,Z,s.jsx(Ne,{children:s.jsx(F,{disabled:x.isPending,onClick:H,children:"Confirm"})})]}),e[80]=x.isPending,e[81]=H,e[82]=X):X=e[82];let Q;e[83]!==W||e[84]!==X?(Q=s.jsx(je,{...W,children:X}),e[83]=W,e[84]=X,e[85]=Q):Q=e[85];let Y;e[86]!==i?(Y=i.getDialogProps("triggerDelivered"),e[86]=i,e[87]=Y):Y=e[87];let ne,ee;e[88]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(Ie,{children:s.jsx(ye,{children:"Trigger Delivered"})}),ee=s.jsx(M,{size:"sm",className:"py-4",children:"This action cannot be undone. Are you sure you want to trigger this shipment as delivered?"}),e[88]=ne,e[89]=ee):(ne=e[88],ee=e[89]);let U;e[90]!==n.id||e[91]!==c?(U=()=>c.mutate({submitDeliveredInput:{id:n.id}}),e[90]=n.id,e[91]=c,e[92]=U):U=e[92];let J;e[93]!==c.isPending||e[94]!==U?(J=s.jsxs(ve,{children:[ne,ee,s.jsx(Ne,{children:s.jsx(F,{disabled:c.isPending,onClick:U,children:"Confirm"})})]}),e[93]=c.isPending,e[94]=U,e[95]=J):J=e[95];let de;e[96]!==Y||e[97]!==J?(de=s.jsx(je,{...Y,children:J}),e[96]=Y,e[97]=J,e[98]=de):de=e[98];let oe;e[99]!==i?(oe=i.getDialogProps("triggerInspectionComplete"),e[99]=i,e[100]=oe):oe=e[100];let me,pe;e[101]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Ie,{children:s.jsx(ye,{children:"Trigger Inspection Complete"})}),pe=s.jsx(M,{size:"sm",className:"py-4",children:"This action cannot be undone. Are you sure you want to trigger this shipment as inspection complete?"}),e[101]=me,e[102]=pe):(me=e[101],pe=e[102]);let Ae;e[103]!==n.id||e[104]!==m?(Ae=()=>m.mutate({submitInspectionCompleteInput:{id:n.id}}),e[103]=n.id,e[104]=m,e[105]=Ae):Ae=e[105];let $e;e[106]!==m.isPending||e[107]!==Ae?($e=s.jsxs(ve,{children:[me,pe,s.jsx(Ne,{children:s.jsx(F,{disabled:m.isPending,onClick:Ae,children:"Confirm"})})]}),e[106]=m.isPending,e[107]=Ae,e[108]=$e):$e=e[108];let ke;e[109]!==oe||e[110]!==$e?(ke=s.jsx(je,{...oe,children:$e}),e[109]=oe,e[110]=$e,e[111]=ke):ke=e[111];let Te;e[112]!==i?(Te=i.getDialogProps("updateTrackingInfo"),e[112]=i,e[113]=Te):Te=e[113];let Le;e[114]===Symbol.for("react.memo_cache_sentinel")?(Le=s.jsx(Ie,{children:s.jsx(ye,{children:"Update Tracking Info"})}),e[114]=Le):Le=e[114];const at=`update-tracking-info-form-${n.id}`;let Ue;e[115]!==n.id||e[116]!==g?(Ue=_e=>
222{g.mutate({updateTrackingInfoInput:{shipmentId:n.id,trackingCode:_e.trackingCode,carrier:_e.carrier}})},e[115]=n.id,e[116]=g,e[117]=Ue):Ue=e[117];let Ye;e[118]!==at||e[119]!==Ue?(Ye=s.jsx("div",{className:"mb-4 flex flex-col",children:s.jsx(Iu,{formId:at,onSubmit:Ue})}),e[118]=at,e[119]=Ue,e[120]=Ye):Ye=e[120];let qe;e[121]!==i?(qe=s.jsx(F,{type:"button",variant:"outline",onClick:()=>i.close("updateTrackingInfo"),children:"Cancel"}),e[121]=i,e[122]=qe):qe=e[122];const ot=`update-tracking-info-form-${n.id}`;let Be;e[123]!==ot||e[124]!==g.isPending?(Be=s.jsx(F,{type:"submit",form:ot,disabled:g.isPending,children:"Confirm"}),e[123]=ot,e[124]=g.isPending,e[125]=Be):Be=e[125];let Je;e[126]!==qe||e[127]!==Be?(Je=s.jsxs(Ne,{children:[qe,Be]}),e[126]=qe,e[127]=Be,e[128]=Je):Je=e[128];let Xe;e[129]!==Ye||e[130]!==Je?(Xe=s.jsxs(ve,{children:[Le,Ye,Je]}),e[129]=Ye,e[130]=Je,e[131]=Xe):Xe=e[131];let Ke;e[132]!==Te||e[133]!==Xe?(Ke=s.jsx(je,{...Te,children:Xe}),e[132]=Te,e[133]=Xe,e[134]=Ke):Ke=e[134];let et;return e[135]!==$||e[136]!==K||e[137]!==Q||e[138]!==de||e[139]!==ke||e[140]!==Ke?(et=s.jsxs("div",{children:[$,K,Q,de,ke,Ke]}),e[135]=$,e[136]=K,e[137]=Q,e[138]=de,e[139]=ke,e[140]=Ke,e[141]=et):et=e[141],et};function Iu(t){const e=T.c(16),{formId:n,onSubmit:l}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={defaultValues:{trackingCode:"",carrier:""}},e[0]=r):r=e[0];const i=Nt(r);let o;e[1]!==i||e[2]!==l?(o=i.handleSubmit(l),e[1]=i,e[2]=l,e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a={required:"Tracking code is required"},e[4]=a):a=e[4];let d,c;e[5]!==i.control?(d=s.jsx(lt,{control:i.control,name:"trackingCode",rules:a,render:Au}),c=s.jsx(lt,{control:i.control,name:"carrier",render:Eu}),e[5]=i.control,e[6]=d,e[7]=c):(d=e[6],c=e[7]);let u;e[8]!==n||e[9]!==o||e[10]!==d||e[11]!==c?(u=s.jsxs("form",{className:"flex flex-col gap-4",id:n,onSubmit:o,children:[d,c]}),e[8]=n,e[9]=o,e[10]=d,e[11]=c,e[12]=u):u=e[12];let m;return e[13]!==i||e[14]!==u?(m=s.jsx(kt,{...i,children:u}),e[13]=i,e[14]=u,e[15]=m):m=e[15],m}function Eu(t){const{field:e}=t;return s.jsxs(rt,{children:[s.jsx(Ts,{children:"Carrier (Optional)"}),s.jsx(pt,{render:s.jsx(Pe,{...e})})]})}function Au(t){const{field:e}=t;return s.jsxs(rt,{children:[s.jsx(Ts,{children:"Tracking Code"}),s.jsx(pt,{render:s.jsx(Pe,{...e})}),s.jsx(bt,{})]})}function $u(){G.error("Failed to trigger shipment as shipped.")}function ku(){G.error("Failed to trigger shipment as delivered.")}function Pu(){G.error("Failed to trigger shipment as inspection complete.")}function Tu(){G.error("Failed to update tracking info.")}function Gu(t,e){return s.jsx("div",{children:t},e)}function zu(t){const{...e}=t;return s.jsx(F,{variant:"ghost",size:"icon",...e,children:s.jsx(Ct,{className:"h-4 w-4"})})}const Mu=()=>{const t=T.c(36),e=Ee(),{returnGroup:n}=se();let l,r,i,o,a,d;if(t[0]!==e||t[1]!==n){d=Ca(n.shipments);let x;t[8]!==n.shipments?(x=_a(n.shipments),t[8]=n.shipments,t[9]=x):x=t[9];const j=x;let g;t[10]!==j.length||t[11]!==n.shipments.length?(g=new Set,j.length===n.shipments.length&&g.add("generate-shipping-label"),t[10]=j.length,t[11]=n.shipments.length,t[12]=g):g=t[12];const b=g,y=n.status===Fe.InReview;l=Ze,o="gap-1";let v;t[13]!==b||t[14]!==y||t[15]!==e?(v=b.size>0?s.jsxs(yt,{children:[s.jsx(vt,{render:Fu}),s.jsx(St,{align:"end",className:"w-fit",children:b.has("generate-shipping-label")&&(y?s.jsxs(ir,{children:[s.jsx(ar,{render:Du}),s.jsx(or,{side:"top",sideOffset:4,children:"Shipping label cannot be generated until return is reviewed."})]}):s.jsx(Me,{onClick:()=>{e.open("generateShippingLabel")},children:"Generate Shipping Label"}))})]}):null,t[13]=b,t[14]=y,t[15]=e,t[16]=v):v=t[16],a=s.jsxs("div",{className:"flex flex-row items-center justify-between",children:[s.jsxs(ft,{className:"flex items-center justify-between",children:["Shipments (",d.length,")"]}),v]}),r="flex flex-col space-y-2",i=d.map(Ou),t[0]=e,t[1]=n,t[2]=l,t[3]=r,t[4]=i,t[5]=o,t[6]=a,t[7]=d}else l=t[2],r=t[3],i=t[4],o=t[5],a=t[6],d=t[7];let c;t[17]!==d.length?(c=d.length===0?s.jsx(Ss,{children:"No shipments have been created."}):null,t[17]=d.length,t[18]=c):c=t[18];let u;t[19]!==r||t[20]!==i||t[21]!==c?(u=s.jsxs("div",{className:r,children:[i,c]}),t[19]=r,t[20]=i,t[21]=c,t[22]=u):u=t[22];let m;t[23]!==e?(m=e.isOpen("generateShippingLabel"),t[23]=e,t[24]=m):m=t[24];let f;
222t[25]!==e?(f=()=>e.close("generateShippingLabel"),t[25]=e,t[26]=f):f=t[26];let h;t[27]!==m||t[28]!==f?(h=s.jsx(gu,{open:m,onClose:f}),t[27]=m,t[28]=f,t[29]=h):h=t[29];let p;return t[30]!==l||t[31]!==o||t[32]!==a||t[33]!==u||t[34]!==h?(p=s.jsxs(l,{className:o,children:[a,u,h]}),t[30]=l,t[31]=o,t[32]=a,t[33]=u,t[34]=h,t[35]=p):p=t[35],p};function Fu(t){const{...e}=t;return s.jsx(F,{variant:"ghost",size:"icon",...e,children:s.jsx(Ct,{className:"w-4 h-4"})})}function Du(t){return s.jsx("span",{...t,className:"relative flex w-full cursor-default select-none items-center rounded-sm text-sm outline-none",children:s.jsx(Me,{disabled:!0,className:"pointer-events-none w-full opacity-50",children:"Generate Shipping Label"})})}function Ou(t){return s.jsx(Er,{children:s.jsx(wu,{shipment:t})},t.id)}const Lu=t=>{const e=T.c(38),{onSubmit:n,onCancel:l}=t,{returnGroup:r}=se(),i=r.paymentIntent;let o;e[0]!==i.amountAuthorized.amount||e[1]!==i.amountReceived.amount?(o=jt(i.amountAuthorized.amount).subtract(i.amountReceived.amount),e[0]=i.amountAuthorized.amount,e[1]=i.amountReceived.amount,e[2]=o):o=e[2];const a=o.intValue;let d;e[3]!==a?(d={defaultValues:{amount:a}},e[3]=a,e[4]=d):d=e[4];const c=Nt(d);let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Capture Authorization"}),s.jsx(Oe,{children:"Please enter the amount you would like to capture."})]}),e[5]=u):u=e[5];let m;e[6]!==c||e[7]!==n?(m=c.handleSubmit(n),e[6]=c,e[7]=n,e[8]=m):m=e[8];const f=c.control;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={value:10,message:"Amount must be greater than 0"},e[9]=h):h=e[9];let p;e[10]!==a||e[11]!==i.amountAuthorized.currencyCode?(p=fe({amount:jt(a,{fromCents:!0}).value,currencyCode:i.amountAuthorized.currencyCode},!0),e[10]=a,e[11]=i.amountAuthorized.currencyCode,e[12]=p):p=e[12];const x=`Amount must be less or equal to the authorized amount ${p}`;let j;e[13]!==a||e[14]!==x?(j={required:"Amount is required",min:h,max:{value:a,message:x}},e[13]=a,e[14]=x,e[15]=j):j=e[15];let g;e[16]!==i.amountAuthorized.currencyCode?(g=_=>{const{field:I}=_;return s.jsxs(rt,{children:[s.jsx(Ts,{children:"Capture amount"}),s.jsx(pt,{render:()=>s.jsx(Qn,{value:I.value,onValueChange:N=>I.onChange(N??0),currencyCode:i.amountAuthorized.currencyCode,allowDecimals:!0})}),s.jsx(bt,{})]})},e[16]=i.amountAuthorized.currencyCode,e[17]=g):g=e[17];let b;e[18]!==c.control||e[19]!==g||e[20]!==j?(b=s.jsx(lt,{control:f,name:"amount",rules:j,render:g}),e[18]=c.control,e[19]=g,e[20]=j,e[21]=b):b=e[21];let y;e[22]!==b||e[23]!==m?(y=s.jsx("form",{onSubmit:m,id:"charge-authorization-form",children:b}),e[22]=b,e[23]=m,e[24]=y):y=e[24];let v;e[25]!==c||e[26]!==y?(v=s.jsx(kt,{...c,children:y}),e[25]=c,e[26]=y,e[27]=v):v=e[27];let S;e[28]!==l?(S=s.jsx(F,{variant:"outline",onClick:l,children:"Cancel"}),e[28]=l,e[29]=S):S=e[29];let C;e[30]!==c.formState.isSubmitting?(C=s.jsx(F,{disabled:c.formState.isSubmitting,type:"submit",form:"charge-authorization-form",children:"Confirm"}),e[30]=c.formState.isSubmitting,e[31]=C):C=e[31];let R;e[32]!==S||e[33]!==C?(R=s.jsxs(Ne,{children:[S,C]}),e[32]=S,e[33]=C,e[34]=R):R=e[34];let w;return e[35]!==v||e[36]!==R?(w=s.jsxs(s.Fragment,{children:[u,v,R]}),e[35]=v,e[36]=R,e[37]=w):w=e[37],w},Vu=t=>{const e=T.c(37),{onSubmit:n,onCancel:l}=t,{returnGroup:r}=se(),i=r.paymentIntent;let o;e[0]!==i.amountReceived.amount?(o=jt(i.amountReceived.amount),e[0]=i.amountReceived.amount,e[1]=o):o=e[1];const a=o.intValue;let d;e[2]!==a?(d={defaultValues:{amount:a}},e[2]=a,e[3]=d):d=e[3];const c=Nt(d);let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Refund"}),s.jsx(Oe,{children:"Please enter the amount you would like to refund."})]}),e[4]=u):u=e[4];let m;e[5]!==c||e[6]!==n?(m=c.handleSubmit(n),e[5]=c,e[6]=n,e[7]=m):m=e[7];const f=c.control;let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h={value:10,message:"Amount must be greater than 0"},e[8]=h):h=e[8];let p;e[9]!==a||e[10]!==i.amountReceived.currencyCode?(p=fe({amount:jt(a,{fromCents:!0}).value,currencyCode:i.amountReceived.currencyCode},!0),e[9]=a,e[10]=i.amountReceived.currencyCode,e[11]=p):p=e[11];const x=`Amount must be less or equal to the captured amount ${p}`;let j;e[12]!==a||e[13]!==x?(j={required:"Amount is required",min:h,max:{value:a,message:x}},e[12]=a,e[13]=x,e[14]=j):j=e[14];let g;e[15]!==i.amountReceived.currencyCode?(g=_=>{const{field:I}=_;return s.jsxs(rt,{children:[s.jsx(Ts,{children:"Refund amount"}),s.jsx(pt,{render:()=>s.jsx(Qn,{placeholder:"Enter amount",value:I.value,onValueChange:N=>I.onChange(N??0),currencyCode:i.amountReceived.currencyCode,allowDecimals:!0})}),s.jsx(bt,{})]})},e[15]=i.amountReceived.currencyCode,e[16]=g):g=e[16];let b;e[17]!==c.control||e[18]!==g||e[19]!==j?(b=s.jsx(lt,{control:f,name:"amount",rules:j,render:g}),e[17]=c.control,e[18]=g,e[19]=j,e[20]=b):b=e[20];let y;e[21]!==b||e[22]!==m?(y=s.jsx("form",{onSubmit:m,id:"charge-authorization-form",children:b}),e[21]=b,e[22]=m,e[23]=y):y=e[23];let v;e[24]!==c||e[25]!==y?(v=s.jsx(kt,{...c,children:y}),e[24]=c,e[25]=y,e[26]=v):v=e[26];let S;e[27]!==l?(S=s.jsx(F,{variant:"outline",onClick:l,children:"Cancel"}),e[27]=l,e[28]=S):S=e[28];let C;e[29]!==c.formState.isSubmitting?(C=s.jsx(F,{disabled:c.formState.isSubmitting,type:"submit",form:"charge-authorization-form",children:"Confirm"}),e[29]=c.formState.isSubmitting,e[30]=C):C=e[30];let R;e[31]!==S||e[32]!==C?(R=s.jsxs(Ne,{children:[S,C]}),e[31]=S,e[32]=C,e[33]=R):R=e[33];let w;return e[34]!==v||e[35]!==R?(w=s.jsxs(s.Fragment,{children:[u,v,R]}),e[34]=v,e[35]=R,e[36]=w):w=e[36],w},Uu=Re(he` 223 mutation CancelAuthorization($returnGroupId: Int!) { 224 cancelAuthorization(returnGroupId: $returnGroupId) { 225 userErrors { 226 message 227 } 228 } 229 } 230`),qu=Re(he`
231 mutation CaptureAuthorization($returnGroupId: Int!, $amount: Int!) { 232 captureAuthorization(returnGroupId: $returnGroupId, amount: $amount) { 233 userErrors { 234 message 235 } 236 } 237 } 238`),Bu=Re(he` 239 mutation CreateStripeRefund($returnGroupId: Int!, $amount: Int!) { 240 createStripeRefund(returnGroupId: $returnGroupId, amount: $amount) { 241 userErrors { 242 message 243 } 244 } 245 } 246`),Ku=Re(he` 247 mutation ReleaseAuthorization($returnGroupId: Int!) { 248 releaseAuthorization(returnGroupId: $returnGroupId) { 249 userErrors { 250 message 251 } 252 } 253 } 254`),Wu=()=>{const t=T.c(110),e=Ee(),{returnGroup:n,refetch:l}=se(),{paymentIntent:r,paymentIntentRefund:i,id:o}=n;let a;e:{if(!r){a=0;break e}let U;t[0]!==r.amountAuthorized.amount||t[1]!==r.amountReceived.amount?(U=jt(r.amountAuthorized.amount).subtract(r.amountReceived.amount),t[0]=r.amountAuthorized.amount,t[1]=r.amountReceived.amount,t[2]=U):U=t[2],a=U.intValue}const d=a;let c;t[3]!==e||t[4]!==l?(c={onSuccess:U=>{if(U.cancelAuthorization.userErrors?.length){G.dismiss(),G.error(U.cancelAuthorization.userErrors[0].message);return}G.dismiss(),G.success("Authorization canceled"),e.close("CancelAuthorization"),l()},onError:Qu},t[3]=e,t[4]=l,t[5]=c):c=t[5];const u=Uu(c);let m;t[6]!==e||t[7]!==l?(m={onSuccess:U=>{if(U.captureAuthorization.userErrors?.length){G.dismiss(),G.error(U.captureAuthorization.userErrors[0].message);return}G.dismiss(),G.success("Authorization captured"),e.close("CaptureAuthorization"),l()},onError:Hu},t[6]=e,t[7]=l,t[8]=m):m=t[8];const f=qu(m);let h;t[9]!==d||t[10]!==e||t[11]!==r?.amountAuthorized||t[12]!==l?(h={onSuccess:U=>{if(U.releaseAuthorization.userErrors?.length){G.dismiss(),G.error(U.releaseAuthorization.userErrors[0].message);return}G.dismiss(),G.success(`Payment captured, and released the remaining ${fe({amount:jt(d,{fromCents:!0}).value,currencyCode:r?.amountAuthorized.currencyCode??Ar.Usd})} to the customer`),e.close("ReleaseAuthorization"),l()},onError:Zu},t[9]=d,t[10]=e,t[11]=r?.amountAuthorized,t[12]=l,t[13]=h):h=t[13];const p=Ku(h);let x;t[14]!==e||t[15]!==l?(x={onSuccess:U=>{if(U.createStripeRefund.userErrors?.length){G.dismiss(),G.error(U.createStripeRefund.userErrors[0].message);return}e.close("CreateStripeRefund"),G.dismiss(),G.success("Refund created"),l()},onError:Yu},t[14]=e,t[15]=l,t[16]=x):x=t[16];const j=Bu(x);let g;t[17]!==r||t[18]!==i?(g=new Set,r&&(r.status===ds.RequiresCapture&&!r.amountReceived?.amount&&g.add("CancelAuthorization"),r.status===ds.RequiresCapture&&g.add("CaptureAuthorization"),r.status===ds.RequiresCapture&&r.amountReceived?.amount&&g.add("ReleaseAuthorization"),r.status===ds.Succeeded&&!i&&g.add("CreateStripeRefund")),t[17]=r,t[18]=i,t[19]=g):g=t[19];const b=g;if(!r)return null;let y;t[20]!==r.platformId?(y=s.jsxs(ft,{className:"flex gap-1",children:["Stripe Payment Information",s.jsx(ai,{stripePaymentIntentId:r.platformId})]}),t[20]=r.platformId,t[21]=y):y=t[21];let v;t[22]!==u.isPending||t[23]!==f.isPending||t[24]!==j.isPending||t[25]!==e||t[26]!==p.isPending||t[27]!==b?(v=b.size?s.jsxs(yt,{children:[s.jsx(vt,{render:Ju}),s.jsxs(St,{align:"end",children:[b.has("CancelAuthorization")?s.jsx(Me,{onClick:()=>{e.open("CancelAuthorization")},disabled:u.isPending,children:"Cancel Authorization"}):null,b.has("CaptureAuthorization")?s.jsx(Me,{onClick:()=>{e.open("CaptureAuthorization")},disabled:f.isPending,children:"Capture Authorization"}):null,b.has("ReleaseAuthorization")?s.jsx(Me,{onClick:()=>{e.open("ReleaseAuthorization")},disabled:p.isPending,children:"Release Authorization"}):null,b.has("CreateStripeRefund")?s.jsx(Me,{onClick:()=>{e.open("CreateStripeRefund")},disabled:j.isPending,children:"Refund"}):null]})]}):null,t[22]=u.isPending,t[23]=f.isPending,t[24]=j.isPending,t[25]=e,t[26]=p.isPending,t[27]=b,t[28]=v):v=t[28];let S;t[29]!==y||t[30]!==v?(S=s.jsxs("div",{className:"flex justify-between items-center",children:[y,v]}),t[29]=y,t[30]=v,t[31]=S):S=t[31];let C;t[32]!==r.amountAuthorized||t[33]!==r.amountReceived||t[34]!==r.status||t[35]!==r.updatedAt||t[36]!==i?(C=s.jsx(Se,{children:s.jsx(we,{children:r.status===ds.Succeeded?s.jsxs(s.Fragment,{children:[i?s.jsxs("div",{className:"flex flex-col mb-4",children:[s.jsxs("div",{children:[s.jsx(It,{weight:"semibold",size:"sm",children:fe(i.transactions[0].amount.shopMoney)})," ","refunded"]}),s.jsxs(M,{size:"xs",tone:"muted",children:["Updated at"," ",Rs(At(i.createdAt),"PPp")]})]}
254):null,s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{children:[s.jsx(It,{weight:"semibold",size:"sm",children:fe(r.amountReceived)})," ","captured"]}),s.jsxs(M,{size:"xs",tone:"muted",children:["Updated at ",Rs(At(r.updatedAt),"PPp")]})]})]}):r.status===ds.Canceled?s.jsx(M,{size:"sm",tone:"muted",children:"Payment canceled. It may take a few days for the money to reach the customer's bank account."}):s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{children:[s.jsx(It,{weight:"semibold",children:fe(r.amountReceived)})," ","captured (",s.jsxs(M,{as:"span",size:"sm",tone:"muted",children:[fe(r.amountAuthorized)," authorized"]}),")"]}),s.jsxs(M,{size:"xs",tone:"muted",children:["Updated at ",Rs(At(r.updatedAt),"PPp")]})]})})}),t[32]=r.amountAuthorized,t[33]=r.amountReceived,t[34]=r.status,t[35]=r.updatedAt,t[36]=i,t[37]=C):C=t[37];let R;t[38]!==e?(R=e.getDialogProps("CancelAuthorization"),t[38]=e,t[39]=R):R=t[39];let w;t[40]!==r.amountAuthorized?(w=fe(r.amountAuthorized),t[40]=r.amountAuthorized,t[41]=w):w=t[41];let _;t[42]!==w?(_=s.jsx(Ie,{children:s.jsxs(ye,{children:["Cancel this payment for"," ",w]})}),t[42]=w,t[43]=_):_=t[43];let I;t[44]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(M,{size:"sm",className:"py-4",children:"If you cancel, this payment can't be recaptured anymore. Are you sure you want to cancel this payment?"}),t[44]=I):I=t[44];let N;t[45]!==u||t[46]!==o?(N=()=>u.mutate({returnGroupId:o}),t[45]=u,t[46]=o,t[47]=N):N=t[47];let A;t[48]!==u.isPending||t[49]!==N?(A=s.jsx(Ne,{children:s.jsx(F,{disabled:u.isPending,onClick:N,children:"Confirm"})}),t[48]=u.isPending,t[49]=N,t[50]=A):A=t[50];let P;t[51]!==_||t[52]!==A?(P=s.jsxs(ve,{children:[_,I,A]}),t[51]=_,t[52]=A,t[53]=P):P=t[53];let k;t[54]!==R||t[55]!==P?(k=s.jsx(je,{...R,children:P}),t[54]=R,t[55]=P,t[56]=k):k=t[56];let E;t[57]!==e?(E=e.getDialogProps("CaptureAuthorization"),t[57]=e,t[58]=E):E=t[58];let z;t[59]!==f||t[60]!==o?(z=U=>f.mutateAsync({returnGroupId:o,amount:U.amount}),t[59]=f,t[60]=o,t[61]=z):z=t[61];let D;t[62]!==e?(D=()=>{e.close("CaptureAuthorization")},t[62]=e,t[63]=D):D=t[63];let $;t[64]!==z||t[65]!==D?($=s.jsx(ve,{children:s.jsx(Lu,{onSubmit:z,onCancel:D})}),t[64]=z,t[65]=D,t[66]=$):$=t[66];let O;t[67]!==E||t[68]!==$?(O=s.jsx(je,{...E,children:$}),t[67]=E,t[68]=$,t[69]=O):O=t[69];let q;
254t[70]!==e?(q=e.getDialogProps("ReleaseAuthorization"),t[70]=e,t[71]=q):q=t[71];let B;t[72]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(Ie,{children:s.jsx(ye,{children:"Release Authorization"})}),t[72]=B):B=t[72];let V;t[73]!==d||t[74]!==r.amountAuthorized.currencyCode?(V=fe({amount:jt(d,{fromCents:!0}).value,currencyCode:r.amountAuthorized.currencyCode}),t[73]=d,t[74]=r.amountAuthorized.currencyCode,t[75]=V):V=t[75];let L;t[76]!==V?(L=s.jsxs(M,{size:"sm",weight:"semibold",className:"py-4",children:["Release"," ",V," ","to the customer?"]}),t[76]=V,t[77]=L):L=t[77];let K;t[78]!==o||t[79]!==p?(K=()=>p.mutate({returnGroupId:o}),t[78]=o,t[79]=p,t[80]=K):K=t[80];let W;t[81]!==p.isPending||t[82]!==K?(W=s.jsx(Ne,{children:s.jsx(F,{disabled:p.isPending,onClick:K,children:"Confirm"})}),t[81]=p.isPending,t[82]=K,t[83]=W):W=t[83];let te;t[84]!==L||t[85]!==W?(te=s.jsxs(ve,{children:[B,L,W]}),t[84]=L,t[85]=W,t[86]=te):te=t[86];let Z;t[87]!==q||t[88]!==te?(Z=s.jsx(je,{...q,children:te}),t[87]=q,t[88]=te,t[89]=Z):Z=t[89];let H;t[90]!==e?(H=e.getDialogProps("CreateStripeRefund"),t[90]=e,t[91]=H):H=t[91];let X;t[92]!==j||t[93]!==o?(X=U=>j.mutateAsync({returnGroupId:o,amount:U.amount}),t[92]=j,t[93]=o,t[94]=X):X=t[94];let Q;t[95]!==e?(Q=()=>{e.close("CreateStripeRefund")},t[95]=e,t[96]=Q):Q=t[96];let Y;t[97]!==X||t[98]!==Q?(Y=s.jsx(ve,{children:s.jsx(Vu,{onSubmit:X,onCancel:Q})}),t[97]=X,t[98]=Q,t[99]=Y):Y=t[99];let ne;t[100]!==H||t[101]!==Y?(ne=s.jsx(je,{...H,children:Y}),t[100]=H,t[101]=Y,t[102]=ne):ne=t[102];let ee;return t[103]!==k||t[104]!==O||t[105]!==Z||t[106]!==ne||t[107]!==S||t[108]!==C?(ee=s.jsxs(Ze,{className:"gap-1",children:[S,C,k,O,Z,ne]}),t[103]=k,t[104]=O,t[105]=Z,t[106]=ne,t[107]=S,t[108]=C,t[109]=ee):ee=t[109],ee};function Qu(){G.dismiss(),G.error("Failed to cancel authorization")}function Hu(){G.dismiss(),G.error("Failed to capture authorization")}function Zu(){G.dismiss(),G.error("Failed to release authorization")}function Yu(){G.dismiss(),G.error("Failed to create refund")}function Ju(t){const{children:e,...n}=t;return s.jsx(F,{variant:"ghost",size:"icon",...n,children:s.jsx(Ct,{className:"h-4 w-4"})})}const Xu=()=>{const t=T.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"flex-none max-w-[360px] w-[360px] flex flex-col space-y-4",children:[s.jsx(ou,{}),s.jsx(Wu,{}),s.jsx(ud,{}),s.jsx(fu,{}),s.jsx(Mu,{}),s.jsx(Bc,{}),s.jsx(td,{})]}),t[0]=e):e=t[0],e},em=()=>{const t=T.c(47),{returnGroup:e,refetch:n}=se(),{close:l,isOpen:r}=Ee(),[i,o]=le.useState(!0),[a,d]=le.useState("");let c;t[0]!==n?(c=()=>{G.error(`Failed to cancel return group. Please email ${ut} for support.`),n()},t[0]=n,t[1]=c):c=t[1];let u;t[2]!==l||t[3]!==n?(u=()=>{G.success("Return group has been canceled."),n(),l("cancel")},t[2]=l,t[3]=n,t[4]=u):u=t[4];let m;t[5]!==c||t[6]!==u?(m={onError:c,onSuccess:u},t[5]=c,t[6]=u,t[7]=m):m=t[7];const{mutate:f,isPending:h}=tm(m);let p;t[8]!==r?(p=r("cancel"),t[8]=r,t[9]=p):p=t[9];let x;t[10]!==l?(x=k=>{k||l("cancel")},t[10]=l,t[11]=x):x=t[11];let j;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(ye,{children:"Cancel Return"}),t[12]=j):j=t[12];let g;t[13]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsxs(Ie,{children:[j,s.jsxs(Oe,{children:["Are you sure you want to cancel this return? The following will occur:",s.jsxs("ul",{className:"list-disc ml-4 mt-2 mb-2",children:[s.jsx("li",{children:"Return label(s) will be void."}),s.jsx("li",{children:"Cancellation email will be sent to customer."}),s.jsx("li",{children:"Customer will have to re-request a return."})]})]})]}),t[13]=g):g=t[13];let b;t[14]===Symbol.for("react.memo_cache_sentinel")?(b=k=>{o(!!k)},t[14]=b):b=t[14];let y;t[15]!==i?(y=s.jsx(fn,{id:"sendEmail",checked:i,onCheckedChange:b}),t[15]=i,t[16]=y):y=t[16];let v;t[17]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(nt,{htmlFor:"sendEmail",children:"Notify Customer"}),t[17]=v):v=t[17];let S;t[18]!==y?(S=s.jsxs(xe,{orientation:"horizontal",children:[y,v]}),t[18]=y,t[19]=S):S=t[19];let C;t[20]!==a||t[21]!==i?(C=i?s.jsxs(xe,{children:[s.jsx(nt,{htmlFor:"cancellationNote",children:"Cancellation Note"}),s.jsx(mn,{id:"cancellationNote",name:"cancellationNote",className:"wrap-anywhere",rows:2,maxLength:300,value:a,onChange:k=>{d(k.currentTarget.value)},placeholder:"Please explain why this return is being cancelled..."})]}):null,t[20]=a,t[21]=i,t[22]=C):C=t[22];let R;
254t[23]!==l?(R=()=>l("cancel"),t[23]=l,t[24]=R):R=t[24];let w;t[25]!==h||t[26]!==R?(w=s.jsx(F,{variant:"outline",disabled:h,onClick:R,children:"Cancel"}),t[25]=h,t[26]=R,t[27]=w):w=t[27];let _;t[28]!==a||t[29]!==f||t[30]!==e.id||t[31]!==i?(_=()=>{f({returnGroupId:e.id,cancellationNote:a,sendCancellationEmail:i})},t[28]=a,t[29]=f,t[30]=e.id,t[31]=i,t[32]=_):_=t[32];let I;t[33]!==h||t[34]!==_?(I=s.jsx(F,{variant:"destructive",disabled:h,onClick:_,children:"Cancel Return"}),t[33]=h,t[34]=_,t[35]=I):I=t[35];let N;t[36]!==w||t[37]!==I?(N=s.jsxs(Ne,{children:[w,I]}),t[36]=w,t[37]=I,t[38]=N):N=t[38];let A;t[39]!==S||t[40]!==C||t[41]!==N?(A=s.jsxs(ve,{className:"space-y-2",children:[g,S,C,N]}),t[39]=S,t[40]=C,t[41]=N,t[42]=A):A=t[42];let P;return t[43]!==A||t[44]!==p||t[45]!==x?(P=s.jsx(je,{open:p,onOpenChange:x,children:A}),t[43]=A,t[44]=p,t[45]=x,t[46]=P):P=t[46],P},tm=Re(he` 255 mutation CancelReturnGroup( 256 $returnGroupId: Int! 257 $cancellationNote: String 258 $sendCancellationEmail: Boolean 259 ) { 260 cancelReturnGroup( 261 returnGroupId: $returnGroupId 262 cancellationNote: $cancellationNote 263 sendCancellationEmail: $sendCancellationEmail 264 ) 265 } 266`),sm=()=>{const t=T.c(29),{returnGroup:e,refetch:n}=se(),{close:l,isOpen:r}=Ee();let i;t[0]!==n?(i=()=>{G.error(`Failed to complete return group. Please email ${ut} for support.`),n()},t[0]=n,t[1]=i):i=t[1];let o;t[2]!==l||t[3]!==n?(o=()=>{G.success("Return group has been completed."),n(),l("complete")},t[2]=l,t[3]=n,t[4]=o):o=t[4];let a;t[5]!==i||t[6]!==o?(a={onError:i,onSuccess:o},t[5]=i,t[6]=o,t[7]=a):a=t[7];const{mutate:d,isPending:c}=nm(a);let u;t[8]!==r?(u=r("complete"),t[8]=r,t[9]=u):u=t[9];let m;t[10]!==l?(m=y=>{y||l("complete")},t[10]=l,t[11]=m):m=t[11];let f;t[12]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Complete Return"}),s.jsx(Oe,{children:"Are you sure you want to complete this return? The following will occur:"})]}),t[12]=f):f=t[12];let h;t[13]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsxs("ul",{className:"list-disc pl-6 text-sm space-y-1",children:[s.jsx("li",{children:"Close out the return regardless of shipment status."}),s.jsx("li",{children:"Restocks inventory if auto restock is turned on."})]}),t[13]=h):h=t[13];let p;t[14]!==l?(p=()=>l("complete"),t[14]=l,t[15]=p):p=t[15];let x;t[16]!==c||t[17]!==p?(x=s.jsx(F,{variant:"outline",onClick:p,disabled:c,children:"Cancel"}),t[16]=c,t[17]=p,t[18]=x):x=t[18];let j;t[19]!==d||t[20]!==e.id?(j=s.jsx(F,{onClick:()=>{d({returnGroupId:e.id})},children:"Complete Return"}),t[19]=d,t[20]=e.id,t[21]=j):j=t[21];let g;t[22]!==x||t[23]!==j?(g=s.jsxs(ve,{children:[f,h,s.jsxs(Ne,{children:[x,j]})]}),t[22]=x,t[23]=j,t[24]=g):g=t[24];let b;return t[25]!==g||t[26]!==u||t[27]!==m?(b=s.jsx(je,{open:u,onOpenChange:m,children:g}),t[25]=g,t[26]=u,t[27]=m,t[28]=b):b=t[28],b},nm=Re(he` 267 mutation CompleteReturnGroup($returnGroupId: Int!) { 268 completeReturnGroup(returnGroupId: $returnGroupId) 269 } 270`),lm=()=>{const t=T.c(38),e=Ee(),{returnGroup:n,refetch:l}=se(),[r,i]=le.useState(n.creditMethod||null);let o;t[0]!==e||t[1]!==l?(o=()=>{l(),G.success("Updated credit method."),e.close("creditMethod")},t[0]=e,t[1]=l,t[2]=o):o=t[2];let a;t[3]!==l?(a=()=>{l(),G.error(`Failed to update credit method. Contact ${ut} for assistance.`)},t[3]=l,t[4]=a):a=t[4];let d;t[5]!==o||t[6]!==a?(d={onSuccess:o,onError:a},t[5]=o,t[6]=a,t[7]=d):d=t[7];const{mutate:c,isPending:u}=Il(d);if(!Ln(n))return null;let f;t[8]!==e?(f=e.getDialogProps("creditMethod"),t[8]=e,t[9]=f):f=t[9];let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Change Credit Method"}),s.jsx(Oe,{children:"Changing the credit method may result in the refund estimation changing."})]}),t[10]=h):h=t[10];let p;t[11]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(nt,{children:"Credit Method"}),t[11]=p):p=t[11];let x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=vn.map(rm),t[12]=x):x=t[12];let j;t[13]!==r?(j=vn.find(A=>A.value===r)?.label??"",t[13]=r,t[14]=j):j=t[14];let g;t[15]===Symbol.for("react.memo_cache_sentinel")?(g=A=>{const P=vn.find(k=>k.label===A);P&&i(P.value)},t[15]=g):g=t[15];let b;t[16]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(Gn,{render:s.jsxs(F,{variant:"input",className:"w-[240px] justify-between",children:[s.jsx(gl,{placeholder:"Select credit method"}),s.jsx(zn,{})]})}
270),t[16]=b):b=t[16];let y;t[17]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsxs(Mn,{children:[s.jsx(jl,{showTrigger:!1,placeholder:"Search"}),s.jsx(bl,{children:"No methods found."}),s.jsx(Fn,{children:im})]}),t[17]=y):y=t[17];let v;t[18]!==j?(v=s.jsxs(xe,{children:[p,s.jsxs(Tn,{items:x,value:j,onValueChange:g,children:[b,y]})]}),t[18]=j,t[19]=v):v=t[19];let S;t[20]!==e?(S=s.jsx(F,{variant:"outline",onClick:()=>e.close("creditMethod"),children:"Close"}),t[20]=e,t[21]=S):S=t[21];const C=!r||r===n.creditMethod||u;let R;t[22]!==c||t[23]!==n.id||t[24]!==r?(R=()=>{c({input:{returnGroupId:n.id,creditMethod:r}})},t[22]=c,t[23]=n.id,t[24]=r,t[25]=R):R=t[25];let w;t[26]!==C||t[27]!==R?(w=s.jsx(F,{disabled:C,onClick:R,children:"Update Credit Method"}),t[26]=C,t[27]=R,t[28]=w):w=t[28];let _;t[29]!==S||t[30]!==w?(_=s.jsxs(Ne,{children:[S,w]}),t[29]=S,t[30]=w,t[31]=_):_=t[31];let I;t[32]!==v||t[33]!==_?(I=s.jsxs(ve,{children:[h,v,_]}),t[32]=v,t[33]=_,t[34]=I):I=t[34];let N;return t[35]!==I||t[36]!==f?(N=s.jsx(je,{...f,children:I}),t[35]=I,t[36]=f,t[37]=N):N=t[37],N};function rm(t){return t.label}function im(t){return s.jsx(Dn,{value:t,children:t},t)}const am=()=>{const t=T.c(13),{returnGroup:e,refetch:n}=se(),l=Ee();let r;t[0]!==l?(r=l.getDialogProps("flag"),t[0]=l,t[1]=r):r=t[1];let i;t[2]!==l?(i=()=>l.close("flag"),t[2]=l,t[3]=i):i=t[3];let o;t[4]!==n?(o=()=>n(),t[4]=n,t[5]=o):o=t[5];let a;t[6]!==e||t[7]!==i||t[8]!==o?(a=s.jsx(ve,{className:"space-y-2",children:s.jsx(xi,{returnGroup:e,entityName:"Return",onClose:i,onSuccess:o})}),t[6]=e,t[7]=i,t[8]=o,t[9]=a):a=t[9];let d;return t[10]!==r||t[11]!==a?(d=s.jsx(je,{...r,children:a}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d},om=()=>{const t=T.c(27),{returnGroup:e,refetch:n}=se(),{close:l,isOpen:r}=Ee();let i;t[0]!==l||t[1]!==n?(i={onError:dm,onSuccess:()=>{G.success("Return has been reset."),l("reset"),n()}},t[0]=l,t[1]=n,t[2]=i):i=t[2];const{isPending:o,mutate:a}=cm(i);let d;t[3]!==r?(d=r("reset"),t[3]=r,t[4]=d):d=t[4];let c;t[5]!==l?(c=b=>{b||l("reset")},t[5]=l,t[6]=c):c=t[6];let u;t[7]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Reset Return"}),s.jsx(Oe,{children:"Are you sure you want to reset this return? The following will occur:"})]}),t[7]=u):u=t[7];let m;t[8]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsxs("ul",{className:"list-disc pl-6 text-sm space-y-1",children:[s.jsx("li",{children:"Return will be reset to unapproved status"}),s.jsx("li",{children:"All shipments will be canceled and recreated"}),s.jsx("li",{children:"Outstanding labels will be void"}),s.jsx("li",{children:"Emails will be resent when applicable"})]}),t[8]=m):m=t[8];let f;t[9]!==l?(f=()=>l("reset"),t[9]=l,t[10]=f):f=t[10];let h;t[11]!==o||t[12]!==f?(h=s.jsx(F,{variant:"outline",onClick:f,disabled:o,children:"Cancel"}),t[11]=o,t[12]=f,t[13]=h):h=t[13];let p;t[14]!==a||t[15]!==e.id?(p=()=>{a({returnGroupId:e.id})},t[14]=a,t[15]=e.id,t[16]=p):p=t[16];let x;t[17]!==o||t[18]!==p?(x=s.jsx(F,{disabled:o,onClick:p,children:"Reset Return"}),t[17]=o,t[18]=p,t[19]=x):x=t[19];let j;t[20]!==h||t[21]!==x?(j=s.jsxs(ve,{children:[u,m,s.jsxs(Ne,{children:[h,x]})]}),t[20]=h,t[21]=x,t[22]=j):j=t[22];let g;return t[23]!==d||t[24]!==c||t[25]!==j?(g=s.jsx(je,{open:d,onOpenChange:c,children:j}),t[23]=d,t[24]=c,t[25]=j,t[26]=g):g=t[26],g},cm=Re(he` 271 mutation ResetReturnGroup($returnGroupId: Int!) { 272 resetReturnGroup(returnGroupId: $returnGroupId) 273 } 274`);function dm(){G.error(`Failed reset return. Please contact ${ut}`)}const um=()=>{const t=T.c(39),{close:e,isOpen:n}=Ee(),{settings:l}=Ce(),{returnGroup:r,refetch:i}=se(),{id:o,reuploadNote:a,returns:d,status:c}=r,[u,m]=le.useState("");let f;t[0]!==e||t[1]!==i?(f={onError:fm,onSuccess:$=>{$.imageReuploadRequest.__typename==="Errors"?(G.error($.imageReuploadRequest.errors?.[0]?.message),i()):(G.success("Image re-upload email sent."),i()),e("reupload")}},t[0]=e,t[1]=i,t[2]=f):f=t[2];const{isPending:h,mutate:p}=mm(f);let x,j;t[3]!==a?(x=()=>{m(a||"")},j=[a],t[3]=a,t[4]=x,t[5]=j):(x=t[4],j=t[5]),le.useEffect(x,j);const g=l?.imageVerificationPolicy.enabled;let b;t[6]!==d?(b=d.find(hm),t[6]=d,t[7]=b):b=t[7];const y=!!b;if(!g||c!==Fe.InReview)return null;let v;t[8]!==n?(v=n("reupload"),t[8]=n,t[9]=v):v=t[9];let S;t[10]!==e?(S=$=>{$||e("reupload")},t[10]=e,t[11]=S):S=t[11];let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsxs(Ie,{children:[s.jsx(ye,{children:"Request Reupload Images"}),s.jsx(Oe,{children:"An email will be sent to the customer requesting new images. The note provided will be included in the email and on the upload page."})]}),t[12]=C):C=t[12];let R;t[13]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(nt,{htmlFor:"reuploadNote",children:"Reupload Note"}),t[13]=R):R=t[13];let w;t[14]===Symbol.for("react.memo_cache_sentinel")?(w=$=>{m($.currentTarget.value)},t[14]=w):w=t[14];let _;t[15]!==u?(_=s.jsxs(xe,{children:[R,s.jsx(mn,{id:"reuploadNote",rows:3,name:"reuploadNote",maxLength:200,value:u,className:"mt-1",onChange:w,placeholder:"Provide additional instructions..."})]}),t[15]=u,t[16]=_):_=t[16];let I;t[17]!==e?(I=()=>{e("reupload")},t[17]=e,t[18]=I):I=t[18];let N;t[19]!==h||t[20]!==I?(N=s.jsx(F,{variant:"outline",onClick:I,disabled:h,children:"Cancel"}),t[19]=h,t[20]=I,t[21]=N):N=t[21];let A;t[22]!==p||t[23]!==o||t[24]!==u?(A=()=>{p({returnGroupId:o,reuploadNote:u})},t[22]=p,t[23]=o,t[24]=u,t[25]=A):A=t[25];const P=y||h;let k;t[26]!==A||t[27]!==P?(k=s.jsx(F,{onClick:A,disabled:P,children:"Request Reupload"}),t[26]=A,t[27]=P,t[28]=k):k=t[28];let E;t[29]!==N||t[30]!==k?(E=s.jsxs(Ne,{children:[N,k]}
274),t[29]=N,t[30]=k,t[31]=E):E=t[31];let z;t[32]!==E||t[33]!==_?(z=s.jsxs(ve,{children:[C,_,E]}),t[32]=E,t[33]=_,t[34]=z):z=t[34];let D;return t[35]!==z||t[36]!==v||t[37]!==S?(D=s.jsx(je,{open:v,onOpenChange:S,children:z}),t[35]=z,t[36]=v,t[37]=S,t[38]=D):D=t[38],D},mm=Re(he` 275 mutation ImageReuploadRequest($returnGroupId: Int!, $reuploadNote: String) { 276 imageReuploadRequest(returnGroupId: $returnGroupId, reuploadNote: $reuploadNote) { 277 __typename 278 ... on ImageReuploadRequest { 279 emailSent 280 } 281 ... on Errors { 282 errors { 283 message 284 } 285 } 286 } 287 } 288`);function fm(){G.error(`Failed to send email. Please contact ${ut} .`)}function hm(t){const{verificationDecision:e}=t;return e===ge.ReuploadImage}const l1=()=>{const t=T.c(8);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/_authenticated/$returnGroupId"},t[0]=e):e=t[0];const{returnGroupId:n}=kr(e);let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx(Oc,{}),t[1]=l):l=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs(pm,{children:[l,s.jsxs("div",{className:"flex gap-6",children:[s.jsx(Dc,{}),s.jsx(Xu,{})]}),s.jsx(um,{}),s.jsx(om,{}),s.jsx(em,{}),s.jsx(sm,{}),s.jsx(Hl,{}),s.jsx(lm,{}),s.jsx(am,{})]}),t[2]=r):r=t[2];let i;t[3]!==n?(i=s.jsx(ja,{returnGroupId:n,className:"flex flex-col overflow-auto gap-6",children:r}),t[3]=n,t[4]=i):i=t[4];let o;return t[5]!==n||t[6]!==i?(o=s.jsx(oi,{returnGroupId:n,children:i}),t[5]=n,t[6]=i,t[7]=o):o=t[7],o},pm=ci(tl(Pr,{queryKey:["questionsProvider"]}),tl(va,{queryKey:["reviewProvider"]}));export{l1 as ReturnGroupPage};
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.