PageSourceSearch

https://partners.tailoredindustry.com/8761.0fa8f88050d882c6fe17.js

js tailoredindustry.com collected 2026-09-25 20:09:53 UTC 181,199 bytes, 13 lines download raw bytes

1"use strict";(globalThis.webpackChunktailored_industry||=[]).push([[8761],{96291(re,et,e){e.d(et,{A:()=>d});var t=e(74848),n=e(74722),o=e(42531),h=e(20440),i=e(30995);function v({colors:c,value:P,availableColorIds:C,onChange:r,renderDescription:l,...G}){return(0,t.jsx)(i.A,{flexDirection:"row",gap:1,rowGap:2,flexWrap:"wrap",...G,children:(0,n.A)(c,H=>{const $=H?.id||H?._id;if(!$)return null;const O=C&&!(0,o.A)(C,$),A=$===P;return(0,t.jsx)(h.A,{color:H,isSelected:A,isDisabled:O,onClick:r,sx:{cursor:"pointer"},tooltipProps:{placement:"bottom"},children:l?.({color:H,isSelected:A})},$)})})}const d=v},90077(re,et,e){e.d(et,{A:()=>c});var t=e(74848),n=e(8058),o=e(89610),h=e(42531),i=e(96540),v=e(12486);function d({sizes:P,availableSizeIds:C,renderLabel:r,...l}){const G=(0,i.useMemo)(()=>{const $=[];return(0,n.A)(P,O=>{const A=O?._id||O?.id;A&&$.push(A)}),$},[P]),H=(0,i.useMemo)(()=>{const $={};return(0,n.A)(P,O=>{const A=O?._id||O?.id;A&&($[A]=O)}),$},[P]);return(0,t.jsx)(v.A,{options:G,shape:"round",gap:1,getOptionLabel:($,O)=>{const A=H[$];return(0,o.A)(r)?r({isSelected:O,size:A}):A?.name},getOptionDisabled:$=>!!C?.length&&!(0,h.A)(C,$),nonSelectedButtonProps:{color:"inherit"},hideIcon:!0,...l})}const c=d},42617(re,et,e){e.d(et,{A:()=>h});var t=e(74848),n=e(69554);function o({sizeData:i,...v}){return i?.name?(0,t.jsx)(n.A,{color:"info",label:i?.name,...v}):null}const h=o},87083(re,et,e){e.d(et,{A:()=>$});var t=e(74848),n=e(61774),o=e(2454),h=e(30251);function i(O){const A=(0,o.G)(h.OS),{loading:q}=$.useTagsSelect();return(0,t.jsx)($,{options:A||[],getOptionLabel:N=>N,loading:q,...O})}function v(O){const A=(0,o.G)(h.N_),{loading:q}=$.useTagsSelect();return(0,t.jsx)($,{options:A||[],loading:q,...O})}var d=e(96540),c=e(76429),P=e(22552);function C(){const{errorSnackbar:O}=(0,c.d)(),{isFetching:A,isError:q}=P.G.useProductFormDataQuery();return(0,d.useEffect)(()=>{q&&O("Failed to load tags")},[q]),{loading:A}}function r(O){const A=(0,o.G)(h.b$),{loading:q}=$.useTagsSelect();return(0,t.jsx)($,{options:A||[],loading:q,...O})}function l(O){const A=(0,o.G)(h._z),{loading:q}=$.useTagsSelect();return(0,t.jsx)($,{options:A||[],loading:q,...O})}function G(O){const A=(0,o.G)(h.um),{loading:q}=$.useTagsSelect();return(0,t.jsx)($,{options:A||[],loading:q,...O})}H.Silhouette=l,H.Gender=v,H.Details=i,H.StitchStructure=G,H.SearchKeywords=r,H.useTagsSelect=C;function H(O){return(0,t.jsx)(n.A,{freeSolo:!0,multiple:!0,...O})}const $=H},75893(re,et,e){e.d(et,{A:()=>G});var t=e(74848),n=e(96540),o=e(61774),h=e(2454),i=e(76429),v=e(23841),d=e(30251),c=e(30995),P=e(69554),C=e(51161),r=e(34605);function l({disabled:H,fieldKey:$,dependencies:O,hideTiers:A=r.A.isAdminZone(),...q}){const{errorSnackbar:N}=(0,i.d)(),{useValuesQuery:K}=v.h,{isLoading:ct,isError:z}=K(),nt=(0,n.useMemo)(()=>({dependencies:O}),[O]),b=(0,h.G)(it=>(0,d.dj)(it,nt)),D=(0,n.useMemo)(()=>(0,C._)(b[$],{field:"id"}),[b]),J=(0,n.useCallback)(it=>{const Y=b?.[$]?.[it];return Y?.label||Y?.system_name||""},[b]);return(0,n.useEffect)(()=>{z&&N("Failed to load fields")},[z]),(0,t.jsx)(o.A,{disabled:H||!D.length,loading:ct,options:D,getOptionLabel:J,renderOption:(it,Y)=>{const dt=b[$]?.[Y],mt=dt?.label||dt?.system_name;return!mt||!dt?.id?null:(0,n.createElement)(c.A,{component:"li",direction:"row",gap:1,justifyContent:"space-between",...it,key:it?.key},mt,!A&&(0,t.jsx)(P.A,{label:dt?.plan?.name,color:"success"}))},...q})}const G=l},76901(re,et,e){e.d(et,{A:()=>A});var t=e(74848),n=e(46942),o=e.n(n),h=e(1694),i=e(24511),v=e(39241),d=e(96540),c=e(53660),P=e(53652),C=e(4855),r=e(30995),l=e(11848),G=e(54792),H=e(93312);const $=(0,l.A)(P.A,{shouldForwardProp:q=>q!=="highlightActive"})(({theme:q,isMobile:N,highlightActive:K})=>[{minWidth:N?280:350,width:"100%"},K&&{"& .Breakdown":{"&.active":{background:q.palette.mask.main,"&:has(+ :not(.active)), &:last-child":{background:q.palette.primary.main,color:q.palette.primary.contrastText}}}}]);function O({pricing:q,current:N,type:K,extraInfo:ct,minSpendAmount:z=0,isMobile:nt=H.A.isMobile,highlightActive:b=!0,...D}){const J=N??0,it=K===C.Th.SPEND_AMOUNT,Y=E=>{const st=(0,h.A)(E?.qty)||0;return st<=z?!0:J>=st},dt=E=>it?`From ${(0,G.A)(E?.qty,0)}`:E?.qty===z?"Base Price":`From ${E?.qty} items`,mt=E=>{if(K!==C.Th.SPEND_AMOUNT)return;const st=(0,h.A)(E?.qty)||0,Ft=(0,h.A)(E?.price)||1;return`${(0,i.A)(st/Ft)}pcs +`},At=E=>o()("Breakdown",{active:Y(E)}),pt=()=>({price:q?.base,qty:z}),yt=(0,d.useMemo)(()=>[pt(),...(0,v.A)(q?.breakdowns)],[q,z]),p=[{label:"Total order value",span:it?12:18,renderField:dt},{label:"Unit Price",span:6,renderField:E=>(0,G.A)(E?.price,0)},{label:"Quantity",span:it?6:0,renderField:mt}];return(0,t.jsxs)(r.A,{gap:2,children:[!!ct&&(0,t.jsx)(c.A,{children:ct}),(0,t.jsx)($,{highlightActive:b,items:yt,config:p,isMobile:nt,itemClassName:At,stickyHeader:!1,transparentHeader:!0,hideFooter:!0,...D})]})}const A=O},87924(re,et,e){e.d(et,{A:()=>it});var t=e(74848),n=e(76901),o=e(21879),h=e(89610),i=e(6005),v=e(1694),d=e(50791),c=e(96540),P=e(4855);function C({data:Y,onQtyChange:dt,totalOrdered:mt,breakdownType:At,minQty:pt=1}){const[yt,p]=(0,c.useState)(0),[E,st]=(0,c.useState)(pt),Ft=X=>{const Z=!(0,o.A)(X)||X<pt?pt:X;st(Z),(0,h.A)(dt)&&dt(Z)},vt=()=>{const X=Y?.breakdowns;return Array.isArray(X)?At===P.Th.SPEND_AMOUNT?(0,i.A)(X,It=>((0,v.A)(It?.qty)||0)<=E):(0,i.A)(X,It=>((0,v.A)(It?.qty)||0)<=(0,d.A)([E,mt])):-1},zt=()=>{if(At!==P.Th.SPEND_AMOUNT)return(0,d.A)([mt,E]);const X=vt(),It=Y?.breakdowns;return X<0||!Array.isArray(It)?pt:(0,v.A)(It?.[X]?.qty)||0};return(0,c.useEffect)(()=>{const X=vt(),It=Y?.breakdowns;p(()=>X<0||!Array.isArray(It)?(0,v.A)(Y?.base)||0:(0,v.A)(It?.[X]?.price)||0)},[E,Y]),(0,c.useEffect)(()=>{Ft(pt)},[pt]),{qty:E,price:yt,currentOrdered:zt(),onQtyChange:Ft}}var r=e(46942),l=e.n(r),G=e(24511),H=e(70628),$=e(61230),O=e(2728),A=e(30995),q=e(87164),N=e(33551),K=e(11848),ct=e(54792),z=e(93312);const nt=(0,K.A)(A.A,{shouldForwardProp:Y=>Y!=="isMobile"})(({isMobile:Y,theme:dt})=>({flexDirection:"row",alignItems:"center",gap:dt.spacing(1),justifyContent:Y?"right":"space-between"}));function b({data:Y,price:dt,qty:mt,onQtyChange:At,className:pt,totalOrdered:yt,minQty:p,maxQty:E,breakdownType:st,currentOrdered:Ft,isMobile:vt=z.A.isMobile,inactive:zt=!1,hideBreakdowns:X=!1,title:It="Pricing",breakdownTitle:Z="Pricing Breakdown",step:W=1,...U}){const lt=l()("Pricing",pt),T=D({minQty:p,maxQty:E,breakdownType:st}),xt=st==="spend_amount"?O.UW.usd:O.UW.pcs,jt=()=>st==="spend_amount"?"$ total spend":"# of units",Tt=()=>st==="spend_amount"?"Units:":"Total:",Gt=()=>st==="spend_amount"?(0,G.A)(mt/dt).toFixed(0):(0,ct.A)(dt*mt,0);return dt?(0,t.jsxs)(q.A,{padding:1,display:vt?"flex":"grid",gridTemplateColumns:"5fr 5fr 7fr",alignItems:"center",gap:2.5,flexWrap:"wrap",flexDirection:vt?"column":"row",className:lt,sx:{opacity:zt?.45:1},...U,children:[(0,t.jsxs)(A.A,{flex:vt?1:"initial",gap:.5,alignItems:vt?"center":"initial",children:[(0,t.jsx)(N.A,{fontWeight:"bold",fontSize:"large",children:It}),(0,t.jsx)(N.A,{hidden:!T,children:T}),(0,t.jsxs)(N.A,{fontSize:"large",hidden:!yt,children:["Total ordered:\xA0",(0,t.jsx)("strong",{children:yt})]})]}),(0,t.jsxs)(A.A,{gap:1.5,width:"100%",children:[(0,t.jsxs)(nt,{isMobile:vt,sx:{maxWidth:vt?"100%":170,width:"100%"},children:[(0,t.jsx)(N.A,{color:"text.secondary",children:Tt()}),(0,t.jsx)(N.A,{fontSize:"x-large",fontWeight:"bold",children:Gt()})]}),(0,t.jsx)(H.A,{sx:{visibility:zt?"hidden":"visible",maxWidth:vt?"100%":170,width:"100%"},unit:xt,value:mt,onChange:Yt=>At((0,v.A)(Yt)||0),placeholder:jt(),min:p,max:E,step:W})]}),(0,t.jsxs)(A.A,{gap:1.5,width:"100%",flex:vt?1:"initial",children:[(0,t.jsxs)(nt,{isMobile:vt,children:[(0,t.jsx)(N.A,{color:"text.secondary",children:"Price per unit:"}),(0,t.jsx)(N.A,{fontSize:"x-large",fontWeight:"bold",children:(0,ct.A)(dt,0)})]}),(0,t.jsx)($.A,{label:Z,variant:"outlined",hidden:X,closeOnClickInside:!1,dropdownProps:{sx:{zIndex:1}},color:"inherit",size:"small",uppercase:!0,children:(0,t.jsx)(n.A,{pricing:Y,type:st,minSpendAmount:p,current:Ft,size:"medium"})})]})]}):null}function D({minQty:Y,maxQty:dt,breakdownType:mt}){return mt===P.Th.SPEND_AMOUNT?`Min ${(0,ct.A)(Y,0)} Total Spend`:Y&&dt&&Y>1?`From ${Y} to ${dt} MOQ`:Y&&Y>1?`Min ${Y} MOQ`:dt?`Max ${dt} MOQ`:null}J.usePricing=C,J.View=b,J.Breakdowns=n.A;function J(Y){const dt=C(Y);return(0,t.jsx)(J.View,{...Y,...dt})}const it=J},29614(re,et,e){e.d(et,{A:()=>i});var t=e(74848),n=e(11397),o=e(62456);function h({embroidery:v,size:d=40}){return v?.image?.previewSrc?(0,t.jsx)(n.A,{maxHeight:d,maxWidth:d,src:v.image.previewSrc,preview:!1,minWidth:35}):(0,t.jsx)(o.A,{fontSize:"large"})}const i=h},7661(re,et,e){e.d(et,{A:()=>d});var t=e(74848),n=e(35520),o=e(65238),h=e(69554);const i={[o.q.LOGO]:"purple",[o.q.TEXT]:"teal"};function v({embroiderySet:c,sx:P,...C}){const r=c?.type;return r?(0,t.jsx)(h.A,{label:(0,n.A)(r),color:i[r],sx:[{minWidth:45},...Array.isArray(P)?P:[P]],...C}):null}const d=v},86268(re,et,e){e.d(et,{A:()=>d});var t=e(74848),n=e(35520),o=e(65238),h=e(69554);const i={[o.q.LOGO]:"purple",[o.q.TEXT]:"teal"};function v({embroidery:c,sx:P,...C}){const r=c?.type;return r?(0,t.jsx)(h.A,{label:(0,n.A)(r),color:i[r],sx:[{minWidth:45},...Array.isArray(P)?P:[P]],...C}):null}const d=v},32943(re,et,e){e.d(et,{A:()=>P});var t=e(74848),n=e(17952),o=e(5489),h=e(48484),i=e(72621),v=e(48569),d=e(85567);function c({inventoryType:C,inventoryId:r,...l}){return C===d.gK.TRIM?(0,t.jsx)(i.A,{trimId:r,...l}):C===d.gK.YARN?(0,t.jsx)(v.A,{yarnId:r,...l}):C===d.gK.LYCRA?(0,t.jsx)(o.A,{lycraId:r,...l}):C===d.gK.PACKING?(0,t.jsx)(h.A,{packingId:r,...l}):C===d.gK.LABEL?(0,t.jsx)(n.A,{labelId:r,...l}):null}const P=c},84549(re,et,e){e.d(et,{A:()=>b});var t=e(74848),n=e(96540),o=e(46942),h=e.n(o),i=e(8058),v=e(9703),d=e(74722),c=e(61774),P=e(62287),C=e(20440),r=e(12794),l=e(2454),G=e(87084),H=e(32123),$=e(65804),O=e(9860),A=e(34605);function q({withLycras:D=!0,withTrims:J=!0,withYarns:it=!0,withLabels:Y=!0}={}){const{useInventoryFormDataQuery:dt}=$.p,{isLoading:mt}
1=(0,H.M)({skipYarns:!it,skipLycras:!D,skipTrims:!J,skipLabels:!Y}),{isLoading:At}=dt(),{isFetching:pt}=G.e.useBrandPartnersQuery({limit:0},{skip:!A.A.isAdminZone()}),yt=(0,n.useMemo)(()=>({withLycras:D,withTrims:J,withLabels:Y,withYarns:it,withPacking:!1}),[Y,it,Y,D]),p=(0,l.G)(st=>(0,O.O9)(st,yt)),E=(0,l.G)(O.bM);return{inventoriesByType:p,inventories:E,loading:mt||pt||At}}var N=e(2155),K=e(30995),ct=e(69554),z=e(33551);function nt({className:D,loading:J,value:it,onChange:Y,withYarns:dt=!0,withTrims:mt=!0,withLycras:At=!0,withLabels:pt=!0,...yt}){const p=h()("InventorySelect",D),{inventories:E,inventoriesByType:st,loading:Ft}=q({withYarns:dt,withLycras:At,withTrims:mt,withLabels:pt}),[vt,zt]=(0,P.P)({value:it,onChange:Y}),X=(0,n.useMemo)(()=>{const W=[];return(0,i.A)(st,U=>{(0,i.A)(U,lt=>{!lt?.id||lt.hidden||W.push(lt.id)})}),W},[st]),It=(0,n.useMemo)(()=>{if(!(!vt||!(0,v.A)(vt)||!E?.[vt]))return(0,t.jsx)(N.A,{inventory:E?.[vt]})},[vt,E]),Z=(0,n.useMemo)(()=>{if(!vt||!(0,v.A)(vt))return;const W=E?.[vt];if(W)return(0,t.jsxs)(K.A,{direction:"row",gap:.5,children:[(0,t.jsx)(C.A.Simple,{background:W?.color?.value}),(0,t.jsx)(r.A,{brandPartner:W?.brandPartner})]})},[]);return(0,t.jsx)(c.A,{value:vt,options:X,loading:Ft||J,onChange:zt,endAdornment:It,startAdornment:Z,groupBy:W=>E?.[W]?.typeLabel||"Other",getOptionLabel:W=>E?.[W]?.title||"",getOptionKey:W=>W,className:p,renderTags:(W,U)=>(0,d.A)(W,(lt,T)=>{const xt=E?.[lt];if(!xt?.title)return;const jt=U({index:T});return(0,n.createElement)(ct.A,{label:(0,t.jsxs)(K.A,{alignItems:"center",gap:.5,direction:"row",children:[(0,t.jsx)(C.A.Simple,{background:xt?.color?.value}),(0,t.jsx)(r.A,{brandPartner:xt?.brandPartner}),(0,t.jsx)(z.A,{variant:"body2",children:xt?.title})]}),...jt,key:jt?.key})}),renderOption:(W,U)=>{const lt=E?.[U];return(0,n.createElement)(K.A,{component:"li",alignItems:"center",gap:.5,direction:"row",...W,key:W?.key},(0,t.jsx)(C.A.Simple,{background:lt?.color?.value}),(0,t.jsx)(r.A,{brandPartner:lt?.brandPartner}),(0,t.jsx)(z.A,{variant:"body2",children:lt?.title}))},disableClearable:!0,...yt})}const b=nt},30517(re,et,e){e.d(et,{A:()=>G,i:()=>l});var t=e(74848),n=e(74722),o=e(26666),h=e(20588),i=e(16394),v=e(47224),d=e(92645),c=e(34605);function P({control:H,size:$,name:O,brandPartnerId:A,canAdd:q=!0,...N}){const K=z=>c.A.isPartnerSide()?z<4&&q:q,ct=(0,h.FH)({control:H,name:O});return(0,t.jsx)(h.Ay.List,{control:H,name:O,render:({fields:z,remove:nt,append:b})=>(0,t.jsxs)(t.Fragment,{children:[(0,n.A)(z,(D,J)=>(0,t.jsxs)(h.Ay.List.Item,{children:[(0,t.jsx)(h.Ay.Item,{name:`${O}.${J}.mill_yarn`,control:H,render:({field:it,fieldState:Y})=>(0,t.jsx)(v.A,{error:Y.invalid,label:`Yarn ${d.A.numberToLetter(J+1)}`,helperText:Y.error?.message,brandPartnerId:A,size:$,inputRef:it.ref,showAvailableColors:!0,disableClearable:!0,fullWidth:!0,required:!0,...it})}),(0,t.jsx)(i.A,{onClick:()=>nt(J),disabled:J===0||J+1<z?.length})]},D.id)),(0,t.jsxs)(h.Ay.List.Button,{hidden:!K(z?.length||0),onClick:()=>b({mill_yarn:""}),disabled:!!ct?.length&&!(0,o.A)(ct)?.mill_yarn,children:["Add Yarn ",d.A.numberToLetter((z?.length||0)+1)]})]}),...N})}var C=e(31782);const r=C.Nc.object().shape({mill_yarn:C.Nc.string().required()}),l=C.Nc.array().of(r).required().min(1),G=P},27447(re,et,e){e.d(et,{A:()=>yt});var t=e(74848),n=e(46942),o=e.n(n),h=e(24401),i=e(20440),v=e(30995),d=e(33551),c=e(69554),P=e(93312);function C({item:p,className:E,isMobile:st=P.A.isMobile,...Ft}){const vt=o()("ColorwayItem",E);return(0,t.jsx)(h.A,{className:vt,...Ft,children:(0,t.jsxs)(v.A,{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flex:1,gap:1,children:[(0,t.jsx)(i.A.Simple,{background:p?.value,dotWidth:28}),(0,t.jsxs)(v.A,{width:"100%",justifyContent:"space-between",flexDirection:st?"column":"row",children:[(0,t.jsxs)(v.A,{justifyContent:"space-between",gap:1,children:[(0,t.jsx)(d.A,{children:p?.name}),(0,t.jsx)(d.A,{children:p?.yarnMill})]}),(0,t.jsxs)(v.A,{justifyContent:"space-between",gap:1,alignItems:st?"flex-start":"flex-end",children:[(0,t.jsx)(d.A,{children:p?.value}),(0,t.jsxs)(v.A,{flexDirection:"row",alignItems:"center",gap:.5,children:[(0,t.jsx)(c.A,{color:"teal",label:p?.size}),(0,t.jsx)(c.A,{color:"info",label:p?.systemName||p?.yarn_name})]})]})]})]})})}const r=C;var l=e(96540),G=e(2454),H=e(23841),$=e(87084),O=e(32123),A=e(65804),q=e(9860),N=e(34605);function K({canDeleteColorway:p=!0,shouldBeUniq:E=!0,canAddColorway:st=!0,isMobile:Ft=P.A.isMobile,...vt}={}){const[zt,X]=(0,l.useState)(),[It,Z]=(0,l.useState)(),{isFetching:W}=$.e.useBrandPartnersQuery({limit:0},{skip:!N.A.isAdminZone()}),{isLoading:U}=H.h.useColorsQuery(),{useInventoryFormDataQuery:lt}=A.p,{isLoading:T}=lt(),{isLoading:xt}=(0,O.M)({skipTrims:!0,skipLabels:!0}),jt=(0,l.useMemo)(()=>({brandPartnerId:It}),[It]),Tt=(0,G.G)(Yt=>(0,q.n0)(Yt,jt)),Gt=(0,G.G)(Yt=>(0,q.bs)(Yt,jt));return{yarnColors:Tt,lycras:Gt,millYarn:zt,setMillYarn:X,brandPartner:It,setBrandPartner:Z,isMobile:Ft,canDeleteColorway:p,shouldBeUniq:E,loading:W||xt||T||U,c
1anAddColorway:zt?.length?st:!1,...vt}}const ct=(0,l.createContext)({});function z({children:p,...E}){return(0,t.jsx)(ct.Provider,{value:E,children:p})}function nt(){return(0,l.useContext)(ct)}var b=e(89610),D=e(74722),J=e(91235),it=e(23149),Y=e(11848),dt=e(92645);const mt=(0,Y.A)(v.A)(({theme:p})=>({...p.mixins.nonPageBreakable}));function At({colorway:p,hideLycra:E,renderYarnLabel:st,renderLycraLabel:Ft,className:vt,...zt}){const X=o()("YarnColorway__View",vt),It=W=>(0,b.A)(st)?st(W):`Yarn ${dt.A.numberToLetter(W+1)}`,Z=W=>(0,b.A)(Ft)?Ft(W):`Lycra ${dt.A.numberToLetter(W+1)}`;return(0,t.jsx)(mt,{className:X,gap:1,...zt,children:(0,D.A)(p,(W,U)=>(0,t.jsxs)(l.Fragment,{children:[W?.value&&(0,t.jsx)(yt.ColorwayItem,{item:W,label:(0,t.jsx)(c.A,{label:It(U),color:"info"})}),!E&&W?.value&&!!(0,J.A)(W?.lycra)&&(0,D.A)(W?.lycra,(lt,T)=>!(0,it.A)(lt)||!("value"in lt)||!lt?.value?null:(0,t.jsx)(yt.ColorwayItem,{item:lt,label:(0,t.jsx)(c.A,{label:Z(U),color:"purple"})},`${U}_${T}`))]},U))})}pt.Provider=z,pt.Context=ct,pt.useContext=nt,pt.useYarnColorways=K,pt.ColorwayItem=r,pt.View=At;function pt({children:p,...E}){const st=K(E);return(0,t.jsx)(z,{...st,children:p})}const yt=pt},88489(re,et,e){e.d(et,{Ay:()=>j,l0:()=>gt,Eq:()=>qt,SV:()=>Kt});var t=e(74848),n=e(74722),o=e(20588),h=e(39241),i=e(39622),v=e(8058),d=e(96540),c=e(2454),P=e(23841),C=e(87084),r=e(32123),l=e(65804),G=e(9860),H=e(34605),$=e(93312);function O({millYarnIds:m,brandPartnerId:u,name:f,colorwayName:L,form:a,canDeleteColorway:M=!0,shouldBeUniq:ot=!0,canAddColorway:Ct=!0,isMobile:ut=$.A.isMobile,...oe}){const Ut=(0,d.useMemo)(()=>!!(0,h.A)(m)?.length,[m]),{isFetching:bt}=C.e.useBrandPartnersQuery({limit:0},{skip:!H.A.isAdminZone()}),{isLoading:de}=P.h.useColorsQuery(void 0,{skip:!Ut}),{useInventoryFormDataQuery:Pe}=l.p,{isLoading:xe}=Pe(void 0,{skip:!Ut}),{isLoading:Fe}=(0,r.M)({skipTrims:!0,skipLabels:!0,skip:!Ut}),ie=(0,d.useMemo)(()=>({brandPartnerId:u}),[u]),Bt=(0,c.G)(at=>(0,G.n0)(at,ie)),B=(0,c.G)(at=>(0,G.bs)(at,ie)),x=({yarnColorwayKey:at,colorwayKey:y,name:_})=>{const Pt=[f,at];return L&&Pt.push(L),Pt.push(y),_&&Pt.push(_),Pt.join(".")},I=({yarnColorwayKey:at,colorwayKey:y,value:_,options:Pt})=>{if(!a)return;const ee=x({colorwayKey:y,yarnColorwayKey:at,name:"lycra"});a.setValue(ee,_,{shouldDirty:!0,shouldTouch:!0,...Pt}),a.trigger(ee)};return{yarnColors:Bt,lycras:B,clearLycra:({colorwayKey:at})=>{if(!a)return;const y=a.getValues(f);(0,v.A)(y,(_,Pt)=>{I({yarnColorwayKey:Pt,colorwayKey:at,value:[]})}),a.trigger(f)},setLycra:I,setSuggestedLycra:({colorwayKey:at,yarnColorwayKey:y})=>{if(!a)return;const _=a.getValues(x({colorwayKey:at,yarnColorwayKey:y}));if(!_||!_?.yarn)return;const Pt=(0,h.A)(Bt?.[_.yarn]?.lycraIds).filter(ee=>typeof ee=="string"&&(0,i.A)(B,ee));I({yarnColorwayKey:y,colorwayKey:at,value:Pt,options:{shouldValidate:!0}})},setSuggestedLycraAll:({colorwayKey:at})=>{if(!a)return;const y=a.getValues(f);!Array.isArray(y)||!y.length||((0,v.A)(y,(_,Pt)=>{const ee=a.getValues(x({colorwayKey:at,yarnColorwayKey:Pt,name:"yarn"}));if(!ee)return;const fe=(0,h.A)(Bt?.[ee]?.lycraIds).filter(me=>typeof me=="string"&&(0,i.A)(B,me));I({colorwayKey:at,yarnColorwayKey:Pt,value:fe})}),a.trigger(f))},millYarnIds:m,brandPartnerId:u,name:f,form:a,isMobile:ut,canDeleteColorway:M,shouldBeUniq:ot,makeName:x,loading:bt||Fe||xe||de,canAddColorway:m?.length?Ct:!1,...oe}}const A=(0,d.createContext)({});function q({children:m,...u}){return(0,t.jsx)(A.Provider,{value:u,children:m})}function N(){return(0,d.useContext)(A)}var K=e(77500),ct=e(24401),z=e(16394),nt=e(30679),b=e(92866),D=e(39693),J=e(37034),it=e(66070),Y=e(66401),dt=e(42531),mt=e(61774),At=e(62287),pt=e(20440),yt=e(12794),p=e(8047),E=e(87164),st=e(30995),Ft=e(33551),vt=e(69554),zt=e(99682),X=e(1649),It=e(11641);function Z({quantity:m,lycra:u,onIncrement:f,onDecrement:L,onDelete:a,...M}){return u?.id?(0,t.jsx)(vt.A,{label:(0,t.jsxs)(st.A,{direction:"row",gap:.5,component:"span",alignItems:"center",children:[(0,t.jsx)(pt.A.Simple,{background:u.color?.value,style:{width:28}}),(0,t.jsxs)("span",{children:[(0,t.jsx)(It.A,{color:"error",size:"small",onMouseDown:ot=>{ot.stopPropagation()},onClick:ot=>{ot.stopPropagation(),L(u)},children:(0,t.jsx)(X.A,{})}),(0,t.jsx)(vt.A,{color:"info",size:"small",label:m}),(0,t.jsx)(It.A,{size:"small",color:"success",onMouseDown:ot=>{ot.stopPropagation()},onClick:ot=>{ot.stopPropagation(),f(u)},children:(0,t.jsx)(zt.A,{})})]}),u?.title]}),deleteIcon:(0,t.jsx)(p.A,{onMouseDown:ot=>ot.stopPropagation()}),onDelete:()=>a(u),...M}):null}const W=Z;function U({value:m,onChange:u,yarnIds:f,helperText:L,disabled:a,...M}){const[ot,Ct]=(0,At.P)({value:m,onChange:u}),{lycras:ut,loading:oe}=j.useContext(),Ut=(0,d.useMemo)(()=>({yarnIds:f}),[f]),bt=(0,c.G)(B=>(0,G.LJ)(B,Ut)),de=(0,d.useMemo)(()=>{const B={};return(0,v.A)((0,nt.A)(bt,"title"),x=>{!x?.id||x?.hidden||!(0,i.A)(x,x?.id)||(B[x.id]=x.id)}),(0,v.A)((0,nt.A)(ut,"title"),x=>{!x?.id||x?.hidden||(B[x.id]=x.id)}),(0,b.A)(B)},[ut,bt]),Pe=(0,d.useMemo)(()=>{const B={};return(0,v.A)(ot,(x,I)=>
1{if(x){if(!B[x]){B[x]={index:I,qty:1};return}B[x].qty+=1}}),B},[ot]),xe=B=>{Ct(x=>B?.id?[...x||[],B.id]:x)},Fe=B=>{Ct(x=>{const I=(0,D.A)(x,B.id);return[...(0,J.A)(x,0,I),...(0,J.A)(x,I+1)]})},ie=B=>{Ct(x=>(0,it.A)(x,I=>I!==B.id))},Bt=(0,d.useMemo)(()=>{if(L)return L;let B;const x=(0,it.A)(ot,I=>!(0,i.A)(ut,I));if((0,Y.A)(x)||(B="Unavailable lycra"),f?.length||(B="You have to select Yarn first"),!!B)return(0,t.jsx)(E.A,{component:"span",sx:I=>({color:I.palette.warning.main}),children:B})},[L,f?.length,ot]);return(0,t.jsx)(mt.A,{options:de,value:ot,onChange:Ct,loading:oe,openOnFocus:!1,disabled:a||!f?.length,helperText:Bt,getOptionDisabled:B=>(0,dt.A)(m,B),getOptionLabel:B=>ut[B]?.title||"",getOptionKey:B=>ut[B]?.id||B,renderOption:(B,x)=>{const I=ut[x];if(!I?.id||!I?.title)return;const g=!!bt?.[I.id]?.id;return(0,d.createElement)(st.A,{component:"li",direction:"row",alignItems:"center",gap:V=>V.spacing(1),...B,key:B?.key},(0,t.jsx)(pt.A.Simple,{background:I.color?.value,style:{width:28}}),(0,t.jsx)(yt.A,{brandPartner:I.brandPartner,hidden:H.A.isPartnerSide()}),(0,t.jsx)(Ft.A,{sx:{flex:1},children:I.title}),g&&(0,t.jsx)(vt.A,{size:"small",label:"Suggested",color:"success",sx:{alignSelf:"flex-end"}}))},renderTags:(B,x)=>(0,n.A)(Pe,(I,g)=>{const V=ut[g];if(!V?.title)return(0,t.jsx)(vt.A,{size:"small",label:"Unavailable lycra",color:"warning",deleteIcon:(0,t.jsx)(p.A,{onMouseDown:at=>at.stopPropagation()}),onDelete:()=>{Ct(at=>(0,it.A)(at,y=>y!==g))}});const ht=x({index:I?.index});return(0,d.createElement)(W,{size:"medium",lycra:V,onDecrement:Fe,onIncrement:xe,quantity:I.qty,...ht,key:ht?.key,onDelete:ie})}),disableClearable:!0,multiple:!0,...M})}const lt=U;var T=e(9703),xt=e(36249);function jt({onChange:m,value:u,millYarnId:f,disabled:L,helperText:a,yarnColorwayKey:M,colorwayKey:ot,...Ct}){const{yarnColors:ut,loading:oe,disableYarnColors:Ut,setLycra:bt,lycras:de}=j.useContext(),Pe=(0,d.useMemo)(()=>({millYarnId:f}),[f]),xe=(0,c.G)(x=>(0,xt.j5)(x,Pe)),Fe=(0,d.useMemo)(()=>{const x=[];return(0,v.A)((0,nt.A)(ut,"label"),I=>{!I?.yarnId||!f||I.mill_yarn===f&&(I.hidden||x.push(I.yarnId))}),x},[f,ut]),ie=()=>{if(a)return a;let x;if(f||(x="You have to select Mill Yarn first"),u&&ut[u]?.mill_yarn!==f&&(x=`This color doesn't exists in ${xe?.name}`),!!x)return(0,t.jsx)(E.A,{component:"span",sx:I=>({color:I.palette.warning.main}),children:x})},Bt=(0,d.useMemo)(()=>{if(!(!u||!(0,T.A)(u)||!ut?.[u]?.color))return(0,t.jsx)(pt.A.Simple,{background:ut?.[u]?.color,style:{width:28}})},[u,ut]),B=x=>{const I=x?(0,h.A)(ut?.[x]?.lycraIds):[];bt({yarnColorwayKey:M,colorwayKey:ot,value:(0,it.A)(I,g=>(0,i.A)(de,g))}),m?.(x)};return(0,t.jsx)(mt.A,{value:u,options:Fe,onChange:B,startAdornment:Bt,loading:oe,disabled:!f||!!Ut||L,getOptionLabel:x=>ut?.[x]?.label||"Unavailable yarn for current BP",renderLabel:x=>(0,t.jsxs)(t.Fragment,{children:[x,xe?.name&&` - ${xe?.name}`]}),renderOption:(x,I)=>{const g=ut[I];if(g?.id)return(0,d.createElement)(st.A,{component:"li",direction:"row",alignItems:"center",gap:V=>V.spacing(1),...x,key:x?.key},(0,t.jsx)(pt.A.Simple,{background:g.color,style:{width:28}}),(0,t.jsx)(yt.A,{brandPartner:g.brandPartner,hidden:H.A.isPartnerSide()}),g.label)},helperText:ie(),disableClearable:!0,...Ct})}const Tt=jt;var Gt=e(71543),Yt=e(92645),ne=e(11201),te=e(26336);function Lt({colorwayKey:m,...u}){const{clearLycra:f}=j.useContext();return(0,t.jsx)(ne.A,{startIcon:(0,t.jsx)(te.A,{}),variant:"text",color:"warning",size:"small",onClick:()=>f({colorwayKey:m}),confirmProps:{title:"Clear lycra?",children:`
2          "Lycra ${Yt.A.numberToLetter(m+1)}" for all colorways will be deleted
3        `},confirmOnClick:!0,uppercase:!0,...u})}const tt=Lt;var Vt=e(21548),Dt=e(22925);function Et({colorwayKey:m,yarnColorwayKey:u,...f}){const{setSuggestedLycra:L,setSuggestedLycraAll:a}=j.useContext(),M=({checked:ot})=>ot?a({colorwayKey:m}):L({colorwayKey:m,yarnColorwayKey:u});return(0,t.jsx)(Vt.A.Button,{variant:"text",color:"success",size:"small",startIcon:(0,t.jsx)(Dt.A,{}),renderConfirm:({checked:ot,setChecked:Ct})=>(0,t.jsx)(Vt.A.Swith,{value:ot,onChange:Ct,label:`
4                        Set for "Lycra ${Yt.A.numberToLetter(m+1)}"
5                        in all colorways
6                    `}),confirmTitle:"Set suggested lycra?",onOk:M,uppercase:!0,...f})}const Wt=Et;function Nt({millYarnIds:m,index:u,parentName:f,control:L,remove:a,colorwayName:M,makeName:ot,form:Ct,hideLycra:ut,canRemove:oe=!0,...Ut}){const bt=(0,o.FH)({control:L,name:f}),de=ie=>ie+1>=(m?.length||0),[Pe,xe]=(0,d.useState)(m?.length||0),Fe=ie=>M?(0,K.A)(bt,[u,M,ie]):(0,K.A)(bt,[u,ie]);return(0,d.useEffect)(()=>
6{if(xe(m?.length||0),m?.length>=Pe)return;const ie=[];(0,v.A)(m,(B,x)=>{const I=Fe(x);I&&ie.push(I)});const Bt=()=>M?`${f}.${u}.${M}`:`${f}.${u}`;Ct.setValue(Bt(),ie,{shouldDirty:!1,shouldTouch:!1})},[m?.length]),(0,t.jsx)(ct.A,{label:(0,t.jsx)(vt.A,{label:`Colorway ${u+1}`}),centeredLabel:!0,...Ut,children:(0,n.A)(m,(ie,Bt)=>(0,t.jsxs)(d.Fragment,{children:[(0,t.jsxs)(st.A,{flexDirection:"row",gap:1,children:[(0,t.jsx)(o.Ay.Item,{name:ot({colorwayKey:Bt,yarnColorwayKey:u,name:"yarn"}),control:L,render:({field:B,fieldState:x})=>(0,t.jsx)(Tt,{millYarnId:ie,error:x.invalid,label:`Yarn ${Yt.A.numberToLetter(Bt+1)}`,helperText:x.error?.message,colorwayKey:Bt,yarnColorwayKey:u,inputRef:B.ref,fullWidth:!0,required:!0,...B})}),!!ut&&(0,t.jsx)(z.A,{sx:{visibility:de(Bt)?"visible":"hidden"},disabled:!oe,onClick:()=>a(u)})]}),!ut&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Ay.Item,{name:ot({colorwayKey:Bt,yarnColorwayKey:u,name:"lycra"}),control:L,render:({field:B,fieldState:x})=>(0,t.jsx)(lt,{yarnIds:(0,h.A)([Fe(Bt)?.yarn]),error:x.invalid,label:`Lycra ${Yt.A.numberToLetter(Bt+1)}`,helperText:x.error?.message,inputRef:B.ref,fullWidth:!0,required:!0,...B})}),(0,t.jsxs)(st.A,{flexDirection:"row",gap:1,children:[(0,t.jsx)(tt,{disabled:!Fe(Bt)?.yarn,colorwayKey:Bt,fullWidth:!0,children:"Clear Lycra"}),(0,t.jsx)(Wt,{colorwayKey:Bt,disabled:!Fe(Bt)?.yarn,yarnColorwayKey:u,fullWidth:!0,children:"Set Suggested Lycra"}),(0,t.jsx)(z.A,{sx:{visibility:de(Bt)?"visible":"hidden"},disabled:!oe,onClick:()=>a(u)})]})]}),!de(Bt)&&(0,t.jsx)(Gt.A,{})]},`${ie}_${Bt}`))})}$t.Provider=q,$t.Context=A,$t.useContext=N,$t.Item=Nt,$t.useYarnColorwayFormList=O;function $t({control:m,name:u,millYarnIds:f,brandPartnerId:L,canDeleteColorway:a,canAddColorway:M,disableYarnColors:ot,shouldBeUniq:Ct,hideLycra:ut,isMobile:oe,colorwayName:Ut,form:bt,...de}){const Pe=O({millYarnIds:f,brandPartnerId:L,canDeleteColorway:a,canAddColorway:M,disableYarnColors:ot,shouldBeUniq:Ct,hideLycra:ut,isMobile:oe,name:u,colorwayName:Ut,form:bt});return(0,t.jsx)(q,{...Pe,children:(0,t.jsx)(o.Ay.List,{control:m,name:u,render:({fields:xe,name:Fe,remove:ie,append:Bt})=>(0,t.jsxs)(t.Fragment,{children:[(0,n.A)(xe,(B,x)=>(0,t.jsx)(Nt,{index:x,remove:ie,millYarnIds:f,parentName:Fe,control:m,canRemove:(xe?.length||0)>1,colorwayName:Ut,makeName:Pe.makeName,form:bt,hideLycra:ut},B.id)),(0,t.jsx)(o.Ay.List.Button,{onClick:()=>Bt([(0,n.A)(f,()=>({lycra:[],yarn:""}))]),hidden:!M,children:"Add Colorway"})]}),...de})})}var he=e(1694),Se=e(59116),k=e(31782);const St=({validationData:m,yarnColorwayId:u,withLycra:f,skipYarnColorwayUnique:L=!1})=>k.Nc.object({order:k.Nc.mixed().optional().nullable(),yarn:k.Nc.string().required().test({name:"yarnColorwayUnique",test:(a,M)=>!L&&(m.yarnColorwaysByIndex[u]?.length||0)>1?M.createError({message:"Such colorway already exists!"}):!0}),lycra:f?k.Nc.array().of(k.Nc.string().required()).test({name:"lycraCommonLength",test:(a,M)=>{const ot=(0,K.A)(M,"options.index")||0,{mostCommonLycraLengthByIndex:Ct}=m,ut=Ct[ot]||0,oe=a?.length||0;if(ut!==oe){const Ut=[`Expected number of Lycras: ${ut}`];return oe>ut&&Ut.unshift("Add Lycra to other colorways to make this field valid"),oe<ut&&Ut.unshift("Remove Lycra from other colorways to make this field valid"),M.createError({message:Ut.join(". ")})}return!0}}):k.Nc.mixed()}),qt=({validationData:m,withLycra:u=!0,skipYarnColorwayUnique:f=!1})=>k.Nc.lazy(L=>{const a=(0,n.A)(L,M=>M?.yarn).join("_");return k.Nc.array().of(St({validationData:m,yarnColorwayId:a,withLycra:u,skipYarnColorwayUnique:f}))}),Kt=({withLycra:m=!0}={})=>k.Nc.lazy(u=>{const f=gt({yarnColorways:u});return k.Nc.array().of(qt({validationData:f,withLycra:m}))}),gt=({yarnColorways:m})=>{const u={},f={};return(0,v.A)(m,(a,M)=>{const ot=[];(0,v.A)(a,(ut,oe)=>{ut?.yarn&&ot.push(ut?.yarn),f[oe]||(f[oe]={});const Ut=ut?.lycra?.length||0;if(!f[Ut]){f[oe][Ut]=1;return}f[oe][Ut]+=1});const Ct=ot.join("_");if(Ct){if(!u[Ct]){u[Ct]=[(0,he.A)(M)];return}u[Ct].push((0,he.A)(M))}}),{yarnColorwaysByIndex:u,mostCommonLycraLengthByIndex:(0,Se.A)(f,a=>{const M=Object.keys(a);return M?.length&&(0,he.A)(M.reduce((ot,Ct)=>f[(0,he.A)(ot)]>f[(0,he.A)(Ct)]?ot:Ct))||0})}},j=$t},25692(re,et,e){e.d(et,{A:()=>c});var t=e(74848),n=e(74722),o=e(17857),h=e(61676),i=e(30995),v=e(69554);function d({phases:P,hidden:C,...r}){const{isLoading:l}=h._.usePhasesQuery({limit:0},{skip:C});return C?null:(0,t.jsxs)(i.A,{flexWrap:"wrap",gap:1,flexDirection:"row",maxWidth:"100%",...r,children:[(0,t.jsx)(o.A,{loading:l}),(0,n.A)(P,(G,H)=>(0,t.jsx)(v.A,{color:"info",hidden:!G?.name,style:{margin:0},label:G?.name},`${G?.id}_${H}`))]})}const c=d},54130(re,et,e){e.d(et,{A:()=>q});var t=e(74848),n=e(96540);const o=(0,n.createContext)({});function h({children:N,...K}){return(0,t.jsx)(o.Provider,{value:K,children:N})}function i(){return(0,n.useContext)(o)}var v=e(53652),d=e(44527),c=e(32943);function P({fetching:N,...K}){const{inventories:ct,inventoriesLoading:z}=q.useContext(),nt=[{label:"Name",span:7,renderField:b=>b?.name||b?.system_name},{field:"quantity",label:"Quantity",span:4},{field:"location",label:"Location",span:6},{field:"type",label:"Type",span:4},{label:"Active",span:3,renderField(b){return(0,t.jsx)(d.A,{inventory:b})}}];return(0,t.jsx)(v.A,{config:nt,items:ct,fetching:N||z,extraRight:b=>
6(0,t.jsx)(c.A,{inventoryId:b?.id,inventoryType:b?.type,children:"View"}),transparentHeader:!0,stickyHeader:!1,hideFooter:!0,...K})}var C=e(11201),r=e(42985);function l({loading:N,children:K,...ct}){const{onApprove:z,modal:nt,loading:b}=q.useContext();return(0,t.jsx)(r.Ay,{title:"Inactive Inventories for this Variant",open:nt.visible,onClose:nt.close,maxWidth:"md",loading:b||N,actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.A,{onClick:nt.close,color:"error",size:"large",uppercase:!0,fullWidth:!0,children:"Cancel"}),(0,t.jsx)(C.A,{onClick:z,color:"primary",variant:"contained",size:"large",uppercase:!0,fullWidth:!0,children:"Confirm update"})]}),fullWidth:!0,...ct,children:K})}var G=e(2454),H=e(32123),$=e(9860);function O({inventoryIds:N,onApprove:K,loading:ct}){const z=(0,r.hS)(),nt=(0,n.useMemo)(()=>({inventoryIds:N}),[N]),b=(0,G.G)(J=>(0,$.SS)(J,nt)),{isLoading:D}=(0,H.M)({skip:!z.visible});return{inventories:b,modal:z,inventoryIds:N,onApprove:K,inventoriesLoading:D,loading:D||!!ct}}A.Context=o,A.Provider=h,A.useContext=i,A.Modal=l,A.List=P,A.useApproveVariantUpdate=O;function A(N){return(0,t.jsx)(A.Provider,{...N,children:(0,t.jsx)(A.Modal,{children:(0,t.jsx)(A.List,{})})})}const q=A},25485(re,et,e){e.d(et,{A:()=>q});var t=e(74848),n=e(96540),o=e(9703),h=e(61774),i=e(62287),v=e(12794),d=e(69518),c=e(26284),P=e(87164),C=e(30995),r=e(51161),l=e(2454),G=e(22552),H=e(27354);function $({brandPartnerId:N}){const{useOrderableProductsQuery:K}=G.G,{productsLoading:ct,response:z}=K({brand_partner:N},{skip:!N,selectFromResult:D=>({productsLoading:D.isLoading||D.isFetching,response:D?.data})}),nt=(0,n.useMemo)(()=>({productIds:(0,r._)(z?.products,{field:"_id"})}),[z]);return{orderableProducts:(0,l.G)(D=>(0,H.bj)(D,nt)),loading:ct}}A.useSelect=$;const O=({product:N})=>(0,t.jsxs)(P.A,{display:"flex",alignItems:"center",minHeight:40,gap:1,children:[(0,t.jsx)(d.A,{product:N,size:"small",maxWidth:50}),(0,t.jsx)(c.A,{product:N}),(0,t.jsx)(v.A,{label:N?.brandPartnerCode})]});function A({brandPartnerId:N,loading:K,readOnly:ct,helperText:z,value:nt,onChange:b,...D}){const[J,it]=(0,i.P)({value:nt,onChange:b}),{orderableProducts:Y,loading:dt}=$({brandPartnerId:N}),mt=(0,n.useMemo)(()=>(0,r._)(Y,{field:"id"}),[Y]),At=(0,n.useMemo)(()=>{if(!(!J||!(0,o.A)(J)))return(0,t.jsx)(O,{product:Y?.[J]})},[J,Y]),pt=()=>{if(z)return z;if(!N)return"Please select a brand partner first"},yt=(0,n.useCallback)(p=>{if(!p)return"";const E=Y?.[p];return[E?.name||"",E?.is_stk?"stk":"",E?.brandPartnerCode||""].join(" ")},[Y]);return(0,t.jsx)(h.A,{value:J,startAdornment:At,getOptionSearchLabel:yt,onChange:it,loading:dt||K,readOnly:!N||ct,helperText:pt(),options:K||dt?[]:mt,label:"Orderable Product",getOptionKey:p=>p,renderOption:(p,E)=>{const st=Y?.[E];if(st?.name)return(0,n.createElement)(C.A,{component:"li",direction:"row",gap:1,...p,key:p?.key},(0,t.jsx)(O,{product:st}),(0,t.jsx)("span",{children:st?.name}))},getOptionLabel:p=>Y?.[p]?.name||"",...D})}const q=A},49205(re,et,e){e.d(et,{A:()=>H});var t=e(74848),n=e(39241),o=e(96540),h=e(84413),i=e(96759),v=e(8488),d=e(2454),c=e(74774),P=e(25692),C=e(22552),r=e(27354),l=e(30995);function G({productId:$,fetching:O,...A}){const[q,N]=(0,o.useState)(),K=(0,d.G)(r.L),{useProductActionsQuery:ct}=C.G,{isLoading:z,pagination:nt}=ct({productId:$,params:q},{refetchOnMountOrArgChange:!0,skip:!$,selectFromResult:b=>({pagination:{total:b.data?.total,offset:b.data?.offset,limit:b.data?.limit},isLoading:b.isFetching})});return(0,t.jsx)(h.A,{actions:K,fetching:z||O,paginationData:nt,onPaginate:N,renderCreatedTitle:()=>"Product Created",renderBrandPartnersField:({action:b,dataKey:D})=>(0,t.jsx)(c.A,{brandPartners:(0,n.A)(b?.[D])}),renderPhasesField:({action:b,dataKey:D})=>(0,t.jsx)(P.A,{phases:(0,n.A)(b?.[D])}),renderTagsField:({action:b,dataKey:D})=>b?.[D]?(0,t.jsxs)(l.A,{gap:2,alignItems:"initial",children:[!!b?.[D]?.details&&(0,t.jsx)(i.A,{title:"Detail tags",value:(0,t.jsx)(v.A,{tags:(0,n.A)(b?.[D]?.details),color:"success"})}),!!b?.[D]?.silhouette&&(0,t.jsx)(i.A,{title:"Silhouette tags",value:(0,t.jsx)(v.A,{tags:(0,n.A)(b?.[D]?.silhouette),color:"teal"})}),!!b?.[D]?.stitch_structure&&(0,t.jsx)(i.A,{title:"Stitch structure tags",value:(0,t.jsx)(v.A,{tags:(0,n.A)(b?.[D]?.stitch_structure),color:"warning"})}),!!b?.[D]?.gender&&(0,t.jsx)(i.A,{title:"Gender tags",value:(0,t.jsx)(v.A,{tags:(0,n.A)(b?.[D]?.gender),color:"purple"})})]}):void 0,renderGaugeField:({action:b,dataKey:D})=>b?.[D]?.label,...A})}const H=G},21568(re,et,e){e.d(et,{A:()=>b});var t=e(74848),n=e(96540),o=e(40134),h=e(3979),i=e(76429),v=e(49497),d=e(91235),c=e(42985),P=e(2454),C=e(23841),r=e(32123),l=e(22552),G=e(27354);function H({productId:D}){const J=(0,c.hS)(),it=(0,n.useMemo)(()=>({productId:D}),[D]),Y=(0,P.G)(E=>(0,G.Mi)(E,it)),{useProductQuery:dt}=l.G,{isFetching:mt}=dt({productId:D},{skip:!D||!J.visible}),{isLoading:At}=(0,r.M)({skip:!D||!J.visible,skipLycras:!0,skipTrims:!0,skipLabels:!0}),{isFetching:pt}=C.h.useSizesQuery(void 0,{skip:!D||!J.visible}),{isLoading:yt}=C.h.useColorsQuery(void 0,{skip:!D||!J.visible}),p=mt||At||pt||yt;return(0,n.useEffect)(()=>{!p&&!(0,d.A)(Y)&&J.visible&&J.close()},[Y,p]),{modal:J,loading:p,disabledVariants:Y,hasDisabledVariants:!!(0,d.A)(Y)}}const $=(0,n.createContext)({});function O({children:D,...J}){return(0,t.jsx)($.Provider,{value:J,children:D})}function A(){return(0,n.useContext)($)}var q=e(26314);function N(D){const{disabledVariants:J}=z.useContext();
6return(0,t.jsx)(q.A.View,{groupedVariants:J,...D})}function K({loading:D,...J}){const{modal:it,loading:Y}=z.useContext();return(0,t.jsx)(c.Ay,{title:"Inactive product variants",open:it.visible,onClose:it.close,loading:D||Y,maxWidth:"sm",fullWidth:!0,fullHeight:!0,...J})}ct.Provider=O,ct.Context=$,ct.useContext=A,ct.List=N,ct.Modal=K,ct.useVariantActivity=H;function ct(D){return(0,t.jsx)(ct.Provider,{...D,children:(0,t.jsx)(ct.Modal,{children:(0,t.jsx)(ct.List,{})})})}const z=ct;function nt({product:D,loading:J,hidden:it,disabled:Y,...dt}){const mt=z.useVariantActivity({productId:D?.id}),{hasDisabledVariants:At}=mt,pt=(0,v.I)(zt=>D?.type==="swatch"?zt.SWATCHES__UPDATE:zt.PRODUCTS__UPDATE),{errorSnackbar:yt}=(0,i.d)(),[p,{isError:E,isSuccess:st,isLoading:Ft}]=l.G.useEditProductMutation(),vt=({checked:zt})=>{const X=D?.id;if(!X)return;const Z={published:!D?.published};D?.published&&(Z.disableVariants=zt),p({productId:X,body:Z})};return(0,n.useEffect)(()=>{E&&yt("Can't edit product!")},[E]),(0,n.useEffect)(()=>{st&&D?.published&&At&&mt.modal.open()},[st]),!D?.id||it?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.A,{checked:!!D?.published,loading:Ft||J,disabled:Y||!pt,confirmProps:{defaultChecked:!0,onOk:vt,title:D?.published?"Unpublish Product?":"Publish Product?",children:({checked:zt,setChecked:X})=>(0,t.jsx)(h.A,{label:"Disable product variants?",hidden:!D?.published,checked:zt,onChange:X})},confirmOnClick:!0,...dt}),(0,t.jsx)(z,{...mt})]})}const b=nt},69518(re,et,e){e.d(et,{A:()=>v});var t=e(74848),n=e(96540),o=e(11397),h=e(62456);function i({product:d,maxWidth:c,maxHeight:P,containerSx:C,sx:r,size:l="small",...G}){const[H,$]=(0,n.useState)(!1),O={small:{width:30,height:30},medium:{width:40,height:40},large:{width:50,height:50}},A=c||O[l].width,q=P||O[l].height,K=l==="small"&&d?.image?.sizes?.small?d.image.sizes.small:d?.previewImgSrc?d.previewImgSrc:null;return(0,t.jsxs)(t.Fragment,{children:[K&&(0,t.jsx)(o.A,{src:K,maxHeight:q,maxWidth:A,containerSx:[{width:A,height:q,position:"relative"},...Array.isArray(C)?C:[C]],sx:[{marginInline:"auto",border:"transparent"},...Array.isArray(r)?r:[r]],onLoad:()=>$(!0),onError:()=>$(!1),placeholder:(0,t.jsx)(h.A,{sx:{width:A,height:q,position:"absolute",top:0,left:0,opacity:H?0:1,transition:H?"opacity 0.2s ease":"none"}}),skipLazyLoad:!0,...G}),!K&&(0,t.jsx)(h.A,{sx:{width:A,height:q}})]})}const v=i},87358(re,et,e){e.d(et,{A:()=>l});var t=e(74848),n=e(96540),o=e(74722),h=e(61774),i=e(2454),v=e(22552),d=e(27354),c=e(87164),P=e(69554),C=e(51161);function r({loading:G,onChange:H,onlyManually:$=!1,...O}){const{useProductCategoriesQuery:A}=v.G,{isLoading:q}=A({limit:0}),N=(0,i.G)(d.$Y),K=(0,i.G)(d.CM),ct=(0,n.useMemo)(()=>(0,C._)(N,{field:"id"}),[N]);return(0,t.jsx)(h.A,{options:ct,onChange:H,getOptionLabel:z=>K?.[z]?.title??"",renderOption:(z,nt)=>{const b=K?.[nt]?.title;if(b&&!($&&K?.[nt]?.is_auto_assign_products))return(0,n.createElement)(c.A,{component:"li",...z,key:z?.key},b)},renderTags:(z,nt)=>(0,o.A)(z,(b,D)=>{const J=K?.[b];if(!J?.title||$&&J.is_auto_assign_products)return;const{key:it,...Y}=nt({index:D});return(0,t.jsx)(P.A,{label:J.title,...Y},it)}),loading:q||G,...O})}const l=r},80756(re,et,e){e.d(et,{A:()=>I,l:()=>jt});var t=e(74848),n=e(74722),o=e(96540),h=e(24401),i=e(20588),v=e(34867),d=e(30517),c=e(88489);function P({brandPartners:g,form:V,...ht}){const at=(0,i.FH)({control:V.control,name:"mill_yarns"}),y=(0,o.useMemo)(()=>(0,n.A)(at,_=>_?.mill_yarn),[at]);return(0,t.jsxs)(i.Ay,{form:V,...ht,children:[(0,t.jsx)(v.A,{label:"Brand Partners",value:g,helperText:`
7                    All inventories below will include
8                    inventories for these Brand Partners
9                `,multiple:!0,readOnly:!0}),(0,t.jsx)(h.A,{label:"Mill Yarns",children:(0,t.jsx)(d.A,{name:"mill_yarns",control:V.control,brandPartnerId:g})}),(0,t.jsx)(c.Ay,{millYarnIds:y,brandPartnerId:g,name:"colorways",control:V.control,form:V,canAddColorway:!0})]})}const C=P;var r=e(39241),l=e(31782);const G=l.Nc.object().shape({mill_yarns:d.i,colorways:(0,c.SV)()});function H({values:g,...V}){return{form:(0,i.mN)({...V,mode:"onChange",resolver:(0,l.L2)(G),values:{colorways:[[{}]],mill_yarns:[{}],...g}})}}function $(){const{setOnSave:g,toNextStep:V,product:ht,setEdited:at,setFormValues:y,formValues:_}=I.useContext(),{form:Pt}=H({values:_?.colorStep}),ee=()=>{Pt.handleSubmit(()=>V())()};return(0,o.useEffect)(()=>{at(Pt.formState.isDirty)},[Pt.formState.isDirty]),(0,o.useEffect)(()=>(g(()=>ee),()=>{y(fe=>({...fe,colorStep:Pt.getValues()}))}),[]),{form:Pt,brandPartners:(0,r.A)(ht?.brand_partners)}}O.useColorStep=$,O.useColorStepForm=H,O.Form=C;function O(g){const V=$();return(0,t.jsx)(C,{...g,...V})}const A=O;var q=e(24978);function N(){const{currentStep:g,availableSteps:V}=I.useContext(),at={[V.details.value]:I.ProductStep,[V.color.value]:I.ColorStep,[V.size.value]:I.SizeStep}?.[g?.value]||q.A;return(0,t.jsx)(at,{})}const K=N;var ct=e(89610),z=e(42985),nt=e(2454),b=e(49497),D=e(22552),J=e(27354);function it({onOpen:g,onClose:V,onProductCreate:ht,defaultValues:at,deleteOnClose:y=!1,defaultProductId:_}={}){const[Pt,ee]=(0,o.useState)(),[fe,me]=(0,o.useState)(0),[Be,Le]=(0,o.useState)(!1),[ze,Ve]=(0,o.useState)(!1),[le,pe]=(0,o.useState)(),[Ne,Oe]=(0,o.useState)({});(0,o.useEffect)(()=>{_&&(ee(_),me(1))},[_]);const Qe=(0,b.I)(Rt=>Rt.PRODUCTS__CREATE),Ye=z.Ay.useModal({canOpen:Qe}),{visible:Ze}=Ye,qe=J.Ql,_e=(0,o.useMemo)(()=>Object.values(qe),[]),tn=_e[fe],ye=(0,o.useMemo)(()=>({productId:Pt}),[Pt]),Ae=(0,nt.G)(Rt=>(0,J.qM)(Rt,ye)),S=(0,nt.G)(Rt=>(0,J._k)(Rt,ye)),{useDeleteProductMutation:R}=D.G,[ft]=R(),rt=Rt=>{me(Rt),Ve(!1)},Mt=()=>rt(Rt=>Rt+1),Ht=()=>rt(Rt=>Rt-1),Qt=()=>fe+1>=_e.length,se=()=>fe<=0,wt=()=>{ee(void 0),Le(!1),me(0),pe(void 0),Ve(!1),Oe({}),Ye.reset()},Jt=()=>{(0,ct.A)(g)&&g(),Ve(!1),_&&(ee(_),me(1)),Ye.open()},Te=()=>{(0,ct.A)(V)&&V(),Ye.close(),wt()},Xt=()=>{Pt&&y&&ft(Pt)},De=(0,o.useMemo)(()=>({...at,productStep:S||at?.productStep,...Ne}),[at,Ne,S]);return{deleteOnClose:y,productId:Pt,setProductId:ee,stepKey:fe,loading:Be,setLoading:Le,edited:ze,setEdited:Ve,onSave:le,setOnSave:pe,product:Ae,currentStep:tn,availableSteps:qe,steps:_e,toNextStep:Mt,open:Jt,close:Te,isOnLastStep:Qt,toPrevStep:Ht,isOnFirstStep:se,visible:Ze,onProductCreate:ht,reset:wt,canOpen:Qe,defaultValues:at,onConfirmClose:Xt,setFormValues:Oe,setStepKey:rt,formValues:De}}var Y=e(46942),dt=e.n(Y),mt=e(21548);function At({className:g,loading:V,...ht}){const{close:at,visible:y,edited:_,productId:Pt,onConfirmClose:ee,reset:fe,deleteOnClose:me,loading:Be}=I.useContext(),Le=dt()("ProductCreateModal",g);return(0,t.jsx)(z.Ay,{confirmOnClose:_||!!Pt,title:(0,t.jsx)(I.Steps,{}),open:y,onClose:at,className:Le,onTransitionExited:fe,maxWidth:"sm",loading:Be||V,confirmProps:{onOk:ee,children:Pt?(0,r.A)(["You haven't finished product creation",me&&" and it will be deleted","!"]).join(""):(0,t.jsx)(mt.A.Message.UnsavedLost,{})},actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(I.PrevStepButton,{}),(0,t.jsx)(I.SaveButton,{})]}),fullWidth:!0,fullHeight:!0,...ht})}const pt=At;var yt=e(11201),p=e(99682);function E({children:g,className:V,hidden:ht,...at}){const{open:y,close:_,visible:Pt,canOpen:ee}=I.useContext();if((0,ct.A)(g))return g({open:y,close:_,visible:Pt});const fe=dt()("ProductCreate__OpenButton",V);return(0,t.jsx)(yt.A,{onClick:y,className:fe,variant:"contained",color:"primary",startIcon:(0,t.jsx)(p.A,{}),hidden:ht||!ee,...at,children:g})}const st=E;var Ft=e(66106);function vt({children:g,...V}){const{isOnFirstStep:ht,toPrevStep:at}=I.useContext();return(0,t.jsx)(yt.A,{onClick:at,hidden:ht(),variant:"outlined",size:"large",startIcon:(0,t.jsx)(Ft.A,{}
9),fullWidth:!0,uppercase:!0,...V,children:g??"Prev Step"})}const zt=vt,X=(0,o.createContext)({});function It({children:g,...V}){return(0,t.jsx)(X.Provider,{value:V,children:g})}function Z(){return(0,o.useContext)(X)}var W=e(21879),U=e(24198),lt=e(4855);const T=l.Nc.object().shape({gender:l.Nc.array().of(l.Nc.string().trim().required()),details:l.Nc.array().of(l.Nc.string().trim().required()),silhouette:l.Nc.array().of(l.Nc.string().trim().required()),stitch_structure:l.Nc.array().of(l.Nc.string().trim().required()),search_keywords:l.Nc.array().of(l.Nc.string().trim().required())}),xt=l.Nc.object().shape({name:l.Nc.string().trim().required(),sku:l.Nc.string().trim().required(),description:l.Nc.string().trim().required(),gauge:l.Nc.string().trim().required(),groups:l.Nc.array().of(l.Nc.string().required()),phases:l.Nc.array().of(l.Nc.string().required()).min(1).required(),images:l.Nc.array().of(l.Nc.string().required()).min(1).required(),brand_partners:l.Nc.array().of(l.Nc.string().required()),published:l.Nc.boolean().required(),tags:T,is_stk:l.Nc.boolean().required(),exclude_from_best_sellers:l.Nc.boolean().required(),request_id:l.Nc.mixed(),xfty_days:l.Nc.number().typeError("Required").required().positive(),knit_by_days:l.Nc.number().typeError("Required").required().positive().when(["xfty_days"],([g],V)=>(0,W.A)(g)?V.lessThan(g,`Knit by days must not exceed XFTY days (${g||0})`):V)});function jt({values:g,...V}={}){const ht=(0,nt.G)(J.oB),at=(0,nt.G)(U.J9);return{form:(0,i.mN)({...V,mode:"onChange",resolver:(0,l.L2)(xt),values:{groups:(0,r.A)([ht?.id]),brand_partners:[],xfty_days:6,is_stk:!1,published:!1,exclude_from_best_sellers:!1,knit_by_days:3,phases:at,tags:{silhouette:[],gender:[],stitch_structure:[],details:[],search_keywords:[]},...g}})}}var Tt=e(72682);function Gt(){const{setOnSave:g,productId:V,setProductId:ht,toNextStep:at,onProductCreate:y,setEdited:_,formValues:Pt,setLoading:ee}=I.useContext(),[fe,{isLoading:me,isSuccess:Be,data:Le,error:ze}]=D.G.useCreateProductMutation(),[Ve,{isLoading:le,isSuccess:pe,error:Ne}]=D.G.useEditProductMutation(),Oe=(0,o.useMemo)(()=>V?(0,Tt.v)(Ne):(0,Tt.v)(ze),[V,ze,Ne]),Qe=()=>{Ye.handleSubmit(Ze=>V?Ve({productId:V,body:Ze}):fe({body:Ze}))()},{form:Ye}=jt({values:Pt?.productStep,errors:Oe});return(0,o.useEffect)(()=>{Be&&(ht(Le?.product?._id),(0,ct.A)(y)&&y(),at())},[Be,Le]),(0,o.useEffect)(()=>{pe&&at()},[pe]),(0,o.useEffect)(()=>{_(Ye.formState.isDirty)},[Ye.formState.isDirty]),(0,o.useEffect)(()=>{ee(me||le)},[me,le]),(0,o.useEffect)(()=>{g(()=>Qe)},[]),{form:Ye,error:ze||Ne}}var Yt=e(42531),ne=e(87083),te=e(75893),Lt=e(70824),tt=e(57939),Vt=e(50273),Dt=e(87358);function Et({form:g,galleryTags:V,...ht}){const at=(0,nt.G)(U.J9);return(0,t.jsxs)(i.Ay,{...ht,children:[(0,t.jsx)(i.Ay.Input,{name:"name",label:"Style name",control:g.control,required:!0}),(0,t.jsx)(i.Ay.Input,{name:"sku",label:"SKU",control:g.control,required:!0}),(0,t.jsx)(i.Ay.Item,{name:"groups",control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(Dt.A,{error:_.invalid,label:"Groups",inputRef:y.ref,helperText:_.error?.message,onlyManually:!0,multiple:!0,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Item,{name:"brand_partners",control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(v.A,{error:_.invalid,label:"Brand Partners",inputRef:y.ref,helperText:_.error?.message,multiple:!0,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Switch,{name:"published",label:"Published",control:g.control,helperText:"Available for Brand Partners"}),(0,t.jsx)(i.Ay.Switch,{name:"is_stk",label:"STK",control:g.control,helperText:"Available in Silhouette Tookit"}),(0,t.jsx)(i.Ay.Switch,{name:"exclude_from_best_sellers",label:"Exclude from best sellers",control:g.control,helperText:"Won't appear in the Best Sellers category"}),(0,t.jsx)(i.Ay.Input,{name:"description",label:"Description",control:g.control,multiline:!0,required:!0}),(0,t.jsx)(i.Ay.Item,{name:"gauge",control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(te.A,{fieldKey:"gauge",error:_.invalid,inputRef:y.ref,label:"Gauge",helperText:_.error?.message,required:!0,...y,ref:void 0})}),(0,t.jsx)(i.Ay.InputMeasure,{name:"xfty_days",label:"XFTY",measureUnitKey:"day",control:g.control,onChange:()=>{g.trigger("knit_by_days")},required:!0}),(0,t.jsx)(i.Ay.InputMeasure,{name:"knit_by_days",measureUnitKey:"day",control:g.control,label:"Knit by",required:!0}),(0,t.jsx)(i.Ay.Images,{name:"images",control:g.control,label:"Photos",initialTags:V??[tt.b.PRODUCT],required:!0}),(0,t.jsx)(i.Ay.Item,{name:`tags.${Lt.f.DETAILS_TAGS}`,control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(ne.A.Details,{error:_.invalid,label:"Details tags",inputRef:y.ref,helperText:_.error?.message,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Item,{name:`tags.${Lt.f.SILHOUETTE_TAGS}`,control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(ne.A.Silhouette,{error:_.invalid,inputRef:y.ref,label:"Silhouette tags",helperText:_.error?.message,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Item,{name:`tags.${Lt.f.STITCH_STRUCTURE_TAGS}`,control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(ne.A.StitchStructure,{error:_.invalid,label:"Stitch structure tags",inputRef:y.ref,helperText:_.error?.message,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Item,{name:`tags.${Lt.f.GENDER_TAGS}`,control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(ne.A.Gender,{error:_.invalid,label:"Gender tags",inputRef:y.ref,helperText:_.error?.message,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Item,{name:`tags.${Lt.f.SEARCH_KEYWORD_TAGS}`,control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(ne.A.SearchKeywords,{error:_.invalid,label:"Search keywords",inputRef:y.ref,helperText:_.error?.message,...y,ref:void 0})}),(0,t.jsx)(i.Ay.Item,{name:"phases",control:g.control,render:({field:y,fieldState:_})=>(0,t.jsx)(Vt.A,{error:_.invalid,label:"Phases",helperText:_.error?.message,inputRef:y.ref,getOptionDisabled:Pt=>(0,Yt.A)(at,Pt),disableClearable:!0,required:!0,multiple:!0,...y,ref:void 0})})]})}const Wt=Et;Nt.useProductStep=Gt,Nt.Form=Wt;function Nt(g){const{form:V,error:ht}=Gt();return(0,t.jsx)(Wt,{form:V,error:ht,...g})}const $t=Nt;var he=e(13834),Se=e(73328);function k(g){const{isOnLastStep:V,onSave:ht}=I.useContext();return(0,t.jsx)(yt.A,{size:"large",onClick:ht,variant:"contained",endIcon:V()?(0,t.jsx)(Se.A,{}):(0,t.jsx)(he.A,{}
9),fullWidth:!0,uppercase:!0,...g,children:V()?"Save and Open Product":"Next Step"})}const St=k;var qt=e(427),Kt=e(76429),gt=e(9559),j=e(16394),m=e(13689),u=e(30251),f=e(69610);function L({sizeIsDisabled:g,name:V,onlyOS:ht,...at}){const y=(0,i.xW)(),_=(0,i.FH)({name:V,control:y.control}),Pt=(0,o.useMemo)(()=>(0,n.A)(_,"size_id"),[_]),ee=(0,nt.G)(u.LR),fe=()=>!ht&&!g?!0:(_?.length||0)<1,me=ze=>{const Ve=_?.[ze]?.size_id;return(Ve?ee[Ve]?.name:void 0)||"New Size"},Be=ze=>{const Ve=_?.[ze]?.size_id,le=Ve?ee[Ve]?.name:void 0;return(0,r.A)(["Add inventory",le&&"for",le]).join(" ")},Le=ze=>Pt.includes(ze);return(0,t.jsx)(i.Ay.List,{name:V,control:y.control,render:({fields:ze,append:Ve,remove:le})=>(0,t.jsxs)(t.Fragment,{children:[(0,n.A)(ze,(pe,Ne)=>(0,t.jsxs)(h.A,{label:me(Ne),children:[(0,t.jsxs)(i.Ay.List.Item,{children:[(0,t.jsx)(i.Ay.Item,{name:`${V}.${Ne}.size_id`,render:({field:Oe,fieldState:Qe})=>(0,t.jsx)(m.A,{onlyOS:ht,error:Qe.invalid,label:"Size",helperText:Qe.error?.message,disabled:g,getOptionDisabled:Le,inputRef:Oe.ref,disableClearable:!0,fullWidth:!0,required:!0,...Oe})}),!ht&&(0,t.jsx)(j.A,{onClick:()=>le(Ne),disabled:g})]}),(0,t.jsx)(f.A,{name:`${V}.${Ne}.inventory`,showTitles:!1,buttonLabel:Be(Ne)})]},pe.id)),(0,t.jsx)(i.Ay.List.Button,{onClick:()=>Ve({size_id:"",inventory:[]}),hidden:!fe(),disabled:!!_?.length&&!_[_.length-1]?.size_id,children:"Add size"})]}),...at})}const a=l.Nc.object().shape({size_id:l.Nc.string().required(),inventory:f.g}),M=l.Nc.array().of(a),ot=L;function Ct({sizeIsDisabled:g,onlyOS:V,...ht}){return(0,t.jsxs)(i.Ay,{...ht,children:[(0,t.jsx)(h.A,{label:"Common trims & labels",helperText:`
10                    These inventories will be attached to the all sizes.
11                    If there are sizes with special inventories
12                    you can complement those sizes below.
13                `,children:(0,t.jsx)(f.A,{name:"inventory",showTitles:!1})}),(0,t.jsx)(ot,{name:"sizes",onlyOS:V,sizeIsDisabled:g})]})}const ut=Ct,oe=l.Nc.object().shape({inventory:f.g,sizes:M.min(1).required()});function Ut({values:g,...V}){return{form:(0,i.mN)({...V,mode:"onChange",resolver:(0,l.L2)(oe),values:{inventory:[{quantity:1}],sizes:[{}],...g}})}}function bt(){const{productId:g,setOnSave:V,close:ht,setEdited:at,setLoading:y,formValues:_,setFormValues:Pt}=I.useContext(),ee=(0,qt.A)(),{savedSnackbar:fe}=(0,Kt.d)(),{useCreateVariantsMutation:me}=D.G,[Be,{error:Le,isSuccess:ze,isLoading:Ve}]=me(),le=(0,o.useMemo)(()=>(0,Tt.v)(Le),[Le]),{form:pe}=Ut({values:_?.sizeStep,errors:le}),Ne=(0,o.useCallback)(()=>{pe.handleSubmit((Oe=>{const Qe={..._?.colorStep,...Oe};g&&Be({productId:g,body:Qe})}))()},[_]);return(0,o.useEffect)(()=>{ze&&((0,ct.A)(ht)&&ht(),fe(),g&&ee.redirect(gt.Ay.productDetails(g)))},[ze]),(0,o.useEffect)(()=>{at(pe.formState.isDirty)},[pe.formState.isDirty]),(0,o.useEffect)(()=>{y(Ve)},[Ve]),(0,o.useEffect)(()=>{V(()=>Ne)},[Ne]),(0,o.useEffect)(()=>()=>{Pt(Oe=>({...Oe,sizeStep:pe.getValues()}))},[]),{form:pe,error:Le}}de.useSizeStep=bt,de.useSizeStepForm=Ut,de.Form=ut;function de(g){const V=bt();return(0,t.jsx)(ut,{...g,...V})}const Pe=de;var xe=e(79595),Fe=e(82997),ie=e(17854);function Bt(){const{steps:g,stepKey:V,setStepKey:ht}=I.useContext();return(0,t.jsx)(xe.A,{activeStep:V,sx:{width:"100%"},nonLinear:!0,children:(0,n.A)(g,(at,y)=>(0,t.jsx)(Fe.A,{completed:y<V,children:(0,t.jsx)(ie.A,{disabled:y>V,onClick:()=>ht(y),children:at?.label})},y))})}const B=Bt;x.useContext=Z,x.Context=X,x.Provider=It,x.Steps=B,x.SaveButton=St,x.Modal=pt,x.OpenButton=st,x.useProductCreate=it,x.ProductStep=$t,x.ColorStep=A,x.SizeStep=Pe,x.CurrentStep=K,x.PrevStepButton=zt;function x({onOpen:g,onClose:V,defaultValues:ht,onProductCreate:at,deleteOnClose:y,defaultProductId:_,...Pt}){const ee=it({onOpen:g,onClose:V,defaultValues:ht,onProductCreate:at,deleteOnClose:y,defaultProductId:_});return(0,t.jsxs)(It,{...ee,children:[(0,t.jsx)(st,{...Pt}),(0,t.jsx)(pt,{children:(0,t.jsx)(K,{})})]})}const I=x},95486(re,et,e){e.d(et,{A:()=>r});var t=e(74848),n=e(89610),o=e(96540),h=e(11201),i=e(21548),v=e(76429),d=e(49497),c=e(22552),P=e(18342);function C({product:l,onSuccess:G,hidden:H,...$}){const[O,{isLoading:A,isSuccess:q,isError:N}]=c.G.useDeleteProductMutation(),{errorSnackbar:K,savedSnackbar:ct}=(0,v.d)(),z=()=>{if(nt)return O(l?.id)},nt=(0,d.I)(b=>l?.type==="swatch"?b.SWATCHES__DELETE:b.PRODUCTS__DELETE);return(0,o.useEffect)(()=>{q&&(ct("Product deleted!"),(0,n.A)(G)&&G())},[q]),(0,o.useEffect)(()=>{N&&K("Could not delete product!")},[N]),(0,t.jsx)(h.A,{onClick:z,loading:A,hidden:H||!l?.id||!nt,startIcon:(0,t.jsx)(P.A,{}),confirmProps:{title:"Delete product?",children:(0,t.jsx)(i.A.Message.EntityDelete,{entityLabel:"Product"})},color:"error",confirmOnClick:!0,...$})}const r=C},98761(re,et,e){e.d(et,{A:()=>vn});var t=e(74848),n=e(96540),o=e(36197),h=e(2454),i=e(23841),v=e(49497),d=e(65804),c=e(22552),P=e(27354);function C({productId:s,route:F,backRoute:Q,showDeleteButton:w=!1}){const _t=(0,v.I)(yn=>yn.PRODUCTS__READ),ce=(0,o.b)({route:F,backRoute:Q,canOpen:_t}
13),[je,We]=(0,n.useState)("details"),Me=(0,n.useMemo)(()=>({productId:s}),[s]),Ue=(0,h.G)(yn=>(0,P.qM)(yn,Me)),we=(0,h.G)(yn=>(0,P.a5)(yn,Me)),{useProductQuery:He}=c.G,{isFetching:xn}=He({productId:s},{skip:!s||!ce.visible}),{isLoading:Ke}=i.h.useValuesQuery(void 0,{skip:!s||!ce.visible}),{isLoading:sn}=d.p.useInventoryFormDataQuery(void 0,{skip:!s||!ce.visible}),on=()=>{We("variants")},an=(0,n.useCallback)(()=>{We("details")},[]);return{product:Ue,drawer:ce,productId:s,canOpen:_t,loading:xn||Ke||sn,reset:an,onCreateVariants:on,productVariantsQty:we,activeTabKey:je,setActiveTabKey:We,showDeleteButton:w}}var r=e(11201);function l({hidden:s,disabled:F,...Q}){const{drawer:w,productId:_t,canOpen:ce}=vn.useContext();return(0,t.jsx)(r.A.Open,{onClick:ce?w.open:void 0,hidden:s||!_t,disabled:F||!ce,disabledMessage:ce?void 0:"Access Denied",...Q})}const G=(0,n.createContext)({});function H({children:s,...F}){return(0,t.jsx)(G.Provider,{value:F,children:s})}function $(){return(0,n.useContext)(G)}var O=e(61230),A=e(21568),q=e(95486),N=e(72682),K=e(42985),ct=e(76429),z=e(80756);function nt({productId:s,...F}){const Q=(0,n.useMemo)(()=>({productId:s}),[s]),w=(0,h.G)(_t=>(0,P._k)(_t,Q));return(0,z.l)({values:w,...F})}function b({productId:s}){const F=(0,v.I)(an=>an.PRODUCTS__UPDATE),Q=(0,K.hS)({canOpen:F}),{savedSnackbar:w}=(0,ct.d)(),_t=(0,n.useMemo)(()=>({productId:s}),[s]),ce=(0,h.G)(an=>(0,P.qM)(an,_t)),{useEditProductMutation:je}=c.G,[We,{isSuccess:Me,error:Ue,isLoading:we,reset:He}]=je(),xn=(0,n.useMemo)(()=>(0,N.v)(Ue),[Ue]),{form:Ke}=nt({productId:s,errors:xn}),sn=Ke.handleSubmit(an=>{s&&We({productId:s,body:an})}),on=(0,n.useCallback)(()=>{Ke.reset(),He()},[He]);return(0,n.useEffect)(()=>{Me&&(w(),Q.close())},[Me]),{productId:s,modal:Q,error:Ue,onSubmit:sn,reset:on,product:ce,form:Ke,canOpen:F,loading:we}}var D=e(70739);function J({hidden:s,...F}){const{modal:Q,productId:w,canOpen:_t}=Ft.useContext();return(0,t.jsx)(r.A,{onClick:Q.open,startIcon:(0,t.jsx)(D.A,{}),hidden:!w||s||!_t,variant:"contained",color:"primary",...F})}const it=(0,n.createContext)({});function Y({children:s,...F}){return(0,t.jsx)(it.Provider,{value:F,children:s})}function dt(){return(0,n.useContext)(it)}var mt=e(21548),At=e(20588);function pt({loading:s,...F}){const{modal:Q,reset:w,form:_t,onSubmit:ce,loading:je}=Ft.useContext();return(0,t.jsx)(K.Ay,{confirmOnClose:_t.formState.isDirty,title:"Edit Product",open:Q.visible,onClose:Q.close,onTransitionExited:w,maxWidth:"sm",loading:je||s,confirmProps:{children:(0,t.jsx)(mt.A.Message.UnsavedLost,{})},actions:(0,t.jsx)(At.Ay.Submit,{onClick:()=>ce(),children:"Save"}),fullWidth:!0,...F})}var yt=e(39241);p.View=z.A.ProductStep.Form;function p(s){const{form:F,error:Q,product:w}=Ft.useContext();return(0,t.jsx)(z.A.ProductStep.Form,{form:F,error:Q,galleryTags:(0,yt.A)([w?.name]),...s})}const E=p;st.Context=it,st.Provider=Y,st.useContext=dt,st.Form=E,st.Button=J,st.Modal=pt;function st({productId:s,...F}){const Q=b({productId:s});return(0,t.jsxs)(st.Provider,{...Q,children:[(0,t.jsx)(st.Modal,{children:(0,t.jsx)(st.Form,{})}),(0,t.jsx)(J,{...F})]})}const Ft=st;var vt=e(8058),zt=e(74722),X=e(4855),It=e(99041),Z=e(44251),W=e(12933);function U({product:s,hidden:F,loading:Q,...w}){const _t=(0,v.I)(He=>He.PRODUCTS__UPDATE),ce=s?.request_id,{isFetching:je}=It.Yp.useRequestQuery({requestId:ce||""},{skip:!ce}),We=(0,n.useMemo)(()=>({techPackId:ce}),[ce]),Me=(0,h.G)(He=>(0,Z.QF)(He,We)),Ue=(0,n.useMemo)(()=>!!(F||!s||!_t||s?.state===X.ix.COMPLETED),[F,s?.state]),we=(0,n.useMemo)(()=>{if(!Me?.id||Ue)return;const He=[],xn=Me?.mill_yarns?.length||0;return(0,vt.A)(Me?.colorwayList,Ke=>{const sn=[];(0,vt.A)(Ke?.colorway,(on,an)=>{on?.yarnId&&(an>=xn||sn.push({yarn:on?.yarnId,lycra:(0,yt.A)(on?.lycraIds)}))}),sn.length&&He.push(sn)}),{colorStep:{colorways:He,mill_yarns:Me?.mill_yarns},sizeStep:{sizes:(0,zt.A)((0,yt.A)(Me?.sizes),Ke=>({size_id:Ke,inventory:[]})),inventory:(0,zt.A)(Me?.trimIds,Ke=>({item:Ke,quantity:1}))}}},[Me]);return i.h.useColorsQuery(void 0,{skip:Ue}),d.p.useInventoryFormDataQuery(void 0,{skip:Ue}),(0,t.jsx)(z.A,{startIcon:(0,t.jsx)(W.A,{}),defaultProductId:s?.id,defaultValues:we,loading:Q||je,disabled:Q||je,hidden:Ue,...w,children:"Finish setup"})}const lt=U;var T=e(9450),xt=e(64415),jt=e(49785),Tt=e(19431),Gt=e(92866),Yt=e(31782);const ne=Yt.Nc.object().shape({type:Yt.Nc.string().oneOf((0,Gt.A)(X.wV)).required(),position:Yt.Nc.number().positive().required(),quantity:Yt.Nc.number().positive().required()});function te({values:s,...F}={}){return{form:(0,At.mN)({...F,values:{type:X.wV.SHOWROOM,position:1,quantity:1,...s},resolver:(0,Yt.L2)(ne)})}}function Lt({productId:s,defaultValues:F}){const Q=(0,K.hS)(),w=Tt.A.useDrawer(),{form:_t}=te({values:F}),ce=_t.handleSubmit(Me=>{s&&Me&&w.open()}),je=(0,n.useCallback)(()=>_t?.reset(),[]),We=(0,jt.FH)({control:_t.control,name:"type"});return{onSubmit:ce,modal:Q,form:_t,productId:s,fileViewerDrawer:w,reset:je,type:We}}var tt=e(20821);function Vt(s){const{modal:F}=de.useContext();return(0,t.jsx)(r.A,{onClick:F.open,startIcon:(0,t.jsx)(tt.A,{}),color:"primary",variant:"contained",...s})}const Dt=(0,n.createContext)({});function Et({children:s,...F}){return(0,t.jsx)(Dt.Provider,{value:F,children:s})}function Wt(){return(0,n.useContext)(Dt)}var Nt=e(25563);function $t(s){const{modal:F,onSubmit:Q,form:w,reset:_t}=de.useContext();
13return(0,t.jsx)(K.Ay,{title:"Product Stickers",open:F.visible,onClose:F.close,onTransitionExited:_t,maxWidth:"xs",actions:(0,t.jsx)(At.Ay.Submit,{onClick:Q,startIcon:(0,t.jsx)(Nt.A,{}),children:"Generate"}),confirmOnClose:w.formState.isDirty,confirmProps:{children:(0,t.jsx)(mt.A.Message.UnsavedLost,{})},fullWidth:!0,...s})}function he(){const{productId:s,fileViewerDrawer:F,form:Q,type:w,modal:_t}=de.useContext(),[ce]=c.G.useStreamProductStickersMutation(),je=()=>w&&P.Uh[w]?`${P.Uh[w]} Stickers`:"Stickers",We=()=>{const Me=Q.getValues();if(!(!s||!Me))return new Promise((Ue,we)=>{ce({productId:s,quantity:Me.quantity||1,type:Me.type,position:Me.position,onSuccess:Ue}).catch(we)})};return(0,t.jsx)(Tt.A,{fileSrc:We,fileName:je(),open:F.visible,onClose:F.close,onTransitionExited:_t.close})}var Se=e(24401),k=e(84957),St=e(27422),qt=e(12486);function Kt(s){const F=(0,n.useMemo)(()=>(0,St.A)(P.Uh),[]);return(0,t.jsx)(qt.A,{options:F,label:"Sticker Type",getOptionLabel:Q=>P.Uh?.[Q]||"",...s})}const gt=Kt;var j=e(87164),m=e(11848),u,f,L;function a(){return a=Object.assign?Object.assign.bind():function(s){for(var F=1;F<arguments.length;F++){var Q=arguments[F];for(var w in Q)({}).hasOwnProperty.call(Q,w)&&(s[w]=Q[w])}return s},a.apply(null,arguments)}const ot=s=>n.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 3300 2550"},s),u||(u=n.createElement("path",{d:"M194.2 47c-9.7 2.6-17.9 7.1-25.6 14.1-8.2 7.5-13.2 15.1-17 25.9l-3.1 8.5-.3 547.5c-.2 496.5-.1 548.2 1.3 555.4 4.8 23.7 22.1 42.1 45.2 48 5.5 1.5 30.8 1.6 257.5 1.4l251.3-.3 6.5-2.3c17.6-6.4 33.5-22.1 38.1-37.8.7-2.4 1.6-4.4 1.9-4.4s1.2 2 1.9 4.4c4.6 15.7 20.5 31.4 38.1 37.8l6.5 2.3h507l6.5-2.3c17.6-6.4 33.5-22.1 38.1-37.8.7-2.4 1.6-4.4 1.9-4.4s1.2 2 1.9 4.4c4.6 15.7 20.5 31.4 38.1 37.8l6.5 2.3h507l6.5-2.3c17.6-6.4 33.5-22.1 38.1-37.8.7-2.4 1.6-4.4 1.9-4.4s1.2 2 1.9 4.4c4.6 15.7 20.5 31.4 38.1 37.8l6.5 2.3h507l6.5-2.3c17.6-6.4 33.5-22.1 38.1-37.8.7-2.4 1.6-4.4 1.9-4.4s1.2 2 1.9 4.4c4.6 15.7 20.5 31.4 38.1 37.8l6.5 2.3 251.3.3c226.7.2 252 .1 257.5-1.4 23.1-5.9 40.4-24.3 45.2-48 1.4-7.2 1.5-58.9 1.3-555.4l-.3-547.5-3.1-8.5c-3.8-10.8-8.8-18.4-17-25.9-7.8-7.2-15.9-11.5-26-14.1-7.6-2-12-2-255.4-2s-247.8 0-255.4 2c-4.3 1.1-10.4 3.4-13.7 5.1-12.2 6.5-24.4 20.4-28.4 32.4-1.1 3-2.2 5.5-2.5 5.5s-1.4-2.5-2.5-5.5c-4-12-16.2-25.9-28.4-32.4-3.3-1.7-9.4-4-13.7-5.1-7.6-2-12-2-255.4-2s-247.8 0-255.4 2c-4.3 1.1-10.4 3.4-13.7 5.1-12.2 6.5-24.4 20.4-28.4 32.4-1.1 3-2.2 5.5-2.5 5.5s-1.4-2.5-2.5-5.5c-4-12-16.2-25.9-28.4-32.4-3.3-1.7-9.4-4-13.7-5.1-7.6-2-12-2-255.4-2s-247.8 0-255.4 2c-4.3 1.1-10.4 3.4-13.7 5.1-12.2 6.5-24.4 20.4-28.4 32.4-1.1 3-2.2 5.5-2.5 5.5s-1.4-2.5-2.5-5.5c-4-12-16.2-25.9-28.4-32.4-3.3-1.7-9.4-4-13.7-5.1-7.6-2-12-2-255.4-2s-247.8 0-255.4 2c-4.3 1.1-10.4 3.4-13.7 5.1-12.2 6.5-24.4 20.4-28.4 32.4-1.1 3-2.2 5.5-2.5 5.5s-1.4-2.5-2.5-5.5c-4-12-16.2-25.9-28.4-32.4-3.3-1.7-9.4-4-13.7-5.1-7.6-2-11.9-2-255.8-1.9-241 0-248.3.1-255.4 1.9M705 50.2c20.7 6.5 36.8 23.1 41.5 42.9 1.3 5.7 1.5 69.5 1.5 553.9 0 487-.2 548.2-1.5 553.5-4 15.8-15.3 30-29.5 37.5-14.5 7.5 6 7-267 7-209 0-246.5-.2-252.2-1.5-20.8-4.4-38.9-21.9-44.3-43-1.3-5.3-1.5-66.5-1.5-553.5 0-484.4.2-548.2 1.5-553.9 5.4-22.6 25.1-40.6 48.5-44 3-.5 116.2-.8 251.5-.7 228.7.1 246.4.3 251.5 1.8m600 0c20.7 6.5 36.8 23.1 41.5 42.9 1.3 5.7 1.5 69.5 1.5 553.9 0 487-.2 548.2-1.5 553.5-4 15.8-15.3 30-29.5 37.5-14.5 7.5 6 7-267 7-209 0-246.5-.2-252.2-1.5-20.8-4.4-38.9-21.9-44.3-43-1.3-5.3-1.5-66.5-1.5-553.5 0-484.4.2-548.2 1.5-553.9 5.4-22.6 25.1-40.6 48.5-44 3-.5 116.2-.8 251.5-.7 228.7.1 246.4.3 251.5 1.8m600 0c20.7 6.5 36.8 23.1 41.5 42.9 1.3 5.7 1.5 69.5 1.5 553.9 0 487-.2 548.2-1.5 553.5-4 15.8-15.3 30-29.5 37.5-14.5 7.5 6 7-267 7-209 0-246.5-.2-252.2-1.5-20.8-4.4-38.9-21.9-44.3-43-1.3-5.3-1.5-66.5-1.5-553.5 0-484.4.2-548.2 1.5-553.9 5.4-22.6 25.1-40.6 48.5-44 3-.5 116.2-.8 251.5-.7 228.7.1 246.4.3 251.5 1.8m600 0c20.7 6.5 36.8 23.1 41.5 42.9 1.3 5.7 1.5 69.5 1.5 553.9 0 487-.2 548.2-1.5 553.5-4 15.8-15.3 30-29.5 37.5-14.5 7.5 6 7-267 7-209 0-246.5-.2-252.2-1.5-20.8-4.4-38.9-21.9-44.3-43-1.3-5.3-1.5-66.5-1.5-553.5 0-484.4.2-548.2 1.5-553.9 5.4-22.6 25.1-40.6 48.5-44 3-.5 116.2-.8 251.5-.7 228.7.1 246.4.3 251.5 1.8m600 0c20.7 6.5 36.8 23.1 41.5 42.9 1.3 5.7 1.5 69.5 1.5 553.9 0 487-.2 548.2-1.5 553.5-4 15.8-15.3 30-29.5 37.5-14.5 7.5 6 7-267 7-209 0-246.5-.2-252.2-1.5-20.8-4.4-38.9-21.9-44.3-43-1.3-5.3-1.5-66.5-1.5-553.5 0-484.4.2-548.2 1.5-553.9 5.4-22.6 25.1-40.6 48.5-44 3-.5 116.2-.8 251.5-.7 228.7.1 246.4.3 251.5 1.8"})),f||(f=n.createElement("path",{d:"M428 538.1c-4.7 1.1-9.5 2.1-10.7 2.4-2.2.5-2.3 1-2.3 10 0 9.4 0 9.5 2.3 9 3-.7 21.8-4.5 22.3-4.5.2 0 .4 
1315.7.4 35v34.9l-12.2.3-12.3.3-.3 9.7-.3 9.8h77.2l-.3-9.8-.3-9.7-12.2-.3-12.3-.3V536l-15.2.1c-10.9.1-17.7.7-23.8 2M1044.5 536.6c-5.3.7-13.8 2.5-18.7 4l-4.8 1.6v23.700000000000003l7.8-3.9c13.9-7.2 24.2-8.6 32.8-4.6 9.5 4.4 11.9 14.9 5.9 25.3-1.7 2.7-10.5 11.3-24.5 23.5l-21.9 19.3v10.7l-.1 10.8h79v-21l-23.6-.2-23.7-.3 14.6-12.9c25.8-22.6 30.7-29.2 31.5-42.6.5-8.8-1.8-16.1-6.8-22.2-3.5-4.3-12.8-9-20.8-10.7-4.9-1-19.6-1.3-26.7-.5M1642.9 536.9c-2.5.5-7.1 1.4-10.2 2.1l-5.7 1.1v10.6c0 9.6.1 10.5 1.8 9.8 10.8-4.5 26.6-6.6 34.1-4.5 6.4 1.7 11.1 6.7 11.1 11.6 0 4.8-1.6 8.1-5.3 10.8-2.4 1.7-4.7 2.1-15 2.6l-12.2.5v18l11.5.6c16.5.8 22.5 4.3 23.6 13.6 2 15.5-22.8 21.2-47.8 10.9l-5.8-2.4v21.700000000000003l3.8 1c10 2.7 13.7 3.2 26.2 3.7 16.2.7 24.9-.8 35.7-6.1 8.2-4 12.5-8.9 14.8-16.9 4.5-15-1.7-29.8-14.8-35.2-2.6-1-4.7-2.1-4.7-2.4 0-.4 1.6-1.2 3.6-1.9 4.9-1.8 10.4-6.8 12.5-11.6 2.5-5.5 2.5-15.9 0-21.7-2.6-6.1-9.1-11.4-17.1-14-5.1-1.6-9.6-2.1-21-2.4-8-.1-16.6.1-19.1.5M2250.5 568.2l-21.5 32.3V625h48v20h27v-20h15v-20h-15v-69h-32zm26.5 14.3V605h-15.1c-12.7 0-15-.2-14.6-1.4.8-2.1 28.6-43.6 29.2-43.6.3 0 .5 10.1.5 22.5M2839 566.6c0 28.8.1 30.6 1.8 29.9 8.5-3.6 14.4-4.8 24.2-4.9 12.3-.1 16.7 1.5 20.5 7.3 6.8 10.3 2.3 23.4-9.4 27.6-2.4.8-6.2 1.5-8.6 1.5-5.7 0-18.7-3.4-26.2-7l-6.3-2.9v21.6l4.3 1.6c9.7 3.7 18.2 5.1 31.7 5.1 12.5.1 14.1-.1 21.3-2.8 9.7-3.5 17.3-10.1 21.4-18.4 2.5-5.1 2.8-6.7 2.7-15.7 0-12.3-2.4-19.3-8.9-25.9-8.5-8.8-19.5-12.2-36.5-11.4l-10 .5V557h48v-21h-70zM200.9 1302.1c-25.6 3.7-46.7 24-51.4 49.4-1.3 7-1.5 74.1-1.3 555.5.3 529.3.4 547.7 2.1 553 5.8 17.2 17.1 30.7 31.7 37.9 15.6 7.6-5.5 7.1 268 7.1s252.4.5 268-7.1c11.5-5.7 21-15.2 26.9-26.8 2.2-4.6 4.1-9 4.1-9.7 0-.8.5-1.4 1-1.4.6 0 1 .6 1 1.4 0 .7 1.9 5.1 4.1 9.7 8.2 16.2 24.4 28.6 42.4 32.4 10.5 2.2 494.5 2.2 505 0 18-3.8 34.2-16.2 42.4-32.4 2.2-4.6 4.1-9 4.1-9.7 0-.8.5-1.4 1-1.4.6 0 1 .6 1 1.4 0 .7 1.9 5.1 4.1 9.7 8.2 16.2 24.4 28.6 42.4 32.4 10.5 2.2 494.5 2.2 505 0 18-3.8 34.2-16.2 42.4-32.4 2.2-4.6 4.1-9 4.1-9.7 0-.8.5-1.4 1-1.4.6 0 1 .6 1 1.4 0 .7 1.9 5.1 4.1 9.7 8.2 16.2 24.4 28.6 42.4 32.4 10.5 2.2 494.5 2.2 505 0 18-3.8 34.2-16.2 42.4-32.4 2.2-4.6 4.1-9 4.1-9.7 0-.8.5-1.4 1-1.4.6 0 1 .6 1 1.4 0 .7 1.9 5.1 4.1 9.7 8.2 16.2 24.4 28.6 42.4 32.4 10.5 2.2 494.5 2.2 505 0 21.9-4.6 39.6-20.9 47.2-43.5 1.7-5.3 1.8-23.7 2.1-553 .3-609.9.9-556.1-6.8-571.8-8.8-17.8-26.3-30.2-46.7-33.2-9.3-1.3-487.3-1.3-496.6 0-20.3 3-37.7 15.3-46.6 33.1-2.3 4.5-4.1 8.8-4.1 9.5 0 .8-.4 1.4-1 1.4-.5 0-1-.6-1-1.4 0-.7-1.8-5-4.1-9.5-8.9-17.8-26.3-30.1-46.6-33.1-9.3-1.3-487.3-1.3-496.6 0-20.3 3-37.7 15.3-46.6 33.1-2.3 4.5-4.1 8.8-4.1 9.5 0 .8-.4 1.4-1 1.4-.5 0-1-.6-1-1.4 0-.7-1.8-5-4.1-9.5-8.9-17.8-26.3-30.1-46.6-33.1-4.3-.6-96-1-248.3-1s-244 .4-248.3 1c-20.3 3-37.7 15.3-46.6 33.1-2.3 4.5-4.1 8.8-4.1 9.5 0 .8-.4 1.4-1 1.4-.5 0-1-.6-1-1.4 0-.7-1.8-5-4.1-9.5-8.9-17.8-26.3-30.1-46.6-33.1-9.3-1.3-487.3-1.3-496.6 0-20.3 3-37.7 15.3-46.6 33.1-2.3 4.5-4.1 8.8-4.1 9.5 0 .8-.4 1.4-1 1.4-.5 0-1-.6-1-1.4 0-.7-1.8-5-4.1-9.5-8.9-17.8-26.3-30.1-46.6-33.1-8.4-1.2-489.2-1.1-497.4.1m507.5 5.7c17.4 6.6 30.4 19.5 36.7 36.3l2.4 6.4.3 549.8c.2 489.3 0 550.6-1.3 556.4-3.5 15.3-15.2 30.2-29.1 37.5-14 7.4 8.6 6.8-267.4 6.8s-253.4.6-267.4-6.8c-13.9-7.3-25.6-22.2-29.1-37.5-1.3-5.8-1.5-67.1-1.3-556.4l.3-549.8 2.4-6.4c3.1-8.2 10.9-19.9 16.3-24.3 9.1-7.5 19.4-12.5 28.8-14.1 1.4-.2 115-.4 252.5-.3l250 .1zm600 0c17.4 6.6 30.4 19.5 36.7 36.3l2.4 6.4.3 549.8c.2 489.3 0 550.6-1.3 556.4-3.5 15.3-15.2 30.2-29.1 37.5-14 7.4 8.6 6.8-267.4 6.8s-253.4.6-267.4-6.8c-13.9-7.3-25.6-22.2-29.1-37.5-1.3-5.8-1.5-67.1-1.3-556.4l.3-549.8 2.4-6.4c3.1-8.2 10.9-19.9 16.3-24.3 9.1-7.5 19.4-12.5 28.8-14.1 1.4-.2 115-.4 252.5-.3l250 .1zm600 0c17.4 6.6 30.4 19.5 36.7 36.3l2.4 6.4.3 549.8c.2 489.3 0 550.6-1.3 556.4-3.5 15.3-15.2 30.2-29.1 37.5-14 7.4 8.6 6.8-267.4 6.8s-253.4.6-267.4-6.8c-13.9-7.3-25.6-22.2-29.1-37.5-1.3-5.8-1.5-67.1-1.3-556.4l.3-549.8 2.4-6.4c3.1-8.2 10.9-19.9 16.3-24.3 9.1-7.5 19.4-12.5 28.8-14.1 1.4-.2 115-.4 252.5-.3l250 .1zm600 0c17.4 6.6 30.4 19.5 36.7 36.3l2.4 6.4.3 549.8c.2 489.3 0 550.6-1.3 556.4-3.5 15.3-15.2 30.2-29.1 37.5-14 7.4 8.6 6.8-267.4 6.8s-253.4.6-267.4-6.8c-13.9-7.3-25.6-22.2-29.1-37.5-1.3-5.8-1.5-67.1-1.3-556.4l.3-549.8 2.4-6.4c3.1-8.2 10.9-19.9 16.3-24.3 9.1-7.5 19.4-12.5 28.8-14.1 1.4-.2 115-.4 252.5-.3l250 .1zm600 0c17.4 6.6 30.4 19.5 36.7 36.3l2.4 6.4.3 549.8c.2 489.3 0 550.6-1.3 556.4-3.5 15.3-15.2 30.2-29.1 37.5-14 7.4 8.6 6.8-267.4 6.8s-253.4.6-267.4-6.8c-13.9-7.3-25.6-22.2-29.1-37.5-1.3-5.8-1.5-67.1-1.3-556.4l.3-549.8 2.4-6.4c3.1-8.2 10.9-19.9 16.3-24.3 9.1-7.5 19.4-12.5 28.8-14.1 1.4-.2 115-.4 252.5-.3l250 .1z"})),L||(L=n.createElement("path",{d:"M450.3 1852.4c-17.6 4.4-29.8 17.3-35 36.6-2.4 9.1-2.4 31.9.1 41 6.2 22.6 20.5 34 42.7 34 20.2 0 36-10.8 40.4-27.7 2.6-10 1.6-20.4-2.9-29.1-2.9-5.6-12-12.9-19.2-15.2-9.6-3.2-21.4-2.6-30.2 1.7l-6.3 3 .6-4.1c2.9-17.6 16.4-26 35.6-22.1 4.3.8 9.9 2.4 12.4 3.5l4.5 1.9v-20.6l-7.2-1.8c-9.3-2.3-28.4-2.9-35.5-1.1m14.7 57.4c4.6 2.3 6.9 6.7 7.6 14.3.8 8.3-.9 14.4-5.1 18.6-3 3-3.8 3.3-9.3 3.3-10.3 0-14.6-5.3-14.7-18.5 0-12.9 4.9-19.5 14.5-19.5 1.9 0 5.1.8 7 1.8M1014 1861.5v10.5l26 .2 25.9.3-18.5 40.5c-10.2 22.3-19.1 42-19.9 43.7l-1.4 3.3h27.4l21.3-46.8 21.2-46.7V1851h-82zM1643.9 1851.9c-12.5 2.3-21.5 9.6-24.5 19.6-3.5 12.2 1 23 12 29.1l5.8 3.2-4.8 2.2c-10.3 4.5-16.4 13.7-16.4 24.9 0 20.8 12.5 31.4 38.6 32.8 18.1 1 32.4
13-3.3 40-12 5-5.6 6.7-11.3 6.7-21.2-.1-11.9-5.3-19.5-16.7-24.5l-4.7-2.1 5-2.5c9.6-4.8 14.1-12.2 14.1-23 0-12.2-6.2-20.1-19.5-24.8-5.7-2.1-27.9-3.1-35.6-1.7m24 19.7c6 5 6.1 15.3.1 20.6-2.6 2.4-3.9 2.8-9.1 2.8-6.7 0-10.2-1.7-12.5-6.1-3.2-6.3-.5-16.7 4.9-18.9 1.2-.5 4.8-.9 7.9-.9 4.7-.1 6.2.3 8.7 2.5m-.9 43.2c6.7 3.5 9.9 14.6 6.6 22.5-.7 1.8-2.8 4.5-4.5 6-2.8 2.3-4.1 2.7-9.9 2.7-11.3 0-16.4-5-16.4-16 0-8 3.1-13.5 9.2-15.9 4-1.6 11.2-1.2 15 .7M2244.1 1852.6c-11.9 3.2-20.1 9.8-25 20.3-2.3 5-2.6 6.8-2.6 16.6 0 10 .3 11.5 2.8 16.7 3.3 6.7 9 12.1 16.6 15.7 5 2.3 6.8 2.6 16.6 2.6 10.4 0 11.4-.2 17.2-3.2l6.3-3.1-.6 2.6c-1.7 7.8-2.6 10.1-5.3 14.3-2.2 3.5-4.4 5.4-8.7 7.5-8.1 3.9-19.6 4-30 .1-3.9-1.5-7.4-2.7-7.8-2.7-.3 0-.6 4.4-.6 9.9v9.9l6.8 1.7c8.9 2.3 26.1 3.1 33.5 1.6 18.4-3.9 31.7-17.2 36.8-36.8 2.5-9.7 2.8-28.4.6-39-3.9-18.3-15.3-31.4-30.6-34.9-7.3-1.8-19.2-1.7-26 .2m20.9 17.9c4.7 2.4 7 8.1 7 17.2 0 9.2-1.8 13.6-6.9 17-6.3 4.2-15.5 2.2-19.7-4.2-1.1-1.8-1.9-5.4-2.2-10.6-.8-14.2 3.7-20.9 14.1-20.9 2.6 0 6.1.7 7.7 1.5M2946.7 1852c-14.2 3.6-24.1 13.5-29.5 29.8-2.4 7.2-2.6 8.9-2.6 25.7s.2 18.5 2.6 25.7c6.5 19.4 18.7 29.4 37.3 30.6 24.8 1.5 40-9.7 46.7-34.6 2.9-11 2.9-32.5-.1-43.5-4.2-15.9-13.1-27.3-24.9-31.8-6.4-2.4-22.9-3.5-29.5-1.9m19.4 20.3c6.8 4.5 8.9 12.8 8.9 35.6 0 26.9-4.5 37.1-16.2 37.1-11.8 0-16.7-11.2-16.8-38 0-20.7 3.1-31.8 10-35.2 4.8-2.5 10-2.3 14.1.5M2832.5 1855.1c-4.9 1-10 2.1-11.2 2.4-2.2.5-2.3 1-2.3 10 0 9.4 0 9.5 2.3 9 4.5-1.1 22-4.5 22.8-4.5.5 0 .9 15.2.9 35v35h-25v20h76v-20h-25v-89l-14.7.1c-10.3.1-17.5.7-23.8 2"}))),Ct=(0,m.A)(ot)(({theme:s})=>({fill:s.palette.text.primary}));function ut({form:s,...F}){return(0,t.jsxs)(At.Ay,{...F,children:[(0,t.jsx)(Se.A,{label:"Stickers layout",children:(0,t.jsx)(j.A,{component:Ct,height:200})}),(0,t.jsx)(At.Ay.Item,{name:"type",control:s.control,render:({field:Q,fieldState:w})=>(0,t.jsx)(gt,{value:Q.value,onChange:Q.onChange,error:w.invalid,helperText:w.error?.message,required:!0})}),(0,t.jsx)(At.Ay.Item,{name:"position",control:s.control,render:({field:Q,fieldState:w})=>(0,t.jsx)(k.A,{start:1,end:10,value:Q.value,onChange:Q.onChange,error:w.invalid,helperText:w.error?.message,inputRef:Q.ref,required:!0})}),(0,t.jsx)(At.Ay.InputNumber,{name:"quantity",label:"Quantity",control:s.control,min:1,required:!0})]})}oe.View=ut;function oe(s){const{form:F}=de.useContext();return(0,t.jsx)(oe.View,{form:F,...s})}const Ut=oe;bt.useContext=Wt,bt.Context=Dt,bt.Provider=Et,bt.Form=Ut,bt.Button=Vt,bt.Modal=$t,bt.useProductStickers=Lt,bt.ProductStickersViewer=he;function bt({productId:s,defaultValues:F,...Q}){const w=Lt({productId:s,defaultValues:F});return(0,t.jsxs)(bt.Provider,{...w,children:[(0,t.jsx)(bt.Modal,{children:(0,t.jsx)(bt.Form,{})}),(0,t.jsx)(bt.Button,{...Q}),(0,t.jsx)(bt.ProductStickersViewer,{})]})}const de=bt;var Pe=e(8205),xe=e(94275),Fe=e(55018),ie=e(91235),Bt=e(32123),B=e(51161);function x({productId:s}){const F=(0,K.hS)(),[Q,w]=(0,n.useState)(!0),_t=()=>w(ve=>!ve),ce=(0,n.useMemo)(()=>({productId:s}),[s]),je=(0,h.G)(ve=>(0,P.QL)(ve,ce)),We=(0,h.G)(ve=>(0,P.qM)(ve,ce)),{useProductQuery:Me,useVariantImagesMutation:Ue}=c.G,{isLoading:we,isFetching:He}=Me({productId:s},{skip:!s||!F.visible}),[xn,{isLoading:Ke}]=Ue(),{isFetching:sn}=i.h.useSizesQuery(void 0,{skip:!s||!F.visible}),{isFetching:on}=d.p.useInventoryFormDataQuery(void 0,{skip:!s||!F.visible}),{isFetching:an}=(0,Bt.M)({skip:!s||!F.visible,skipTrims:!0,skipLycras:!0,skipLabels:!0}),{isFetching:Dn}=i.h.useColorsQuery(void 0,{skip:!s||!F.visible}),yn=we||sn||Dn||an||on,zn=ve=>{if(!ve)return;const Xe=je[ve]?.variantIds;if(!(!Array.isArray(Xe)||!Xe.length))return Xe},Pn=({imageIds:ve,colorId:Xe,action:pn})=>{if(!Array.isArray(ve)||!ve.length)return Promise.resolve();const jn=zn(Xe);return jn?xn({body:{action:pn,variants:jn,images:ve}}):Promise.resolve()},Nn=({colorId:ve})=>Xe=>{const pn=(0,B._)(Xe,{field:"id"});return Pn({colorId:ve,imageIds:pn,action:"upload"})},On=({imageId:ve,colorId:Xe})=>Pn({colorId:Xe,imageIds:(0,yt.A)([ve]),action:"sync"}),Bn=({imageId:ve,colorId:Xe})=>Pn({colorId:Xe,imageIds:(0,yt.A)([ve]),action:"delete"}),Rn=({colorId:ve})=>{if(!ve)return Promise.resolve();const Xe=je[ve];if(Xe?.synced)return Promise.resolve();const pn=[];return(0,vt.A)(Xe?.images,jn=>{jn?.fromProduct||jn?.fromMillYarn||jn?.image?.id&&pn.push(jn.image.id)}),Pn({colorId:ve,imageIds:pn,action:"sync"})},En=()=>!He&&!Ke,Wn=ve=>En()?ve?.fromProduct||ve?.fromMillYarn?!!(0,ie.A)(ve?.excludedVariants):!ve?.synced:!1,Un=ve=>En()?ve?.fromProduct||ve?.fromMillYarn?!!(0,ie.A)(ve?.includedVariants):!0:!1,Gn=ve=>!ve||!je[ve]?!1:!je[ve]?.synced,Yn=(0,n.useCallback)(()=>{w(!0)},[]);return{modal:F,product:We,productImagesVisible:Q,variantsImages:je,loading:yn,reset:Yn,onUpload:Nn,onImageDelete:Bn,onImageSync:On,onColorwaySync:Rn,imageCanSync:Wn,toggleProductImagesVisibility:_t,canSyncColorway:Gn,imageCanDelete:Un,uploading:Ke||He}}var I=e(3979);const g=(0,m.A)(I.A)({minWidth:280});function V(s){const{productImagesVisible:F,toggleProductImagesVisibility:Q}=Jt.useContext();return(0,t.jsx)(g,{value:F,onChange:Q,label:`Product images are ${F?"visible":"hidden"}`,...s})}const ht=V;var at=e(95218);function y({disabled:s,colorId:F,loading:Q,hidden:w,..._t}){const{onColorwaySync:ce,uploading:je,canSyncColorway:We}
13=Jt.useContext(),[Me,Ue]=(0,n.useState)(!1),we=()=>{Ue(!0),ce({colorId:F}).catch(console.warn).finally(()=>Ue(!1))};return(0,t.jsx)(r.A,{loading:Me||Q,disabled:je||s,onClick:we,color:"primary",variant:"contained",hidden:w||!We(F),startIcon:(0,t.jsx)(at.A,{}),..._t})}const _=y;var Pt=e(30995),ee=e(20440),fe=e(42617),me=e(33551),Be=e(82778),Le=e(73164);const ze=(0,m.A)(Be.A)(({theme:s})=>({borderRadius:s.shape.borderRadius}));function Ve({colorId:s,disabled:F,...Q}){const{onUpload:w,uploading:_t,product:ce}=Jt.useContext();return(0,t.jsx)(ze,{startIcon:(0,t.jsx)(Le.A,{sx:{fontSize:60}}),size:"large",shape:"default",initialTags:(0,yt.A)([ce?.name]),onApply:w({colorId:s}),disabled:F||_t,extraTools:(0,t.jsx)(Be.A.ApplyButton,{startIcon:(0,t.jsx)(Le.A,{}),children:"Attach to variant colorway"}),selectable:!0,...Q})}const le=Ve;var pe=e(11397),Ne=e(99682),Oe=e(18342),Qe=e(69554);function Ye({variantImage:s}){if(!(0,ie.A)(s?.excludedVariants))return null;const F=()=>s?.fromProduct||s?.fromMillYarn?"Detached in sizes:":"Missed in sizes:";return(0,t.jsx)(Se.A,{label:F(),contentPadding:Q=>Q.spacing(.5),children:(0,t.jsx)(Pt.A,{flexDirection:"row",gap:.5,flexWrap:"wrap",children:(0,zt.A)(s?.excludedVariants,Q=>(0,t.jsx)(fe.A,{sizeData:Q?.size,color:s?.fromProduct||s?.fromMillYarn?"warning":"error",hidden:!Q?.size?.name},Q?.size?.id))})})}const Ze=(0,m.A)(Pt.A)(({theme:s})=>({minWidth:200,maxWidth:200,border:s.border.solid(1),borderRadius:s.shape.borderRadius}));function qe({variantImage:s,colorId:F}){const{productImagesVisible:Q,imageCanSync:w,imageCanDelete:_t,onImageSync:ce,onImageDelete:je,uploading:We}=Jt.useContext(),[Me,Ue]=(0,n.useState)(!1),[we,He]=(0,n.useState)(!1),xn=()=>{Ue(!0),ce({colorId:F,imageId:s?.image?.id}).catch(console.warn).finally(()=>Ue(!1))},Ke=()=>{He(!0),je({colorId:F,imageId:s?.image?.id}).catch(console.warn).finally(()=>He(!1))},sn=(0,n.useMemo)(()=>s?.fromProduct?"Product Image":s?.fromMillYarn?"Color Card":"Variant Image",[s]),on=(0,n.useMemo)(()=>s?.fromProduct?"success":s?.fromMillYarn?"info":"purple",[s]);return(0,t.jsxs)(Ze,{flex:1,hidden:!Q&&(!!s?.fromProduct||!!s?.fromMillYarn),justifyContent:"space-between",padding:1,gap:1,children:[(0,t.jsxs)(Pt.A,{gap:1,width:"100%",justifyContent:"space-between",flex:1,children:[(0,t.jsxs)(Pt.A,{position:"relative",alignItems:"center",gap:1,children:[(0,t.jsx)(Qe.A,{color:on,label:sn,sx:{width:"100%"}}),(0,t.jsx)(pe.A,{src:s?.image?.previewSrc,maxHeight:150,style:{alignSelf:"center"},preview:{src:s?.image?.highResolutionSrc||s?.image?.src}})]}),(0,t.jsx)(Ye,{variantImage:s})]}),(0,t.jsxs)(Pt.A,{width:"100%",children:[(0,t.jsx)(r.A,{startIcon:(0,t.jsx)(Ne.A,{}),onClick:xn,disabled:!w(s)||We,loading:Me,variant:"text",color:"inherit",justifyContent:"flex-start",fullWidth:!0,children:"Attach to all sizes"}),(0,t.jsx)(r.A,{startIcon:(0,t.jsx)(Oe.A,{}),disabled:!_t(s)||We,onClick:Ke,loading:we,variant:"text",justifyContent:"flex-start",color:"error",fullWidth:!0,children:s?.fromProduct||s?.fromMillYarn?"Detach from all sizes":"Delete from variants"})]})]})}const _e=qe;tn.Image=_e;function tn({images:s,colorId:F}){return(0,t.jsxs)(Pt.A,{flexWrap:"wrap",flexDirection:"row",gap:2,children:[(0,t.jsx)(le,{colorId:F,sx:{width:120,minHeight:230},autoHeight:!0}),(0,zt.A)(s,(Q,w)=>(0,t.jsx)(_e,{colorId:F,variantImage:Q},w))]})}const ye=tn;function Ae({color:s,images:F,sizes:Q}){return(0,t.jsxs)(Se.A,{contentAlignItems:"flex-start",label:(0,t.jsxs)(Pt.A,{flexDirection:"row",gap:1,alignItems:"center",flexWrap:"wrap",children:[(0,t.jsx)(ee.A,{color:s,width:36}),(0,t.jsx)(me.A,{children:s?.name}),(0,zt.A)(Q,w=>(0,t.jsx)(fe.A,{sizeData:w}))]}),children:[(0,t.jsx)(Jt.SyncColorwayButton,{colorId:s?.id,children:"Sync all images in colorway"}),(0,t.jsx)(ye,{images:F,colorId:s?.id})]})}S.Item=Ae;function S(s){const{variantsImages:F}=Jt.useContext();return(0,t.jsx)(Pt.A,{width:"100%",gap:4,...s,children:(0,zt.A)(F,(Q,w)=>(0,t.jsx)(S.Item,{color:Q?.color,images:Q?.images,sizes:Q?.sizes},w))})}const R=S;var ft=e(62456);function rt(s){const{modal:F}=Jt.useContext();return(0,t.jsx)(r.A,{startIcon:(0,t.jsx)(ft.A,{}),onClick:F.open,variant:"contained",color:"primary",...s})}const Mt=(0,n.createContext)({});function Ht({children:s,...F}){return(0,t.jsx)(Mt.Provider,{value:F,children:s})}function Qt(){return(0,n.useContext)(Mt)}function se({loading:s,...F}){const{modal:Q,reset:w,loading:_t}=Jt.useContext();return(0,t.jsx)(K.Ay,{open:Q.visible,onClose:Q.close,title:"Images by Colorways",onTransitionExited:w,headerActions:(0,t.jsx)(Jt.ProductImagesToggle,{}),maxWidth:"lg",loading:_t||s,fullScreen:!0,fullWidth:!0,...F})}wt.useVariantsImages=x,wt.Modal=se,wt.Button=rt,wt.ImageList=R,wt.ProductImagesToggle=ht,wt.ImagesUpload=le,wt.SyncColorwayButton=_,wt.useContext=Qt,wt.Context=Mt,wt.Provider=Ht;function wt({productId:s,...F}){const Q=wt.useVariantsImages({productId:s});return(0,t.jsxs)(wt.Provider,{...Q,children:[(0,t.jsx)(wt.Modal,{children:(0,t.jsx)(wt.ImageList,{})}),(0,t.jsx)(wt.Button,{...F})]})}const Jt=wt;var Te=e(71543);function Xt({loading:s,...F}){const{drawer:Q,product:w,onCreateVariants:_t,reset:ce,activeTabKey:je,setActiveTabKey:We,showDeleteButton:Me,loading:Ue}=vn.useContext();return(0,t.jsx)(o.A,{isEmpty:!w?.id,emptyLabel:"Product not found",open:Q.visible,onClose:Q.close,onTransitionExited:ce,loading:Ue||s,title:(0,t.jsx)(T.A,{product:w}),defaultTab:"details",tab:je,width:je==="pricing"?650:void 0,onTabChange:We,actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Pe.A,{productId:w?.id,hidden:w?.state!==X.ix.COMPLETED,children:"TP"}),(0,t.jsx)(lt,{product:w}),(0,t.jsxs)(O.A,{children:[(0,t.jsx)(Fe.A,{hidden:w?.state!==X.ix.COMPLETED,productId:w?.id,shape:"default",variant:"text",color:"inherit",fullWidth:!0,children:"Matrix"}),(0,t.jsx)(xe.A,{hidden:w?.state!==X.ix.COMPLETED,productId:w?.id,shape:"default",color:"inherit",variant:"text",onClick:_t,fullWidth:!0,children:"Create Variants"}),(0,t.jsx)(Jt,{hidden:w?.state!==X.ix.COMPLETED,productId:w?.id,shape:"default",variant:"text",color:"inherit",fullWidth:!0,children:"Images for Colorways"}),(0,t.jsx)(xt.Ay,{productId:w?.id,shape:"default",color:"inherit",variant:"text",fullWidth:!0,children:"Edit Pricing"}),(0,t.jsx)(Ft,{productId:w?.id,shape:"default",variant:"text",color:"inherit",fullWidth:!0,children:"Edit Product"}),(0,t.jsx)(de,{productId:w?.id,shape:"default",variant:"text",color:"inherit",fullWidth:!0,children:"Stickers"}),!!Me&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Te.A,{}),(0,t.jsx)(q.A,{product:w,onSuccess:Q.close,shape:"default",variant:"text",fullWidth:!0,children:"Delete Product"})]})]})]}),subheader:(0,t.jsxs)(Pt.A,{flexDirection:"row",gap:1,alignItems:"center",justifyContent:"space-between",children:[(0,t.jsxs)(o.A.TabsList,{children:[(0,t.jsx)(o.A.Tab,{label:"Details",value:"details"}),(0,t.jsx)(o.A.Tab,{label:(0,t.jsx)(vn.Tabs.Variants.Title,{}),value:"variants"}),(0,t.jsx)(o.A.Tab,{label:"Pricing",value:"pricing"}),(0,t.jsx)(o.A.Tab,{label:"Requests",value:"requests"}),(0,t.jsx)(o.A.Tab,{label:"Actions",value:"actions"})]}),(0,t.jsx)(A.A,{product:w})]}),...F})}var De=e(427),Rt=e(9559);function Ie({productId:s,hidden:F,disabled:Q,...w}){const _t=(0,De.A)(),ce=(0,v.I)(We=>We.PRODUCTS__READ),je=()=>s?_t.redirect(Rt.Ay.productDetails(s),!0):void 0;return(0,t.jsx)(r.A.Open,{onClick:je,hidden:F||!s,disabled:Q||!ce,disabledMessage:ce?void 0:"Access Denied",...w})}var ge=e(49205),Re=e(51825),be=e(28811),ue=e(96759),rn=e(81662),$e=e(8488),Je=e(74774),ke=e(29617),ln=e(25692),cn=e(69592),An=e(23149),gn=e(17857);function hn({groups:s,loader:F}){const{isLoading:Q}=c.G.useProductCategoriesQuery({limit:0});return!Q&&!s?null:(0,t.jsxs)(Pt.A,{flexWrap:"wrap",gap:1,flexDirection:"row",maxWidth:"100%",children:[!!Q&&((0,cn.A)(F)?(0,t.jsx)(gn.A,{loading:Q}):F),(0,zt.A)(s,(w,_t)=>!w||!(0,An.A)(w)||!("id"in w)?null:(0,t.jsx)(Qe.A,{color:"info",hidden:!w?.title||Q,style:{margin:0},label:w?.title},`${w?.id}_${_t}`))]})}const un=hn;var mn=e(44409),dn=e(47144);Ot.Gauge=mn.A;function Ot(){const{product:s}=vn.useContext();return(0,t.jsxs)(j.A,{children:[!!s?.exclude_from_best_sellers&&(0,t.jsx)(rn.A,{type:"warning",error:"This product is excluded from best sellers"}),(0,t.jsx)(ue.A,{value:(0,t.jsx)(ke.A,{items:[...(0,yt.A)((0,Gt.A)(s?.images)),...(0,yt.A)((0,Gt.A)(s?.mill_yarn_images))]}),hidden:!(0,ie.A)(s?.images)&&!(0,ie.A)(s?.mill_yarn_images)}),(0,t.jsx)(ue.A,{title:"Style Name",value:s?.name}),(0,t.jsx)(ue.A,{title:"SKU",value:s?.sku}),(0,t.jsx)(ue.A,{title:"Groups",value:(0,t.jsx)(un,{groups:s?.groupList})}),(0,t.jsx)(ue.A,{title:"Brand Partner",value:(0,t.jsx)(Je.A,{brandPartners:s?.brandPartnerList})}),(0,t.jsx)(ue.A,{title:"Product description",value:s?.description}),(0,t.jsx)(ue.A,{title:"Fiber content",value:s?.fiberContent}),(0,t.jsx)(ue.A,{title:"Gauge",value:(0,t.jsx)(mn.A,{product:s})}),(0,t.jsx)(ue.A,{title:"XFTY",value:dn.A.formatDay(s?.xfty_days??6)}),(0,t.jsx)(ue.A,{title:"Knit by",value:dn.A.formatDay(s?.knit_by_days??3)}),(0,t.jsx)(ue.A,{title:"Detail tags",value:(0,t.jsx)($e.A,{tags:(0,yt.A)(s?.tags?.details),color:"success"})}),(0,t.jsx)(ue.A,{title:"Silhouette tags",value:(0,t.jsx)($e.A,{tags:(0,yt.A)(s?.tags?.silhouette),color:"teal"})}),(0,t.jsx)(ue.A,{title:"Stitch structure tags",value:(0,t.jsx)($e.A,{tags:(0,yt.A)(s?.tags?.stitch_structure),color:"warning"})}),(0,t.jsx)(ue.A,{title:"Gender tags",value:(0,t.jsx)($e.A,{tags:(0,yt.A)(s?.tags?.gender),color:"purple"})}),(0,t.jsx)(ue.A,{title:"Search keywords",value:(0,t.jsx)($e.A,{tags:(0,yt.A)(s?.tags?.search_keywords),color:"info"})}),(0,t.jsx)(ue.A,{title:"Phases",value:(0,t.jsx)(ln.A,{phases:(0,yt.A)(s?.phaseList)})}),(0,t.jsx)(ue.A,{title:"Created",value:(0,t.jsx)(be.A,{date:s?.created})}),(0,t.jsx)(ue.A,{title:"Updated",value:(0,t.jsx)(be.A,{date:s?.updated})})]})}const kt=Ot;var Zt=e(72305),ae=e(24978),Ee=e(30193),en=e(84053),Ce=e(28786);function Ge({productId:s}){const{useRequestsQuery:F}=It.Yp,{requestsLoading:Q,response:w}=F({product:s||"",limit:0},{selectFromResult:je=>({requestsLoading:je.isLoading,response:je.data})}),_t=(0,n.useMemo)(()=>({techPackIds:(0,B._)(w?.techPacks,{field:"_id"})}),[w]);return{requests:(0,h.G)(je=>(0,Z.K1)(je,_t)),loading:Q}}fn.useProductRequestsTab=Ge;function fn(){const{product:s}=vn.useContext(),{requests:F,loading:Q}=Ge({productId:s?.id});return(0,t.jsxs)(Pt.A,{gap:2,children:[(0,t.jsx)(gn.A,{loading:Q}
13),!Q&&!(0,ie.A)(F)&&(0,t.jsx)(ae.A,{}),(0,zt.A)(F,(w,_t)=>(0,t.jsxs)(Zt.A,{children:[(0,t.jsx)(Zt.A.Item,{label:"Name",children:w?.name}),(0,t.jsx)(Zt.A.Item,{label:"Brand Partner",children:(0,t.jsx)(Je.A,{brandPartners:(0,yt.A)([w?.brandPartner])})}),(0,t.jsx)(Zt.A.Item,{label:"Phase",children:(0,t.jsx)(en.A,{request:w})}),(0,t.jsx)(Zt.A.Item,{label:"State",children:(0,t.jsx)(Ce.A,{request:w})}),(0,t.jsx)(Zt.A.Footer,{children:(0,t.jsx)(Ee.A,{requestId:w?.id,fullWidth:!0,children:"View"})})]},_t))]})}const Cn=fn;var Mn=e(26314);function In({productId:s}){const{isFetching:F}=i.h.useSizesQuery(void 0,{skip:!s}),{isLoading:Q}=d.p.useInventoryFormDataQuery(void 0,{skip:!s}),{isLoading:w}=(0,Bt.M)({skip:!s,skipTrims:!0,skipLycras:!0,skipLabels:!0}),{isLoading:_t}=i.h.useColorsQuery(void 0,{skip:!s});return{loading:F||w||Q||_t}}var Vn=e(17138);function bn(s){const{productVariantsQty:F,product:Q}=vn.useContext();return(0,t.jsxs)(Pt.A,{flexDirection:"row",alignItems:"center",gap:.5,...s,children:[(0,t.jsxs)("span",{children:["Variants ",F]}),(0,t.jsx)(Vn.A,{variant:(0,yt.A)((0,Gt.A)(Q?.variants))})]})}Tn.Title=bn,Tn.useProductVariantsTab=In;function Tn(){const{productVariantsQty:s,product:F}=vn.useContext(),{loading:Q}=In({productId:F?.id});return Q?(0,t.jsx)(gn.A,{loading:Q}):s?(0,t.jsx)(Mn.A,{productId:F?.id}):(0,t.jsx)(ae.A,{})}const Ln=Tn;Sn.Info=kt,Sn.Requests=Cn,Sn.Variants=Ln;function Sn(){const{product:s}=vn.useContext();return(0,t.jsxs)(j.A,{children:[(0,t.jsx)(o.A.TabPanel,{value:"details",children:(0,t.jsx)(kt,{})}),(0,t.jsx)(o.A.TabPanel,{value:"variants",children:(0,t.jsx)(Ln,{})}),(0,t.jsx)(o.A.TabPanel,{value:"pricing",children:(0,t.jsx)(Re.A,{productId:s?.id})}),(0,t.jsx)(o.A.TabPanel,{value:"requests",children:(0,t.jsx)(Cn,{})}),(0,t.jsx)(o.A.TabPanel,{value:"actions",children:(0,t.jsx)(ge.A,{productId:s?.id})})]})}const Fn=Sn;nn.Provider=H,nn.Context=G,nn.useContext=$,nn.Drawer=Xt,nn.Button=l,nn.Tabs=Fn,nn.Link=Ie,nn.useProductDetails=C;function nn({productId:s,route:F,backRoute:Q,showDeleteButton:w,..._t}){const ce=C({productId:s,route:F,backRoute:Q,showDeleteButton:w});return(0,t.jsxs)(nn.Provider,{...ce,children:[(0,t.jsx)(nn.Drawer,{children:(0,t.jsx)(nn.Tabs,{})}),(0,t.jsx)(l,{..._t})]})}const vn=nn},44409(re,et,e){e.d(et,{A:()=>c});var t=e(74848),n=e(96540),o=e(17857),h=e(76429),i=e(23841),v=e(69554);function d({product:P,label:C,...r}){const{isLoading:l,isError:G}=i.h.useValuesQuery(),{errorSnackbar:H}=(0,h.d)();return(0,n.useEffect)(()=>{G&&H("Failed to load gauges!")},[G]),l?(0,t.jsx)(o.A,{loading:l}):(0,t.jsx)(v.A,{label:C??P?.gaugeField?.label,color:"teal",...r})}const c=d},9450(re,et,e){e.d(et,{A:()=>i});var t=e(74848),n=e(30995),o=e(69554);function h({product:v}){return v?.name?(0,t.jsxs)(n.A,{flexDirection:"row",gap:1,alignItems:"center",children:[!!v?.is_stk&&(0,t.jsx)(o.A,{color:"success",label:"STK"}),(0,t.jsx)("span",{children:v?.name})]}):null}const i=h},51825(re,et,e){e.d(et,{A:()=>j});var t=e(74848),n=e(96540),o=e(2454),h=e(27354),i=e(33318),v=e(87924),d=e(4855);function c(){const{product:m}=j.useContext(),u=(0,o.G)(i.ro);return(0,t.jsx)(v.A.Breakdowns,{pricing:m?.pricing?.jit,type:d.Th.SPEND_AMOUNT,minSpendAmount:u,borderless:!0,striped:!0,horizontalBordered:!0})}const P=c;
13var C=e(39241),r=e(27447),l=e(47144);function G(m){const{pricingDetails:u,product:f}=j.useContext(),L=(0,n.useMemo)(()=>(0,h.wK)({product:f,surcharges:(0,C.A)(u?.pricing?.surcharges)}),[u,f]),a=(0,n.useMemo)(()=>[{field:"colorway",label:"Colorway",span:19,renderField:M=>(0,t.jsx)(r.A.View,{colorway:M?.colorway?.colorway,width:"100%",paddingRight:2})},{label:"Total",span:5,field:"amount",renderField:M=>(0,t.jsx)(j.Data.Text,{variant:"body1",fontWeight:"bold",hidden:!M?.amount,translate:"no",children:l.A.formatUsd(M?.amount)})}],[]);return(0,t.jsx)(j.Data,{items:L,config:a,...m})}const H=G;var $=e(89610),O=e(53652),A=e(30995),q=e(33551);function N({hidden:m,...u}){return m?null:(0,t.jsx)(A.A,{component:q.A,variant:"body2",...u})}K.Text=N;function K({renderFooter:m,items:u,...f}){return(0,t.jsxs)(A.A,{children:[(0,t.jsx)(O.A,{items:u,urlBased:!1,transparentHeader:!0,borderless:!0,horizontalBordered:!0,striped:!0,hideFooter:!0,...f}),(0,$.A)(m)&&m({items:u})]})}const ct=K;var z=e(23841),nt=e(30251),b=e(49497),D=e(22552);function J({productId:m}){const[u,f]=(0,n.useState)(),{useProductPricingDetailsQuery:L}=D.G,{isLoading:a}=L({productId:m},{skip:!m}),M=(0,n.useMemo)(()=>({productId:m}),[m]),ot=(0,o.G)(Bt=>(0,h.Ib)(Bt,M)),Ct=(0,o.G)(Bt=>(0,h.qM)(Bt,M)),{useProductQuery:ut}=D.G,{isFetching:oe}=ut({productId:m},{skip:!m}),{useSizesQuery:Ut}=z.h,{isFetching:bt}=Ut(void 0,{skip:!m}),de=(0,o.G)(Bt=>(0,h.sW)(Bt,M)),Pe=(0,n.useMemo)(()=>({variantId:u?.variant||void 0}),[u?.variant]),xe=(0,o.G)(Bt=>(0,h.Ox)(Bt,Pe)),Fe=(0,o.G)(nt.LR),ie=(0,b.I)(Bt=>Bt.INVENTORY__PRICES__READ);return(0,n.useEffect)(()=>{const Bt=Ct?.variantIds?.[0];if(!Bt)return;const B=Ct?.variants?.[Bt];f({variant:Bt,colorway:B?.colorId,size:B?.sizeId})},[Ct,ot]),{pricingDetails:ot,sizes:Fe,phasesPricing:de,pickedVariantData:u,setPickedVariantData:f,canViewPricingDetails:ie,productId:m,product:Ct,selectedVariant:xe,loading:a||bt||oe}}var it=e(8058),Y=e(13575),dt=e(74722),mt=e(11848);const At=(0,mt.A)(A.A)(({theme:m})=>({borderBottom:m.border.solid(1),"&:first-of-type":{paddingTop:0},"&:last-of-type":{borderBottomColor:"transparent",paddingBottom:0}}));function pt(m){const{pricingDetails:u}=j.useContext(),f=(0,n.useMemo)(()=>{const M=[];return(0,it.A)(u?.pricing?.extra?.yarns,ot=>{!ot?.mill_yarn||ot?.type!=="body"||M.push(ot)}),M},[u]),L=(0,n.useMemo)(()=>[{field:"name",label:"Size",span:9,renderField:M=>(0,t.jsx)(j.Data.Text,{fontWeight:M?.name==="median"?"bold":"inherit",children:(0,Y.A)(M.name)})},{field:"time",label:"Knitting",span:5,renderField:M=>(0,t.jsx)(j.Data.Text,{fontWeight:M?.name==="median"?"bold":"inherit",color:M?.name==="median"?"info":"inherit",children:l.A.formatMinute(M.time)})},{label:"Yarns",span:10,renderField:M=>(0,t.jsx)(A.A,{width:"100%",children:(0,dt.A)(f,(ot,Ct)=>{if(!M?.name)return;const ut=l.A.formatKg(ot?.details?.[M.name]?.weight);return(0,t.jsxs)(At,{justifyContent:"space-between",width:"100%",flexDirection:"row",paddingBlock:.5,gap:8,children:[(0,t.jsx)(q.A,{variant:"body2",children:ot?.mill_yarn_name}),(0,t.jsx)(j.Data.Text,{color:M.name==="median"?"teal":"inherit",children:ut})]},Ct)})})}],[f]),a=(0,n.useMemo)(()=>(0,dt.A)(u?.pricing?.extra?.knitting?.details,(M,ot)=>({name:ot,time:M?.time||0})),[u]);return(0,t.jsx)(j.Data,{items:a,config:L,...m})}const yt=pt;var p=e(1694),E=e(91235),st=e(53098),Ft=e(24978),vt=e(24401),zt=e(4187);function X(m){const{pricingDetails:u}=j.useContext(),f=(0,n.useMemo)(()=>{const a={};let M=0,ot=0,Ct=0,ut=0,oe=0;return(0,it.A)(u?.pricing?.extra?.knitting?.parts,Ut=>{const bt=Ut?.part_name;bt&&(a?.[bt]||(a[bt]={name:bt,data:[]}),Ct+=(0,p.A)(Ut.medianKnitTime)||0,ot+=(0,p.A)(Ut.total)||0,oe+=(0,p.A)(Ut.price)||0,a[bt]?.data?.push({mill_yarn_name:"Knitting",mill_yarn:"knitting",time:Ut.medianKnitTime,price:Ut.price,total:Ut.total}))}),(0,it.A)(u?.pricing?.extra?.yarns,Ut=>{if(!Ut?.mill_yarn||Ut?.type!=="part")return;const bt=Ut?.part_name;bt&&(a?.[bt]||(a[bt]={name:bt,data:[]}),M+=(0,p.A)(Ut.weight)||0,ot+=(0,p.A)(Ut.total)||0,ut+=(0,p.A)(Ut.price)||0,a[bt]?.data?.push(Ut))}),(0,E.A)(a)&&(a.total={name:"Total",data:[{mill_yarn_name:"Total",mill_yarn:"total",weight:M,total:ot,time:Ct,weightPrice:ut,timePrice:oe}]}),a},[u]),L=(0,n.useMemo)(()=>[{field:"mill_yarn_name",label:"Mill",span:9,renderField:a=>(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",textTransform:a?.mill_yarn==="total"?"uppercase":"inherit",children:a.mill_yarn_name})},{field:"weight",label:"Weight / Time",span:5,renderField:a=>(0,st.A)(a)?(0,t.jsxs)(A.A,{children:["weight"in a&&(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",children:l.A.formatKg(a?.weight)}),"time"in a&&(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",children:l.A.formatMinute(a?.time)})]}):null},{field:"price",label:"Price",span:5,renderField:a=>(0,st.A)(a)?(0,t.jsxs)(A.A,{children:["price"in a&&(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",hidden:!a?.price,translate:"no",children:l.A.formatUsd(a.price)}),"weightPrice"in a&&(0,t.jsxs)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",hidden:!a?.weightPrice,translate:"no",children:[l.A.formatUsd(a?.weightPrice)," / kg"]}),"timePrice"in a&&(0,t.jsxs)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",hidden:!a?.timePrice,translate:"no",children:[l.A.formatUsd(a?.timePrice)," / min"]})]}):null},{field:"total",label:"Total",span:5,renderField:a=>(0,t.jsxs)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",flexDirection:"row",gap:1,alignItems:"center",hidden:!a?.total,translate:"no",children:[l.A.formatUsd(a.total),(0,t.jsx)(zt.A,{children:"Includes margin of error"})]})}],[]);return(0,E.A)(f)?(0,t.jsx)(A.A,{width:"100%",gap:2,children:(0,dt.A)(f,(a,M)=>(0,t.jsx)(vt.A,{label:a?.name,children:(0,t.jsx)(j.Data,{items:a?.data,config:L,...m},M)}))}):(0,t.jsx)(Ft.A,{})}const It=X;function Z(){const{product:m}=j.useContext();return(0,t.jsx)(v.A.Breakdowns,{pricing:m?.pricing?.od,type:d.Th.QUANTITY,borderless:!0,striped:!0,horizontalBordered:!0}
13)}const W=Z;function U(m){const{phasesPricing:u}=j.useContext(),f=(0,n.useMemo)(()=>[{field:"name",label:"Phase",span:9,renderField:L=>(0,t.jsx)(j.Data.Text,{fontWeight:L?.key==="total"?"bold":"inherit",variant:L?.key==="total"?"body1":"body2",textTransform:L?.key==="total"?"uppercase":"inherit",children:L.name})},{field:"time",label:"Time",span:5,renderField:L=>(0,t.jsx)(j.Data.Text,{fontWeight:L?.key==="total"?"bold":"inherit",color:L?.key==="knitting"?"info":"inherit",variant:L?.key==="total"?"body1":"body2",children:l.A.formatMinute(L.time)})},{field:"price",label:"Price / min",span:5,renderField:L=>L?.key==="total"?null:(0,t.jsx)(j.Data.Text,{hidden:!L?.price,translate:"no",children:l.A.formatUsd(L.price)})},{field:"total",label:"Total",span:5,renderField:L=>(0,t.jsxs)(j.Data.Text,{fontWeight:L?.key==="total"?"bold":"inherit",variant:L?.key==="total"?"body1":"body2",flexDirection:"row",alignItems:"center",gap:1,hidden:!L.total,translate:"no",children:[l.A.formatUsd(L.total),L?.key==="knitting"&&(0,t.jsx)(zt.A,{children:"Includes margin of error"})]})}],[]);return(0,t.jsx)(j.Data,{items:u,config:f,...m})}const lt=U;var T=e(8977);function xt({productId:m,...u}){const f=J({productId:m}),{canViewPricingDetails:L}=f;return(0,t.jsx)(j.Provider,{...f,children:(0,t.jsxs)(j.Layout,{...u,children:[(0,t.jsxs)(T.A,{multiple:!0,children:[L&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(T.A.Item,{tab:"settings",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"Settings"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.Settings,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"phases",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"Phases"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.PhasesPricing,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"mills",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"Mills"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.YarnsPricing,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"knit-trims",children:[(0,t.jsx)(T.A.Summary,{children:"Knit Trims"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.KnitTrimsPricing,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"size-surcharges",children:[(0,t.jsx)(T.A.Summary,{children:"Size Surcharges"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.SizeSurcharges,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"color-surcharges",children:[(0,t.jsx)(T.A.Summary,{children:"Colorway Surcharges"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.ColorSurcharges,{})})]})]}),(0,t.jsxs)(T.A.Item,{tab:"variants",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"Variants"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.VariantPricing,{})})]})]}),(0,t.jsx)(j.Totals,{})]})})}const jt=(0,n.createContext)({});function Tt({children:m,...u}){return(0,t.jsx)(jt.Provider,{value:u,children:m})}function Gt(){return(0,n.useContext)(jt)}var Yt=e(17857);function ne({children:m,...u}){const{loading:f}=j.useContext();return(0,t.jsxs)(A.A,{gap:2,...u,children:[!!f&&(0,t.jsx)(Yt.A,{loading:f}),!f&&m]})}function te({productId:m,...u}){const f=J({productId:m});return(0,t.jsx)(j.Provider,{...f,children:(0,t.jsxs)(j.Layout,{...u,children:[(0,t.jsxs)(T.A,{children:[(0,t.jsxs)(T.A.Item,{tab:"bulk",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"BULK Pricing"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.Bulk,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"od",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"OD Pricing"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.Od,{})})]}),(0,t.jsxs)(T.A.Item,{tab:"retail",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"Retail Pricing"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(j.Retail,{})})]})]}),(0,t.jsx)(j.Totals,{})]})})}function Lt(){const{product:m}=j.useContext();return(0,t.jsx)(v.A.Breakdowns,{pricing:m?.pricing?.retail,type:d.Th.QUANTITY,borderless:!0,striped:!0,horizontalBordered:!0})}const tt=Lt;function Vt(){const{product:m}=j.useContext(),u=(0,n.useMemo)(()=>[{name:"Margin of error",value:m?.pricing_auto?.margin_of_error||0,key:"margin_of_error"}],[m]),f=(0,n.useMemo)(()=>[{field:"name",label:"Name",span:12},{field:"value",label:"Value",span:12,renderField:L=>
13L.key==="margin_of_error"?`${(0,p.A)(L.value)||0}%`:L.value}],[]);return(0,t.jsx)(j.Data,{items:u,config:f})}const Dt=Vt;function Et(m){const{sizes:u,pricingDetails:f}=j.useContext(),L=(0,n.useMemo)(()=>(0,h.iC)({sizes:u,surcharges:(0,C.A)(f?.pricing?.surcharges)}),[u,f]),a=(0,n.useMemo)(()=>[{field:"name",label:"Size",span:9,renderField:M=>(0,t.jsx)(j.Data.Text,{children:M?.name})},{field:"yarn",label:"Mill",span:5,renderField:M=>(0,t.jsx)(j.Data.Text,{hidden:!M?.yarn,translate:"no",children:l.A.formatUsd(M?.yarn)})},{field:"knitting",label:"Knitting",span:5,renderField:M=>(0,t.jsx)(j.Data.Text,{hidden:!M?.knitting,translate:"no",children:l.A.formatUsd(M?.knitting)})},{label:"Total",span:5,renderField:M=>(0,t.jsx)(j.Data.Text,{variant:"body1",fontWeight:"bold",translate:"no",hidden:!M?.yarn&&!M?.knitting,children:l.A.formatUsd(((0,p.A)(M?.yarn)||0)+((0,p.A)(M?.knitting)||0))})}],[]);return(0,t.jsx)(j.Data,{items:L,config:a,...m})}const Wt=Et,Nt=(0,mt.A)(A.A)(({theme:m})=>({flexDirection:"row",gap:m.spacing(2),justifyContent:"space-between",alignItems:"center"}));function $t(){const{pricingDetails:m,product:u,canViewPricingDetails:f}=j.useContext(),L=()=>{const a=(0,p.A)(m?.pricing?.phases)||0,M=(0,p.A)(m?.pricing?.inventory)||0;return a+M};return!u?.pricing_auto?.enabled||!f?null:(0,t.jsxs)(A.A,{gap:2,padding:2,children:[(0,t.jsxs)(Nt,{children:[(0,t.jsx)(j.Data.Text,{fontWeight:"bold",children:"Phase Total"}),(0,t.jsx)(j.Data.Text,{fontWeight:"bold",translate:"no",children:l.A.formatUsd(m?.pricing?.phases)})]}),(0,t.jsxs)(Nt,{children:[(0,t.jsx)(j.Data.Text,{fontWeight:"bold",children:"Inventory Total"}),(0,t.jsx)(j.Data.Text,{fontWeight:"bold",translate:"no",children:l.A.formatUsd(m?.pricing?.inventory)})]}),(0,t.jsxs)(Nt,{children:[(0,t.jsx)(j.Data.Text,{variant:"body1",textTransform:"uppercase",fontWeight:"bold",children:"Total"}),(0,t.jsx)(j.Data.Text,{variant:"body1",fontWeight:"bold",translate:"no",children:l.A.formatUsd(L())})]})]})}const he=$t;var Se=e(1259);function k(){const{productId:m,setPickedVariantData:u,pickedVariantData:f,selectedVariant:L}=j.useContext();return(0,t.jsxs)(A.A,{gap:2,children:[(0,t.jsx)(Se.Ay,{entityType:"product",entityId:m,multiple:!1,showColorway:!1,value:f,onChange:u,hideEntitySelect:!0}),!!L?.id&&(0,t.jsxs)(T.A,{children:[(0,t.jsxs)(T.A.Item,{tab:"bulk",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"BULK pricing"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(v.A.Breakdowns,{pricing:L?.pricing?.jit,type:d.Th.SPEND_AMOUNT,borderless:!0,striped:!0,horizontalBordered:!0})})]}),(0,t.jsxs)(T.A.Item,{tab:"od",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"OD Pricing"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(v.A.Breakdowns,{pricing:L?.pricing?.od,type:d.Th.QUANTITY,borderless:!0,striped:!0,horizontalBordered:!0})})]}),(0,t.jsxs)(T.A.Item,{tab:"retail",defaultExpanded:!0,children:[(0,t.jsx)(T.A.Summary,{children:"Retail pricing"}),(0,t.jsx)(T.A.Details,{children:(0,t.jsx)(v.A.Breakdowns,{pricing:L?.pricing?.retail,type:d.Th.QUANTITY,borderless:!0,striped:!0,horizontalBordered:!0})})]})]})]})}const St=k;function qt(m){const{pricingDetails:u}=j.useContext(),f=(0,n.useMemo)(()=>{const a=[];let M=0,ot=0,Ct=0;return(0,it.A)(u?.pricing?.extra?.yarns,ut=>{!ut?.mill_yarn||ut?.type!=="body"||(M+=(0,p.A)(ut.weight)||0,Ct+=(0,p.A)(ut.total)||0,ot+=(0,p.A)(ut.price)||0,a.push(ut))}),a?.length&&a.push({mill_yarn_name:"Total",mill_yarn:"total",weight:M,price:ot,total:Ct}),a},[u]),L=(0,n.useMemo)(()=>[{field:"mill_yarn_name",label:"Mill",span:9,renderField:a=>(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",textTransform:a?.mill_yarn==="total"?"uppercase":"inherit",children:a.mill_yarn_name})},{field:"weight",label:"Weight",span:5,renderField:a=>(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",textTransform:a?.mill_yarn==="total"?"uppercase":"inherit",color:a?.mill_yarn==="total"?"inherit":"teal",children:l.A.formatKg(a.weight)})},{field:"price",label:"Price",span:5,renderField:a=>(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",textTransform:a?.mill_yarn==="total"?"uppercase":"inherit",hidden:!a?.price,translate:"no",children:l.A.formatUsd(a.price)})},{field:"total",label:"Total",span:5,renderField:a=>(0,t.jsx)(j.Data.Text,{fontWeight:a?.mill_yarn==="total"?"bold":"inherit",variant:a?.mill_yarn==="total"?"body1":"body2",textTransform:a?.mill_yarn==="total"?"uppercase":"inherit",hidden:!a?.total,translate:"no",children:l.A.formatUsd(a.total)})}],[]);return(0,t.jsx)(j.Data,{items:f,config:L,...m})}const Kt=qt;gt.Provider=Tt,gt.useContext=Gt,gt.Data=ct,gt.PhasesPricing=lt,gt.KnittingPricing=yt,gt.YarnsPricing=Kt,gt.VariantPricing=St,gt.KnitTrimsPricing=It,gt.SizeSurcharges=Wt,gt.ColorSurcharges=H,gt.Totals=he,gt.Retail=tt,gt.Od=W,gt.Bulk=P,gt.Layout=ne,gt.useProductPricingDetails=J,gt.Auto=xt,gt.Manual
13=te,gt.Settings=Dt;function gt({productId:m,...u}){const f=(0,n.useMemo)(()=>({productId:m}),[m]);return(0,o.G)(a=>(0,h.qM)(a,f))?.pricing_auto?.enabled?(0,t.jsx)(gt.Auto,{productId:m,...u}):(0,t.jsx)(gt.Manual,{productId:m,...u})}const j=gt},64415(re,et,e){e.d(et,{Ay:()=>It});var t=e(96540),n=e(49785),o=e(20588),h=e(25242),i=e(31782);const v=i.Nc.object().shape({qty:i.Nc.number().positive().required(),price:i.Nc.number().positive().required()}),d=i.Nc.object().shape({base:i.Nc.number().positive().required(),breakdowns:i.Nc.array().of(i.Nc.lazy(()=>v))}),c=i.Nc.object().shape({od:d.required(),retail:d.required(),jit:d.required()}),P=i.Nc.lazy(Z=>{const W=!Z?.pricing_auto?.enabled;return i.Nc.object().shape({pricing_manual:W?c:i.Nc.mixed().optional(),pricing_auto:i.Nc.object().shape({enabled:i.Nc.boolean().required(),margin_of_error:W?i.Nc.mixed().optional():i.Nc.number().positive().required()})})});function C({product:Z,values:W,...U}){const lt=(0,t.useMemo)(()=>({pricing_manual:Z?.pricing,pricing_auto:{enabled:h.A.isProd?!1:!!Z?.pricing_auto?.enabled,margin_of_error:Z?.pricing_auto?.margin_of_error}}),[Z]),T=(0,o.mN)({...U,resolver:(0,i.L2)(P),values:{...W,...lt}}),xt=(0,n.FH)({control:T.control,name:"pricing_auto.enabled"});return(0,t.useEffect)(()=>{xt||!T.formState.isDirty||(T.resetField("pricing_manual"),T.resetField("pricing_auto.margin_of_error"))},[xt]),{form:T}}var r=e(74848),l=e(72682),G=e(42985),H=e(2454),$=e(76429),O=e(49497),A=e(22552),q=e(27354);function N({productId:Z}){const W=(0,O.I)(Nt=>Nt.INVENTORY__PRICES__UPDATE),U=(0,G.hS)({canOpen:W}),lt=(0,t.useMemo)(()=>({productId:Z}),[Z]),T=(0,H.G)(Nt=>(0,q.qM)(Nt,lt)),{savedSnackbar:xt}=(0,$.d)(),{useProductPricingDetailsQuery:jt}=A.G,{isLoading:Tt}=jt({productId:Z},{skip:!Z||!U.visible}),{useEditProductPricingMutation:Gt}=A.G,[Yt,{isSuccess:ne,error:te,isLoading:Lt,reset:tt}]=Gt(),Vt=(0,t.useMemo)(()=>(0,l.v)(te),[te]),{form:Dt}=C({product:T,errors:Vt}),Et=Dt.handleSubmit(Nt=>{Z&&Yt({productId:Z,body:Nt})}),Wt=(0,t.useCallback)(()=>{Dt.reset(),tt()},[tt]);return(0,t.useEffect)(()=>{ne&&(xt(),U.close())},[ne]),{productId:Z,modal:U,error:te,onSubmit:Et,reset:Wt,product:T,form:Dt,canEdit:W,loading:Lt||Tt}}var K=e(11201),ct=e(70739);function z({hidden:Z,...W}){const{modal:U,productId:lt,canEdit:T}=It.useContext();return(0,r.jsx)(K.A,{onClick:U.open,shape:"round",startIcon:(0,r.jsx)(ct.A,{}),hidden:Z||!T||!lt,...W})}const nt=(0,t.createContext)({});function b({children:Z,...W}){return(0,r.jsx)(nt.Provider,{value:W,children:Z})}function D(){return(0,t.useContext)(nt)}var J=e(33318),it=e(51825),Y=e(4855),dt=e(74722),mt=e(24401),At=e(16394);function pt({pricingType:Z,control:W,size:U,label:lt="Pricing",withoutBreakdowns:T=!1,...xt}){const jt=`pricing_manual.${Z}`;return(0,r.jsxs)(mt.A,{label:lt,children:[(0,r.jsx)(o.Ay.InputMeasure,{measureUnitKey:"usd",label:"Base price",name:`${jt}.base`,step:10,control:W,size:U,required:!0,...xt}),!T&&(0,r.jsx)(o.Ay.List,{name:`${jt}.breakdowns`,control:W,render:({fields:Tt,name:Gt,remove:Yt,append:ne})=>(0,r.jsxs)(r.Fragment,{children:[(0,dt.A)(Tt,(te,Lt)=>(0,r.jsxs)(o.Ay.List.Item,{children:[(0,r.jsx)(o.Ay.InputMeasure,{name:`${Gt}.${Lt}.price`,label:"Price",control:W,measureUnitKey:"usd",size:U,min:0,step:10,required:!0}),(0,r.jsx)(o.Ay.InputMeasure,{name:`${Gt}.${Lt}.qty`,label:"Quantity",control:W,measureUnitKey:"pcs",size:U,min:0,required:!0}),(0,r.jsx)(At.A,{onClick:()=>Yt(Lt)})]},te.id)),(0,r.jsx)(o.Ay.List.Button,{onClick:()=>ne({price:"",qty:""}),children:"Add breakpoint"})]})})]})}const yt=pt;var p=e(70628);function E({pricingType:Z,control:W,size:U,label:lt="Pricing",breakdownLabel:T="Total Spend",minBreakdownQty:xt=5e3,withoutBreakdowns:jt=!1,breakdownQtyStep:Tt=5e3,...Gt}){const Yt=`pricing_manual.${Z}`;return(0,r.jsxs)(mt.A,{label:lt,children:[(0,r.jsxs)(o.Ay.List.Item,{children:[(0,r.jsx)(o.Ay.InputMeasure,{measureUnitKey:"usd",label:"Price",name:`${Yt}.base`,control:W,step:10,size:U,required:!0,...Gt}),(0,r.jsx)(p.A.Usd,{value:xt,label:T,size:U,disabled:!0}),(0,r.jsx)(At.A,{sx:{visibility:"hidden"}})]}),!jt&&(0,r.jsx)(o.Ay.List,{name:`${Yt}
13.breakdowns`,control:W,render:({fields:ne,name:te,remove:Lt,append:tt})=>(0,r.jsxs)(r.Fragment,{children:[(0,dt.A)(ne,(Vt,Dt)=>(0,r.jsxs)(o.Ay.List.Item,{children:[(0,r.jsx)(o.Ay.InputMeasure,{name:`${te}.${Dt}.price`,label:"Price",control:W,measureUnitKey:"usd",step:10,min:0,size:U,required:!0}),(0,r.jsx)(o.Ay.InputMeasure,{name:`${te}.${Dt}.qty`,label:T,control:W,measureUnitKey:"usd",min:xt,step:Tt,size:U,required:!0}),(0,r.jsx)(At.A,{onClick:()=>Lt(Dt)})]},Vt.id)),(0,r.jsx)(o.Ay.List.Button,{onClick:()=>tt({price:"",qty:xt+Tt*((ne?.length||0)+1)}),children:"Add breakpoint"})]})})]})}const st=E;Ft.Pricing=yt,Ft.TotalSpend=st;function Ft(Z){const{form:W,productId:U,loading:lt}=It.useContext(),T=(0,n.FH)({control:W.control,name:"pricing_auto.enabled"}),xt=(0,H.G)(J.ro);return(0,r.jsxs)(o.Ay,{...Z,children:[!h.A.isProd&&(0,r.jsx)(o.Ay.Switch,{control:W.control,name:"pricing_auto.enabled",label:"Auto Pricing"}),T&&!lt&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.Ay.InputMeasure,{measureUnitKey:"percent",name:"pricing_auto.margin_of_error",label:"Margin of error",control:W.control,max:50}),(0,r.jsx)(it.A.Auto,{productId:U})]}),!T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(yt,{pricingType:Y.rq.ON_DEMAND,label:"On-Demand pricing",control:W.control,size:"small",required:!0}),(0,r.jsx)(st,{pricingType:Y.rq.JUST_IN_TIME,label:"Bulk Pricing",minBreakdownQty:xt,breakdownQtyStep:5e3,size:"small",control:W.control,required:!0}),(0,r.jsx)(yt,{pricingType:Y.rq.RETAIL,label:"Retail pricing",size:"small",control:W.control,withoutBreakdowns:!0,required:!0})]})]})}var vt=e(21548);function zt({loading:Z,...W}){const{modal:U,reset:lt,form:T,onSubmit:xt,loading:jt}=It.useContext();return(0,r.jsx)(G.Ay,{confirmOnClose:T.formState.isDirty,title:"Edit Product Pricing",open:U.visible,onClose:U.close,onTransitionExited:lt,maxWidth:"sm",loading:jt||Z,confirmProps:{children:(0,r.jsx)(vt.A.Message.UnsavedLost,{})},actions:(0,r.jsx)(o.Ay.Submit,{onClick:()=>xt(),children:"Save"}),fullWidth:!0,fullHeight:!0,...W})}X.Provider=b,X.useContext=D,X.Button=z,X.Modal=zt,X.Form=Ft;function X({productId:Z,...W}){const U=N({productId:Z});return(0,r.jsxs)(X.Provider,{...U,children:[(0,r.jsx)(X.Modal,{children:(0,r.jsx)(X.Form,{})}),(0,r.jsx)(X.Button,{...W})]})}const It=X},26284(re,et,e){e.d(et,{A:()=>h});var t=e(74848),n=e(69554);function o({product:i,hidden:v,...d}){return(0,t.jsx)(n.A,{hidden:!i?.is_stk||v,label:"STK",color:"success",...d})}const h=o},8205(re,et,e){e.d(et,{A:()=>P});var t=e(74848),n=e(11201),o=e(427),h=e(49497),i=e(9559),v=e(63385),d=e(34605);function c({productId:C,section:r,hidden:l,params:G,...H}){const $=()=>{if(C)return d.A.setParams({url:i.Ay.productTechPack(C),params:{section:r,...G}})},O=(0,o.A)(),A=$(),q=()=>A?O.redirect(A):void 0,N=(0,h.I)(K=>K.TECH_PACK__READ);return(0,t.jsx)(n.A,{color:"primary",variant:"contained",startIcon:(0,t.jsx)(v.A,{}),hidden:l||!N||!A,onClick:q,...H})}const P=c},21658(re,et,e){e.d(et,{A:()=>G});var t=e(74848),n=e(74722),o=e(77500),h=e(23149),i=e(96540),v=e(72682),d=e(40134),c=e(76429),P=e(54130),C=e(4855),r=e(22552);function l({variant:H,...$}){const{errorSnackbar:O,savedSnackbar:A}=(0,c.d)(),{ACTIVE:q,INACTIVE:N}=C.kV,{useEditVariantMutation:K}=r.G,[ct,{isSuccess:z,error:nt,reset:b,isLoading:D}]=K(),J=({force:dt=0}={})=>{const mt=H?.id;mt&&ct({variantId:mt,body:{status:H?.status===N?q:N,force:dt}})},it=(0,i.useMemo)(()=>nt?(0,n.A)((0,o.A)(nt,["data","inventories"]),"id"):[],[nt]),Y=P.A.useApproveVariantUpdate({inventoryIds:it,onApprove:()=>J({force:1}),loading:D});return(0,i.useEffect)(()=>{z&&(Y.modal.close(),A(),b())},[z]),(0,i.useEffect)(()=>{if(!(0,h.A)(nt)||!("status"in nt))return;const{DISABLED_INVENTORY:dt}=C.fv;if(nt?.status===dt){Y.modal.open();return}O((0,v.u1)(nt))},[nt]),H?.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(d.A,{checked:H?.isActive,loading:D,onClick:()=>J(),...$}),(0,t.jsx)(P.A,{...Y})]}):null}const G=l},94275(re,et,e){e.d(et,{A:()=>te});var t=e(74848),n=e(74722),o=e(24401),h=e(65952),i=e(27447);function v(Lt){const{product:tt,populateSizes:Vt}=te.useContext();return(0,t.jsx)(h.A,{label:"Existed Colorways",gap:2,contentVisible:Vt,fullWidth:!0,...Lt,children:(0,n.A)(tt?.colors,(Dt,Et)=>(0,t.jsx)(o.A,{label:`Colorway ${Et+1}`,children:(0,t.jsx)(i.A.View,{colorway:Dt?.colorway})},Et))})}const d=v;var c=e(21548),P=e(76197),C=e(4855);function r(){const{setFormType:Lt,onlyOS:tt,formType:Vt,form:Dt}=te.useContext();return(0,t.jsx)(P.A,{tab:Vt,onTabChange:Lt,confirmOnChange:Dt.formState.isDirty,confirmProps:{children:(0,t.jsx)(c.A.Message.UnsavedLost,{})},children:(0,t.jsxs)(P.A.List,{children:[(0,t.jsx)(P.A.Tab,{label:"Add size(s) to colorways",value:C.nm.POPULATE_SIZES,disabled:tt}),(0,t.jsx)(P.A.Tab,{label:"Add yarn colors to size(s)",value:C.nm.POPULATE_COLORS}),(0,t.jsx)(P.A.Tab,{label:"Add variants",value:C.nm.CUSTOM})]})})}const l=r;var G=e(39241),H=e(92049),$=e(66401),O=e(89610),A=e(96540),q=e(72682),N=e(42985),K=e(2454),ct=e(49497),z=e(22552),nt=e(27354),b=e(99041),D=e(44251),J=e(92866),it=e(42531),Y=e(66070),dt=e(47360),mt=e(8058),At=e(91235),pt=e(39993),yt=e(20588),p=e(30251),E=e(88489),st=e(9860),Ft=e(51161),vt=e(31782);
13const zt=({validateSizes:Lt,validateColors:tt})=>vt.Nc.object().shape({type:vt.Nc.string().oneOf((0,J.A)(C.nm)).required(),product:vt.Nc.string().required(),colorways:tt?(0,E.SV)():vt.Nc.mixed().nullable(),sizes:Lt?vt.Nc.array().of(vt.Nc.string().trim().required()).min(1):vt.Nc.mixed().nullable()});function X({formType:Lt,brandPartnerIds:tt,onlyOS:Vt,product:Dt,productTechPack:Et,...Wt}){const Nt=Lt===C.nm.POPULATE_COLORS,$t=Lt===C.nm.POPULATE_SIZES,he=(0,A.useMemo)(()=>(0,it.A)([C.nm.POPULATE_SIZES,C.nm.CUSTOM],Lt),[Lt]),Se=Lt===C.nm.POPULATE_COLORS,k=(0,A.useMemo)(()=>({brandPartnerId:tt}),[tt]),St=(0,K.G)(u=>(0,st.n0)(u,k)),qt=(0,K.G)(p.Kb),Kt=(u,f)=>!(0,H.A)(u)||(0,$.A)(u)?[]:(0,Y.A)(f,{mill_yarn:(0,dt.A)(Dt?.millYarns),systemName:(0,dt.A)(u)?.systemName}),gt=(0,A.useMemo)(()=>Vt?(0,G.A)([qt?.id]):(0,Ft._)(Et?.sizeList,{field:"id"}),[Et,Vt,qt]),j=(0,A.useMemo)(()=>{const u=Dt?.defaultVariant?.color?.colorway||[],f=Kt(u,St),L=[];(0,mt.A)(f,ot=>{ot?.yarnId&&(0,At.A)((0,Y.A)(Dt?.variants,ut=>ut?.colorway?.[0]?.yarn===ot.yarnId))!==(0,At.A)(gt)&&L.push(ot)});const a=[],M=(0,At.A)((0,dt.A)(u)?.lycra);return(0,mt.A)(L,ot=>{a.push([{yarn:ot?.yarnId,lycra:(0,pt.A)((0,G.A)(ot?.lycraIds),M)}])}),a},[St,Dt,gt]),m=(0,yt.mN)({...Wt,values:{product:Dt?._id,sizes:Nt?gt:[],colorways:Nt?j:[],type:Lt},resolver:(0,vt.L2)(zt({validateColors:Se,validateSizes:he}))});return(0,A.useEffect)(()=>{m.reset()},[Lt]),{form:m,populateSizes:$t,populateColors:Nt,hasUnusedColors:!!j?.length}}function It({productId:Lt,onCreate:tt,onlyOS:Vt,permission:Dt}){const Et=Vt?C.nm.CUSTOM:C.nm.POPULATE_SIZES,[Wt,Nt]=(0,A.useState)(Et),$t=(0,ct.I)(Dt??(bt=>bt.PRODUCT_VARIANTS__CREATE)),he=(0,N.hS)({canOpen:$t}),Se=(0,A.useMemo)(()=>({productId:Lt}),[Lt]),k=(0,K.G)(bt=>(0,nt.qM)(bt,Se)),St=(0,K.G)(bt=>(0,D.V0)(bt,Se)),{useProductTechPackQuery:qt}=b.Yp,{isLoading:Kt}=qt({productId:Lt},{skip:!he.visible||!Lt}),{useCreateVariantMutation:gt}=z.G,[j,{isSuccess:m,error:u,data:f,reset:L,isLoading:a}]=gt(),M=(0,A.useMemo)(()=>(0,q.v)(u),[u]),ot=X({product:k,productTechPack:St,formType:Wt,brandPartnerIds:(0,G.A)(k?.brand_partners),errors:M}),{form:Ct}=ot,ut=Ct.handleSubmit(bt=>{Lt&&j({body:bt})}),oe=a||Kt,Ut=(0,A.useCallback)(()=>{L(),Ct?.reset(),Nt(Et)},[L]);return(0,A.useEffect)(()=>{m&&(he.close(),(0,H.A)(f?.variants)&&!(0,$.A)(f?.variants)&&(0,O.A)(tt)&&tt((0,n.A)(f?.variants,"_id")))},[m]),{canOpen:$t,productId:Lt,modal:he,error:u,onSubmit:ut,reset:Ut,loading:oe,product:k,onlyOS:Vt,formType:Wt,setFormType:Nt,availableSizeIds:(0,G.A)(St?.sizes),...ot}}var Z=e(11201),W=e(99682);function U({hidden:Lt,onClick:tt,...Vt}){const{modal:Dt,productId:Et,canOpen:Wt}=te.useContext(),Nt=$t=>{(0,O.A)(tt)&&tt($t),Dt.open()};return(0,t.jsx)(Z.A,{variant:"contained",color:"primary",hidden:!Et||Lt||!Wt,onClick:Nt,startIcon:(0,t.jsx)(W.A,{}),...Vt})}const lt=(0,A.createContext)({});function T({children:Lt,...tt}){return(0,t.jsx)(lt.Provider,{value:tt,children:Lt})}function xt(){return(0,A.useContext)(lt)}var jt=e(81662),Tt=e(13689);function Gt(Lt){const{product:tt,form:Vt,availableSizeIds:Dt,onlyOS:Et,populateColors:Wt,populateSizes:Nt,hasUnusedColors:$t,error:he}=te.useContext(),Se=St=>St?Et?!1:!Dt?.includes(St):!0,k=()=>"Add additional sizes to the product TechPack to select them here";return(0,t.jsxs)(yt.Ay,{error:he,...Lt,children:[Wt&&!$t&&(0,t.jsx)(jt.A,{error:"No unused colors found for this yarn",type:"warning"}),!Wt&&(0,t.jsx)(yt.Ay.Item,{name:"sizes",control:Vt.control,render:({field:St,fieldState:qt})=>(0,t.jsx)(Tt.A,{error:qt.invalid,inputRef:St.ref,helperText:qt.error?.message??k(),onlyOS:Et,sizeIsHidden:Se,label:"Sizes",required:!0,multiple:!0,...St,ref:void 0})}),!Nt&&(0,t.jsx)(E.Ay,{name:"colorways",millYarnIds:(0,G.A)(tt?.millYarns),brandPartnerId:(0,G.A)(tt?.brand_partners),disableYarnColors:Wt,control:Vt.control,canAddColorway:!Wt,form:Vt})]})}function Yt({loading:Lt,...tt}){const{modal:Vt,reset:Dt,onSubmit:Et,form:Wt,loading:Nt}=te.useContext();return(0,t.jsx)(N.Ay,{title:"Create Variants",onClose:Vt.close,open:Vt.visible,onTransitionExited:Dt,confirmOnClose:Wt.formState.isDirty,confirmProps:{children:(0,t.jsx)(c.A.Message.UnsavedLost,{})},actions:(0,t.jsx)(yt.Ay.Submit,{onClick:Et,children:"Save"}),maxWidth:620,loading:Nt||Lt,fullWidth:!0,fullHeight:!0,...tt})}ne.Context=lt,ne.Provider=T,ne.useContext=xt,ne.Form=Gt,ne.Button=U,ne.Modal=Yt,ne.ExistedColorways=d;function ne({productId:Lt,onCreate:tt,onlyOS:Vt,permission:Dt,...Et}){const Wt=It({productId:Lt,onCreate:tt,onlyOS:Vt,permission:Dt});return(0,t.jsxs)(T,{...Wt,children:[(0,t.jsxs)(Yt,{children:[(0,t.jsx)(l,{}),(0,t.jsx)(Gt,{}),(0,t.jsx)(d,{})]}),(0,t.jsx)(U,{...Et})]})}const te=ne},97348(re,et,e){e.d(et,{A:()=>Lt});var t=e(74848),n=e(96540),o=e(36197),h=e(2454),i=e(23841),v=e(49497),d=e(32123),c=e(65804),P=e(22552),C=e(27354);function r({variantId:tt,productId:Vt}){const Dt=(0,n.useMemo)(()=>({variantId:tt}),[tt]),Et=(0,h.G)(gt=>(0,C.Ox)(gt,Dt)),Wt=(0,v.I)(gt=>Et?.productType==="swatch"?gt.SWATCH_VARIANTS__READ:gt.PRODUCT_VARIANTS__READ),Nt=(0,o.b)({canOpen:Wt}),{useProductQuery:$t}=P.G,{isFetching:he}=$t({productId:Vt},{skip:!Vt||!Nt.visible}),{isLoading:Se}=c.p.useInventoryFormDataQuery(void 0,{skip:!tt||!Nt.visible}),{isLoading:k}=i.h.useValuesQuery(void 0,{skip:!tt||!Nt.visible}),{isLoading:St}
13=(0,d.M)({skip:!tt||!Nt.visible}),{isFetching:qt}=i.h.useSizesQuery(void 0,{skip:!Vt||!Nt.visible}),{isLoading:Kt}=i.h.useColorsQuery(void 0,{skip:!Vt||!Nt.visible});return{variant:Et,variantId:tt,drawer:Nt,canOpen:Wt,loading:Se||St||k||he||qt||Kt}}var l=e(11201);function G({hidden:tt,...Vt}){const{drawer:Dt,variant:Et,variantId:Wt,canOpen:Nt}=Lt.useContext();return(0,t.jsx)(l.A.Open,{hidden:!Wt||!Nt||tt,onClick:Dt.open,color:Et?.isActive?"inherit":"warning",autoHeight:!0,...Vt})}const H=(0,n.createContext)({});function $({children:tt,...Vt}){return(0,t.jsx)(H.Provider,{value:Vt,children:tt})}function O(){return(0,n.useContext)(H)}var A=e(61230),q=e(21658),N=e(89610),K=e(21548),ct=e(76429),z=e(18342);function nt({variantData:tt,onSuccess:Vt,loading:Dt,hidden:Et,disabled:Wt,...Nt}){const[$t,{isSuccess:he,isError:Se,isLoading:k}]=P.G.useDeleteVariantMutation(),{errorSnackbar:St,savedSnackbar:qt}=(0,ct.d)(),Kt=()=>{tt?.id&&$t(tt.id)},gt=(0,v.I)(j=>tt?.productType==="swatch"?j.SWATCH_VARIANTS__DELETE:j.PRODUCT_VARIANTS__DELETE);return(0,n.useEffect)(()=>{he&&(qt("Variant deleted!"),(0,N.A)(Vt)&&Vt())},[he]),(0,n.useEffect)(()=>{Se&&St("Could not delete variant!")},[Se]),(0,t.jsx)(l.A,{onClick:Kt,loading:k||Dt,hidden:!tt?.id||Et,startIcon:(0,t.jsx)(z.A,{}),color:"error",disabled:Wt||!gt,disabledMessage:"Variant could not be deleted!",confirmProps:{title:"Delete this variant?",children:(0,t.jsx)(K.A.Message.EntityDelete,{entityLabel:"Variant"})},confirmOnClick:!0,...Nt})}const b=nt;var D=e(77273),J=e(30995);function it({loading:tt,...Vt}){const{drawer:Dt,variant:Et,loading:Wt}=Lt.useContext();return(0,t.jsx)(o.A,{isEmpty:!Et?.id,emptyLabel:"Variant not found",title:Et?.name,open:Dt.visible,loading:Wt||tt,onClose:Dt.close,defaultTab:"details",actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D.A,{variantId:Et?.id,children:"Edit"}),(0,t.jsx)(A.A,{children:(0,t.jsx)(b,{variantData:Et,shape:"default",variant:"text",fullWidth:!0,children:"Delete Variant"})})]}),subheader:(0,t.jsxs)(J.A,{flexDirection:"row",gap:1,justifyContent:"space-between",alignItems:"center",children:[(0,t.jsxs)(o.A.TabsList,{children:[(0,t.jsx)(o.A.Tab,{label:"Details",value:"details"}),(0,t.jsx)(o.A.Tab,{label:"Actions",value:"actions"})]}),(0,t.jsx)(q.A,{variant:Et})]}),...Vt})}var Y=e(87164),dt=e(84137),mt=e(17634);function At(tt){const{variantId:Vt}=Lt.useContext(),[Dt,Et]=(0,n.useState)(),Wt=(0,h.G)(C.l6),{isLoading:Nt}=mt.i.useUsersQuery({limit:0},{skip:!Vt}),{useVariantActionsQuery:$t}=P.G,{isLoading:he,pagination:Se}=$t({variantId:Vt,params:Dt},{refetchOnMountOrArgChange:!0,selectFromResult:k=>({pagination:{total:k.data?.total,offset:k.data?.offset,limit:k.data?.limit},isLoading:k.isLoading})});return(0,t.jsx)(dt.A,{actions:Wt,fetching:he||Nt,paginationData:Se,onPaginate:Et,...tt})}const pt=At;var yt=e(91235),p=e(39241),E=e(96759),st=e(42617),Ft=e(29617),vt=e(25692),zt=e(27447);function X({color:tt}){return(0,t.jsx)(E.A,{title:"Colorway",children:tt?.colorway?(0,t.jsx)(zt.A.View,{colorway:tt.colorway}):null})}const It=X;var Z=e(74722),W=e(32943),U=e(3748);function lt({variantInventory:tt,...Vt}){return(0,t.jsx)(W.A,{inventoryId:tt?.item,inventoryType:tt?.data?.type,justifyContent:"space-between",fullWidth:!0,...Vt,children:(0,t.jsxs)(J.A,{flexDirection:"row",gap:1,alignItems:"center",children:[(0,t.jsx)(U.A,{inventory:tt}),tt?.data?.title]})})}const T=lt;xt.Item=T;function xt({variant:tt}){const Vt=(0,n.useMemo)(()=>({variantId:tt?.id}),[tt?.id]),Dt=(0,h.G)(Et=>(0,C.th)(Et,Vt));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.A,{title:"Yarns",value:(0,t.jsx)(t.Fragment,{children:(0,Z.A)(Dt?.yarn,(Et,Wt)=>(0,t.jsx)(T,{variantInventory:Et},`${Wt}_${Et?.item}`))})}),(0,t.jsx)(E.A,{title:"Lycras",value:(0,t.jsx)(t.Fragment,{children:(0,Z.A)(Dt?.lycra,(Et,Wt)=>(0,t.jsx)(T,{variantInventory:Et},`${Wt}_${Et?.item}`))})}),(0,t.jsx)(E.A,{title:"Trims",value:(0,t.jsx)(t.Fragment,{children:(0,Z.A)(Dt?.trim,(Et,Wt)=>(0,t.jsx)(T,{variantInventory:Et},`${Wt}_${Et?.item}`))})}),(0,t.jsx)(E.A,{title:"Labels",value:(0,t.jsx)(t.Fragment,{children:(0,Z.A)(Dt?.label,(Et,Wt)=>(0,t.jsx)(T,{variantInventory:Et},`${Wt}_${Et?.item}`))})})]})}const jt=xt;Tt.InventoryInfo=jt,Tt.ColorInfo=It;function Tt(){const{variant:tt}=Lt.useContext();return(0,t.jsxs)(Y.A,{children:[(0,t.jsx)(E.A,{hidden:!(0,yt.A)(tt?.images),value:(0,t.jsx)(Ft.A,{items:(0,p.A)(tt?.images)})}),(0,t.jsx)(E.A,{title:"Name",value:tt?.name}),(0,t.jsx)(E.A,{title:"SKU",value:tt?.sku}),(0,t.jsx)(E.A,{title:"Size",value:(0,t.jsx)(st.A,{sizeData:tt?.size})}),(0,t.jsx)(It,{color:tt?.color}),(0,t.jsx)(jt,{variant:tt}),(0,t.jsx)(E.A,{title:"Phases",value:(0,t.jsx)(vt.A,{phases:(0,p.A)(tt?.phaseList)})})]})}const Gt=Tt;function Yt(){return(0,t.jsxs)(Y.A,{children:[(0,t.jsx)(o.A.TabPanel,{value:"details",children:(0,t.jsx)(Gt,{})}),(0,t.jsx)(o.A.TabPanel,{value:"actions",children:(0,t.jsx)(pt,{})})]})}const ne=Yt;te.Provider=$,te.useContext=O,te.useVariantDetails=r,te.Tabs=ne,te.Button=G,te.Drawer=it;function te({variantId:tt,productId:Vt,...Dt}){const Et=r({variantId:tt,productId:Vt});return(0,t.jsxs)(te.Provider,{...Et,children:[(0,t.jsx)(te.Drawer,{children:(0,t.jsx)(te.Tabs,{})}),(0,t.jsx)(te.Button,{...Dt})]})}const Lt=te},77273(re,et,e){e.d(et,{A:()=>W,x:()=>c});var t=e(92866),n=e(39241),o=e(74722),h=e(96540),i=e(20588),v=e(4855),d=e(31782);const c=d.Nc.object().shape({type:d.Nc.mixed().optional(),item:d.Nc.string().required(),quantity:d.Nc.number().positive().required(),order:d.Nc.mixed().optional()}),P=d.Nc.object().shape({sku:d.Nc.string().trim().required(),status:d.Nc.string().oneOf((0,t.A)(v.kV)).required(),images:d.Nc.array().of(d.Nc.string().trim().required()).required(),inventory:d.Nc.array().of(c).required().min(1),force:d.Nc.mixed().optional()});function C({variant:U,values:lt,...T}){const xt=(0,h.useMemo)(()=>({sku:U?.sku,status:U?.status,images:(0,n.A)(U?.imageIds),inventory:(0,o.A)(U?.inventory,Tt=>({type:Tt?.type,quantity:Tt?.quantity,item:Tt?.item,order:Tt?.order}))}),[U]);return{form:(0,i.mN)({...T,resolver:(0,d.L2)(P),values:{...lt,...xt}})}}
13var r=e(74848),l=e(72682),G=e(42985),H=e(2454),$=e(76429),O=e(49497),A=e(22552),q=e(27354);function N({variantId:U}){const{savedSnackbar:lt}=(0,$.d)(),T=(0,h.useMemo)(()=>({variantId:U}),[U]),xt=(0,H.G)(Nt=>(0,q.Ox)(Nt,T)),jt=(0,O.I)(Nt=>xt?.productType==="swatch"?Nt.SWATCH_VARIANTS__UPDATE:Nt.PRODUCT_VARIANTS__UPDATE),Tt=(0,G.hS)({canOpen:jt}),{useEditVariantMutation:Gt}=A.G,[Yt,{isSuccess:ne,error:te,reset:Lt,isLoading:tt}]=Gt(),Vt=(0,h.useMemo)(()=>(0,l.v)(te),[te]),{form:Dt}=C({variant:xt,errors:Vt}),Et=({force:Nt=0}={})=>{U&&Dt.handleSubmit($t=>Yt({variantId:U,body:{...$t,force:Nt}}))()},Wt=(0,h.useCallback)(()=>{Dt.reset(),Lt()},[Lt]);return(0,h.useEffect)(()=>{ne&&(Tt.close(),lt())},[ne]),{variantId:U,modal:Tt,error:te,onSubmit:Et,reset:Wt,variant:xt,form:Dt,canOpen:jt,loading:tt}}var K=e(11201),ct=e(70739);function z({hidden:U,...lt}){const{modal:T,variantId:xt,canOpen:jt}=W.useContext();return(0,r.jsx)(K.A,{onClick:T.open,color:"primary",variant:"contained",hidden:!xt||!jt||U,startIcon:(0,r.jsx)(ct.A,{}),...lt})}const nt=(0,h.createContext)({});function b({children:U,...lt}){return(0,r.jsx)(nt.Provider,{value:lt,children:U})}function D(){return(0,h.useContext)(nt)}var J=e(21548);function it({loading:U,...lt}){const{modal:T,reset:xt,form:jt,onSubmit:Tt,loading:Gt}=W.useContext();return(0,r.jsx)(G.Ay,{maxWidth:"sm",onClose:T.close,open:T.visible,loading:Gt||U,title:"Edit Variant",onTransitionExited:xt,confirmOnClose:jt.formState.isDirty,confirmProps:{children:(0,r.jsx)(J.A.Message.UnsavedLost,{})},actions:(0,r.jsx)(i.Ay.Submit,{onClick:()=>Tt(),children:"Save"}),fullWidth:!0,...lt})}var Y=e(77500),dt=e(23149),mt=e(54130),At=e(51161),pt=e(24401),yt=e(69610),p=e(23645),E=e(61774);const st={[v.kV.ACTIVE]:{value:v.kV.ACTIVE,label:(0,p.A)(v.kV.ACTIVE)},[v.kV.INACTIVE]:{value:v.kV.INACTIVE,label:(0,p.A)(v.kV.INACTIVE)}};function Ft(U){const lt=(0,h.useMemo)(()=>(0,At._)(st,{field:"value"}),[]);return(0,r.jsx)(E.A,{options:lt,getOptionLabel:T=>st[T]?.label||"",...U})}const vt=Ft;function zt({variant:U,form:lt,...T}){return(0,r.jsxs)(i.Ay,{...T,children:[(0,r.jsx)(i.Ay.Input,{label:"SKU",control:lt.control,name:"sku",required:!0}),(0,r.jsx)(i.Ay.Item,{name:"status",control:lt.control,render:({field:xt,fieldState:jt})=>(0,r.jsx)(vt,{error:jt.invalid,inputRef:xt.ref,helperText:jt.error?.message,required:!0,...xt,ref:void 0})}),(0,r.jsx)(i.Ay.Images,{name:"images",label:"Images",control:lt.control,initialTags:(0,n.A)([U?.productName])}),(0,r.jsx)(pt.A,{label:"Inventories",children:(0,r.jsx)(yt.A,{name:"inventory",control:lt.control})})]})}X.View=zt;function X(U){const{variant:lt,form:T,error:xt,onSubmit:jt,loading:Tt}=W.useContext(),Gt=(0,h.useMemo)(()=>(0,At._)((0,Y.A)(xt,["data","inventories"]),{field:"id"}),[xt]),Yt=mt.A.useApproveVariantUpdate({inventoryIds:Gt,onApprove:()=>jt({force:1}),loading:Tt});return(0,h.useEffect)(()=>{!(0,dt.A)(xt)||!("status"in xt)||xt?.status===v.fv.DISABLED_INVENTORY&&Yt.modal.open()},[xt]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(X.View,{variant:lt,form:T,...U}),(0,r.jsx)(mt.A,{...Yt})]})}const It=X;Z.Context=nt,Z.Provider=b,Z.useContext=D,Z.Form=It,Z.Button=z,Z.Modal=it,Z.useVariantEdit=N;function Z({variantId:U,...lt}){const T=N({variantId:U});return(0,r.jsxs)(Z.Provider,{...T,children:[(0,r.jsx)(Z.Modal,{children:(0,r.jsx)(Z.Form,{})}),(0,r.jsx)(z,{...lt})]})}const W=Z},17138(re,et,e){e.d(et,{A:()=>G});var t=e(74848),n=e(39241),o=e(41343),h=e(74722),i=e(96540),v=e(56432),d=e(52723),c=e(30995),P=e(33551),C=e(51161),r=e(34605);function l({variant:H}){const $=(0,i.useMemo)(()=>{const O=(0,n.A)(Array.isArray(H)?H:[H]);return(0,o.A)((0,C._)(O,{field:"errorMessage"}))},[H]);return!r.A.isAdminZone()||!$.length?null:(0,t.jsx)(v.A,{title:(0,t.jsx)(c.A,{children:(0,h.A)($,(O,A)=>(0,t.jsx)(P.A,{children:O},A))}),children:(0,t.jsx)(d.A,{color:"error",fontSize:"small"})})}const G=l},69610(re,et,e){e.d(et,{A:()=>z,g:()=>ct});var t=e(74848),n=e(1694),o=e(74722),h=e(96540),i=e(20588),v=e(16394),d=e(2454),c=e(85567),P=e(9860),C=e(42531),r=e(84549),l=e(27354);function G({variantId:nt,disabledInventories:b,...D}){const J=(0,h.useMemo)(()=>({variantId:nt}),[nt]),it=(0,d.G)(mt=>(0,l.Ox)(mt,J)),Y=(0,d.G)(P.bM),dt=mt=>{if(!mt||Array.isArray(b)&&b.includes(mt))return!0;const At=Y[mt];return At?.brandPartnerId&&Array.isArray(it?.brandPartnerIds)&&it?.brandPartnerIds.length?!(0,C.A)(it?.brandPartnerIds,At.brandPartnerId):!1};return(0,t.jsx)(r.A,{getOptionDisabled:dt,...D})}const H=G;var $=e(33551),O=e(92645),A=e(51161);function q({name:nt,variant:b,control:D,disabledInventories:J,showTitles:it=!0,buttonLabel:Y="Add inventory",...dt}){const mt=(0,d.G)(P.bM),At=(0,i.FH)({name:nt,control:D}),pt=(0,h.useMemo)(()=>{const X=(0,A._)(At,{field:"item"});return Array.isArray(J)?[...J,...X]:X},[J,At]),yt=X=>{if(Array.isArray(At))return At[X]},p=X=>yt(X)?.type,E=X=>{const It=p(X);return It!==c.gK.LYCRA&&It!==c.gK.YARN},st=X=>p(X)===c.gK.YARN,Ft=X=>{const It=p(X);return P.WW[It||"trim"]},vt=X=>{const It=yt(X)?.item;if(!It)return!1;const Z=mt[It];return Z?.type?Z.type===c.gK.LYCRA||Z.type===c.gK.YARN:!1},zt=X=>(0,n.A)(yt(X)?.order)||0;return(0,t.jsx)(i.Ay.List,{name:nt,control:D,render:({fields:X,append:It,remove:Z})=>(0,t.jsxs)(t.Fragment,{children:[(0,o.A)(X,(W,U)=>{const lt=vt(U),T=p(U),xt=E(U),jt=st(U),Tt=U>0?E(U-1):!1;return(0,t.jsxs)(h.Fragment,{children:[it&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)($.A,{fontWeight:"bold",variant:"body2",hidden:!jt,children:["Yarn\xA0",O.A.numberToLetter(zt(U)+1)]}),(0,t.jsx)($.A,{fontWeight:"bold",variant:"body2",hidden:!xt||Tt,children:"Trims and Labels"})]}),(0,t.jsxs)(i.Ay.List.Item,{children:[(0,t.jsx)(i.Ay.Item,{control:D,name:`${nt}.${U}.item`,render:({field:Gt,fieldState:Yt})=>(0,t.jsx)(H,{error:Yt.invalid,label:"Inventory",helperText:Yt.error?.message,disabledInventories:pt,variantId:b?.id,disabled:lt,withYarns:lt,withLycras:lt,inputRef:Gt.ref,fullWidth:!0,required:!0,...Gt})}),(0,t.jsx)(i.Ay.InputMeasure,{sx:{minWidth:110,maxWidth:110},label:Ft(U)?.title,name:`${nt}.${U}.quantity`,endAdornment:!1,control:D,disabled:lt,size:"small",measureUnitKey:T?P.WW[T]?.name:P.WW.trim?.name,required:!0}),(0,t.jsx)(v.A,{onClick:()=>Z(U),disabled:lt})]})]},W.id)}),(0,t.jsx)(i.Ay.List.Button,{onClick:()=>It({quantity:1,item:""}),disabled:!!X?.length&&!yt(X.length-1)?.item,children:Y})]}),...dt})}var N=e(31782);const K=N.Nc.object().shape({item:N.Nc.string().required(),quantity:N.Nc.number().positive().required(),type:N.Nc.mixed().optional(),order:N.Nc.mixed().optional()}),ct=N.Nc.array().of(K),z=q},26314(re,et,e){e.d(et,{A:()=>yt});var t=e(74848),n=e(96540),o=e(2454),h=e(27354),i=e(54346),v=e(8058),d=e(69115),c=e(57456),P=e(42531),C=e(74722),r=e(39241),l=e(8977),G=e(62287),H=e(21658),$=e(97348),O=e(17138),A=e(30995),q=e(34605),N=e(42617),K=e(33551),ct=e(27558),z=e(11848);const nt=(0,z.A)(K.A)(({theme:p})=>({...p.mixins.allBreakable})),b=(0,z.A)(A.A,{shouldForwardProp:p=>p!=="selectable"})(({theme:p,selectable:E})=>[{borderRadius:p.shape.borderRadius},E&&{cursor:"pointer","&:hover":{backgroundColor:p.palette.mask.light}}]);function D({variant:p,onSelect:E,selected:st,selectable:Ft,...vt}
13){const zt=()=>{!Ft||!p?.id||E?.(!st,p.id)};return(0,t.jsxs)(b,{flexDirection:"row",gap:1,alignItems:"center",onClick:zt,selectable:Ft,width:"100%",...vt,children:[Ft&&(0,t.jsx)(ct.A,{checked:st}),(0,t.jsx)(N.A,{sizeData:p?.size,color:p?.isActive?"info":"warning"}),(0,t.jsx)(nt,{overflow:"hidden",children:p?.sku})]})}const J=D;var it=e(20440);const Y=(0,z.A)(K.A)(({theme:p})=>({...p.mixins.allBreakable}));function dt({variants:p,color:E,children:st,hideSizes:Ft,selectable:vt,onSelect:zt,indeterminate:X,selected:It,...Z}){return(0,t.jsxs)(A.A,{flexDirection:"row",alignItems:"center",gap:1,...Z,children:[!!vt&&(0,t.jsx)(ct.A,{checked:It,indeterminate:X,onChange:zt,onClick:W=>W.stopPropagation()}),(0,t.jsx)(O.A,{variant:p}),(0,t.jsx)(it.A,{color:E}),(0,t.jsxs)(A.A,{flex:1,justifyContent:"space-between",gap:.5,children:[(0,t.jsx)(Y,{overflow:"hidden",children:st}),(0,t.jsx)(A.A,{hidden:Ft,flexWrap:"wrap",flexDirection:"row",gap:.5,children:(0,C.A)(p,W=>(0,t.jsx)(N.A,{sizeData:W?.size,color:W?.isActive?"info":"warning"},W?.id))})]})]})}const mt=dt;function At({groupedVariants:p,selectable:E,value:st,onChange:Ft,...vt}){const[zt,X]=(0,n.useState)([]),[It,Z]=(0,G.P)({value:st,onChange:Ft}),W=(0,n.useCallback)(xt=>{const jt={selected:!1,indeterminate:!1};if(!Array.isArray(p?.[xt]?.variants))return jt;const Tt=(0,i.A)(p?.[xt]?.variants,"id");let Gt=0;if((0,v.A)(It,ne=>{Tt?.[ne]&&(Gt+=1)}),!Gt)return jt;const Yt=p[xt]?.variants?.length||0;return jt.selected=Gt>=Yt,jt.indeterminate=Yt>Gt,jt},[It,p]),U=xt=>jt=>{const Tt=[];(0,v.A)(p?.[xt]?.variants,Gt=>{Gt?.id&&Tt.push(Gt?.id)}),Z(Gt=>jt?.target?.checked?Tt?.length?(0,d.A)(Gt,Tt):Gt:(0,c.A)(Gt,...Tt))},lt=(xt,jt)=>{Z(Tt=>xt?[...Tt||[],jt]:(0,c.A)(Tt,jt))},T=xt=>(0,P.A)(It,xt);return(0,t.jsx)(l.A,{activeTabs:zt,setActiveTabs:X,multiple:!0,...vt,children:(0,C.A)(p,(xt,jt)=>(0,t.jsxs)(l.A.Item,{tab:jt,children:[(0,t.jsx)(l.A.Summary,{children:(0,t.jsx)(mt,{variants:(0,r.A)(xt?.variants),color:xt?.color,hideSizes:zt.includes(jt),onSelect:U(jt),selectable:E,...W(jt),children:jt})}),(0,t.jsx)(l.A.Details,{children:(0,C.A)(xt?.variants,(Tt,Gt)=>(0,t.jsxs)(A.A,{flexDirection:"row",alignItems:"center",sx:Yt=>({borderBottom:Yt.border.solid(1),"&:first-of-type":{borderTop:Yt.border.solid(1)}}),gap:1,children:[!E&&(0,t.jsx)($.A,{variantId:Tt?.id,shape:"default",justifyContent:"space-between",color:"inherit",fullWidth:!0,children:(0,t.jsx)(J,{variant:Tt})}),!!E&&(0,t.jsx)(J,{variant:Tt,onSelect:lt,selected:T(Tt?.id),selectable:!0}),q.A.isAdminZone()&&(0,t.jsxs)(A.A,{flexDirection:"row",gap:.5,children:[(0,t.jsx)(O.A,{variant:Tt}),(0,t.jsx)(H.A,{variant:Tt,disabled:!Tt?.isActive&&Tt?.hasErrors})]})]},Gt))})]},jt))})}pt.View=At;function pt({productId:p,withInactive:E=!0,...st}){const Ft=(0,n.useMemo)(()=>({withInactive:E,productId:p}),[p,E]),vt=(0,o.G)(zt=>(0,h.wW)(zt,Ft));return(0,t.jsx)(pt.View,{groupedVariants:vt,...st})}const yt=pt},55018(re,et,e){e.d(et,{A:()=>Ae});var t=e(74848),n=e(74722),o=e(24978),h=e(90973),i=e(59116),v=e(66070),d=e(8058),c=e(96540),P=e(11201),C=e(61230),r=e(2454),l=e(85567),G=e(27354);function H({variantId:S,inventoryId:R,...ft}){const rt=(0,c.useMemo)(()=>({variantId:S}),[S]),Mt=(0,r.G)(Te=>(0,G.Ox)(Te,rt)),{setMatrixData:Ht,setEdited:Qt}=Ae.useContext(),se=({needCopy:Te}={})=>{Qt(!0),Ht(Xt=>{const De=$({variantId:S,inventoryId:R,needCopy:Te,variants:Xt?.variants});return{...Xt,variants:De}})},wt=()=>se({needCopy:(Xt,De)=>!!De?.color_id&&De.color_id===Xt?.color_id}),Jt=()=>se({needCopy:(Xt,De)=>!!De?.size_id&&De.size_id===Xt?.size_id});return(0,t.jsxs)(C.A,{...ft,children:[(0,t.jsxs)(P.A,{variant:"text",onClick:wt,children:["All \u201D",Mt?.colorName,"\u201D variants"]}),(0,t.jsxs)(P.A,{variant:"text",onClick:Jt,children:["All \u201D",Mt?.sizeName,"\u201D variants"]}),(0,t.jsx)(P.A,{variant:"text",onClick:()=>se(),children:"All variants"})]})}function $({variantId:S,inventoryId:R,needCopy:ft,variants:rt}){const Mt=S?rt?.[S]:void 0;if(!Mt?.variant_id)return;const Ht=R?(0,h.A)(Mt.data?.inventory,{item:R}):void 0,{LYCRA:Qt,YARN:se}=l.gK,wt=()=>(0,i.A)(rt,Jt=>{if(!Ht?.item||ft&&!ft(Mt,Jt)||Jt?.variant_id===Mt.variant_id||(0,h.A)(Jt.data?.inventory,{item:Ht.item}))return Jt;const Xt=Jt.data?.inventory||[];return{...Jt,data:{...Jt?.data,inventory:[...Xt,Ht]}}});return Ht?.item?wt():(0,i.A)(rt,Jt=>{if(ft&&!ft(Mt,Jt)||Jt?.variant_id===Mt.variant_id)return Jt;const Te=(0,v.A)(Jt.data?.inventory,Xt=>Xt?.type===Qt||Xt.type===se);return(0,d.A)(Mt.data?.inventory,Xt=>{Xt?.type===Qt||Xt.type===se||Te.push(Xt)}),{...Jt,data:{...Jt?.data,inventory:Te}}})}const O=H;var A=e(23149),q=e(39241),N=e(42985),K=e(76429),ct=e(23841),z=e(49497),nt=e(32123),b=e(65804),D=e(22552),J=e(99041),it=e(44251);function Y({productId:S,permission:R}){const[ft,rt]=(0,c.useState)(!1),[Mt,Ht]=(0,c.useState)(!1),[Qt,se]=(0,c.useState)(),[wt,Jt]=(0,c.useState)(),{savedSnackbar:Te}=(0,K.d)(),Xt=(0,c.useMemo)(()=>({productId:S}),[S]),De=(0,r.G)(Ce=>(0,G.n0)(Ce,Xt)),Rt=(0,r.G)(Ce=>(0,G.qM)(Ce,Xt)),Ie=(0,r.G)(Ce=>(0,it.V0)(Ce,Xt)),ge=(0,z.I)(R??(Ce=>Ce.PRODUCT_VARIANTS__UPDATE)),Re=(0,N.hS)({canOpen:ge}),{visible:be}=Re,ue=(0,c.useCallback)(()=>{rt(!1),Ht(!1),se(void 0)},[]),{useProductTechPackQuery:rn}=J.Yp,{techPackLoading:$e}=rn({productId:S},{skip:!be||!S,refetchOnMountOrArgChange:!0,selectFromResult:Ce=>({techPackLoading:Ce.isLoading})}),{isFetching:Je}=ct.h.useSizesQuery(void 0,{skip:!be||!S}),{isLoading:ke}=b.p.useInventoryFormDataQuery(void 0,{skip:!be||!S}),{isLoading:ln}=(0,nt.M)({skip:!be||!S,skipYarns:!0,skipLycras:!0}),{isLoading:cn}=ct.h.useColorsQuery(void 0,{skip:!be||!S}),{useEditVariantsMutation:An}=D.G,[gn,{isLoading:hn,isSuccess:un,isError:mn}]=An(),dn=hn||$e||cn||ke||ln||Je,Ot=()=>Ht(!0),kt=()=>{const Ce=[];return(0,d.A)(Qt?.variants,Ge=>{Ge?.variant_id&&Ce.push({variant_id:Ge?.variant_id,data:Ge?.data})}),{...Qt,variants:Ce,yarn_consumption:wt}},Zt=()=>{Ht(!1),gn({body:kt()})},ae=()=>
13{if(!Rt?.id||!(0,A.A)(Rt?.variants))return;const Ce={};(0,d.A)(Rt.variants,Ge=>{Ge?.id&&(Ce[Ge.id]={variant_id:Ge.id,color_id:Ge.colorId,size_id:Ge.sizeId,data:{inventory:(0,q.A)(Ge.inventory)}})}),se({variants:Ce})},Ee=Ce=>Ce?Qt?.variants?.[Ce]?.data:void 0,en=({variantId:Ce,data:Ge})=>{Ht(!0),Ce&&se(fn=>{if(!fn?.variants?.[Ce])return;const Cn=fn?.variants?.[Ce];return{...fn,variants:{...fn?.variants,[Ce]:{...Cn,data:Ge}}}})};return(0,c.useEffect)(()=>{!be||!Rt?.id||!Ie?.id||dn||(ae(),Jt(Ie?.yarn_consumption))},[be,Rt?.id,Ie?.id,dn]),(0,c.useEffect)(()=>{un&&(Te(),Re.close())},[un]),(0,c.useEffect)(()=>{mn&&Ht(!0)},[mn]),{edited:Mt,canOpen:ge,setEdited:Ht,setLoading:rt,productId:S,onSave:Zt,matrix:De,product:Rt,onValuesChange:Ot,modal:Re,techPack:Ie,reset:ue,matrixData:Qt,setMatrixData:se,getVariantData:Ee,setVariantData:en,matrixConsumption:wt,setMatrixConsumption:Jt,loading:ft||dn}}var dt=e(46942),mt=e.n(dt),At=e(30995);function pt({className:S,...R}){const ft=mt()("VariantMatrix",S);return(0,t.jsx)(At.A,{width:"max-content",className:ft,...R})}const yt=pt;var p=e(35704),E=e(1694),st=e(70628),Ft=e(35720),vt=e(9860);function zt({yarnKey:S,sizeId:R,...ft}){const[rt,Mt]=(0,c.useState)(0),{setEdited:Ht,setMatrixData:Qt,matrixConsumption:se,setMatrixConsumption:wt}=Ae.useContext(),Jt=vt.WW[Ft.g.LYCRA],Te=Rt=>{R&&Qt(Ie=>{const ge=Ie?.variants;return(0,d.A)(ge,Re=>{Re?.size_id===R&&(0,d.A)(Re?.data?.inventory,(be,ue)=>{be?.type!==Ft.g.LYCRA||be?.order!==S||(0,p.A)(ge||{},[Re?.variant_id,"data","inventory",ue,"quantity"],Rt)})}),{...Ie}})},Xt=Rt=>{wt(Ie=>{const ge=Ie?.yarns?.[S],Re=(0,h.A)(ge?.data,"isBase")?.sizeData,be=Re?.order||0,rn=(0,h.A)(ge?.data,{size:R})?.sizeData?.order||0;return(0,d.A)(ge?.data,($e,Je)=>{if(!$e?.size)return;const ke=$e?.sizeData?.order||0,ln=be>rn&&rn>=ke,cn=be<rn&&rn<=ke;(Re?.id===R||ln||cn)&&!$e?.overwrite&&(0,p.A)(ge||{},["data",Je,"overwrite"],!0),$e.size===R&&(0,p.A)(ge||{},["data",Je,"lycra"],Rt)}),{...Ie}})},De=Rt=>{Mt((0,E.A)(Rt)||0),Ht(!0),Xt((0,E.A)(Rt)||0)};return(0,c.useEffect)(()=>{const Rt=se?.yarns?.[S];(0,d.A)(Rt?.data,Ie=>{Ie?.size===R&&Mt(Ie?.lycra||0)})},[se,S]),(0,c.useEffect)(()=>{Te(rt)},[rt]),(0,t.jsx)(st.A,{unit:Jt,onChange:De,value:rt,min:0,...ft})}const X=zt;function It({className:S,...R}){const ft=mt()("MatrixBody",S);return(0,t.jsx)(At.A,{height:"100%",zIndex:1,flexGrow:1,margin:"0 auto",gap:2,className:ft,...R})}const Z=It;var W=e(85692),U=e(64155),lt=e(87164),T=e(11848);const xt=(0,T.A)(At.A,{shouldForwardProp:S=>S!=="isEmpty"})(({theme:S,isEmpty:R})=>[{borderRadius:S.shape.borderRadius,border:S.border.solid(1)},R&&{...S.mixins.invisible}]),jt=(0,c.memo)(function({className:R,children:ft,footer:rt,header:Mt,forwardedRef:Ht,inView:Qt,...se}){const wt=!(0,c.isValidElement)(ft)&&!Array.isArray(ft),Jt=mt()("MatrixCell",R);return(0,t.jsx)(xt,{className:Jt,ref:Ht,isEmpty:wt,justifyContent:"center",gap:1.5,padding:1.5,alignItems:"center",width:375,component:U.A,minHeight:50,...se,children:Qt&&(0,t.jsxs)(t.Fragment,{children:[!!Mt&&(0,t.jsx)(lt.A,{width:"100%",children:Mt}),(0,t.jsx)(At.A,{flex:1,width:"100%",gap:2,children:ft}),!!rt&&(0,t.jsx)(lt.A,{width:"100%",children:rt})]})})},(S,R)=>!R.inView);function Tt(S){const{ref:R,inView:ft}=(0,W.Wx)();return(0,t.jsx)(jt,{inView:ft,forwardedRef:R,...S})}const Gt=Tt;var Yt=e(33551),ne=e(92645);function te(){const{matrix:S,techPack:R}=Ae.useContext();return(0,t.jsx)(At.A,{className:"MatrixHeader",flexDirection:"row",zIndex:2,position:"sticky",component:U.A,boxShadow:0,top:0,margin:"0 auto",paddingTop:1,paddingBottom:1,borderRadius:0,gap:2,children:(0,t.jsx)(Ae.Row,{children:(0,n.A)(S?.sizes,(ft,rt)=>(0,t.jsx)(Ae.Cell,{header:(0,t.jsx)(Yt.A,{variant:"h6",textAlign:"center",margin:0,children:ft?.name}),children:(0,n.A)(R?.millYarns,(Mt,Ht)=>(0,t.jsxs)(At.A,{alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%",gap:1,children:[(0,t.jsx)(Ae.YarnConsumption,{yarnKey:Ht,label:`Yarn ${ne.A.numberToLetter(Ht+1)}`,sizeId:ft?.id}),(0,t.jsx)(Ae.LycraConsumption,{yarnKey:Ht,label:`Lycra ${ne.A.numberToLetter(Ht+1)}`,sizeId:ft?.id})]},Ht))},`${ft?.id}_${rt}`))})})}const Lt=te;function tt({className:S,...R}
13){const ft=mt()("MatrixRow",S);return(0,t.jsx)(At.A,{flexDirection:"row",gap:2,className:ft,...R})}const Vt=tt;var Dt=e(21548),Et=e(72682),Wt=e(20588),Nt=e(88489),$t=e(31782);const he=$t.Nc.object().shape({colorways:(0,Nt.SV)()});function Se(S={}){return{form:(0,Wt.mN)({...S,resolver:(0,$t.L2)(he)})}}function k({productId:S}){const R=(0,N.hS)(),{errorSnackbar:ft,savedSnackbar:rt}=(0,K.d)(),Mt=(0,c.useMemo)(()=>({productId:S}),[S]),Ht=(0,r.G)(ue=>(0,G.Ty)(ue,Mt)),Qt=(0,r.G)(ue=>(0,G.qM)(ue,Mt)),{useEditProductColorwaysMutation:se}=D.G,[wt,{isLoading:Jt,isError:Te,isSuccess:Xt,error:De,reset:Rt}]=se(),Ie=(0,c.useMemo)(()=>(0,Et.v)(De),[De]),{form:ge}=Se({values:{colorways:Ht},errors:Ie}),Re=ge.handleSubmit(ue=>{if(S)return wt({body:ue,productId:S})}),be=(0,c.useCallback)(()=>{Rt(),ge.reset()},[Rt]);return(0,c.useEffect)(()=>{Te&&ft("Failed to edit colorways")},[Te]),(0,c.useEffect)(()=>{Xt&&(rt(),R.close())},[Xt]),{product:Qt,productId:S,modal:R,loading:Jt,reset:be,onSubmit:Re,error:De,form:ge}}var St=e(70739);function qt({hidden:S,...R}){const{modal:ft,productId:rt}=L.useContext();return(0,t.jsx)(P.A,{color:"primary",variant:"contained",startIcon:(0,t.jsx)(St.A,{}),onClick:ft?.open,hidden:!rt||S,...R})}const Kt=(0,c.createContext)({});function gt({children:S,...R}){return(0,t.jsx)(Kt.Provider,{value:R,children:S})}function j(){return(0,c.useContext)(Kt)}function m(S){const{product:R,form:ft,error:rt}=L.useContext();return(0,t.jsx)(Wt.Ay,{error:rt,...S,children:(0,t.jsx)(Nt.Ay,{control:ft.control,form:ft,name:"colorways",millYarnIds:(0,q.A)(R?.millYarns),brandPartnerId:R?.brandPartnerId,canDeleteColorway:!1,canAddColorway:!1,disableYarnColors:!0})})}function u({loading:S,...R}){const{product:ft,modal:rt,reset:Mt,form:Ht,onSubmit:Qt,loading:se}=L.useContext();return(0,t.jsx)(N.Ay,{maxWidth:"sm",onClose:rt.close,open:rt.visible,loading:se||S,title:ft?.sku,onTransitionExited:Mt,confirmOnClose:Ht.formState.isDirty,confirmProps:{children:(0,t.jsx)(Dt.A.Message.UnsavedLost,{})},actions:(0,t.jsx)(Wt.Ay.Submit,{onClick:Qt,children:"Save"}),fullHeight:!0,fullWidth:!0,...R})}f.Form=m,f.OpenButton=qt,f.Modal=u,f.useProductColorways=k,f.Provider=gt,f.Context=Kt,f.useContext=j;function f({productId:S,...R}){const ft=k({productId:S});return(0,t.jsxs)(f.Provider,{...ft,children:[(0,t.jsx)(f.Modal,{children:(0,t.jsx)(f.Form,{})}),(0,t.jsx)(f.OpenButton,{...R})]})}const L=f;function a({className:S,loading:R,...ft}){const{onSave:rt,reset:Mt,edited:Ht,product:Qt,modal:se,loading:wt}=Ae.useContext(),Jt=mt()("VariantMatrix__Modal",S),Te=wt||R;return(0,t.jsx)(N.Ay,{open:se.visible,className:Jt,loading:Te,onClose:se.close,onTransitionExited:Mt,contentSx:{paddingTop:0},title:Qt?.sku,headerActions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(L,{productId:Qt?.id,variant:"contained",disabled:Te,children:"Edit Lycras"}),(0,t.jsx)(P.A,{variant:"contained",color:"primary",onClick:rt,disabled:Te||!Ht,children:"Save"})]}),confirmOnClose:Ht,confirmProps:{children:(0,t.jsx)(Dt.A.Message.UnsavedLost,{})},fullScreen:!0,...ft})}const M=a;var ot=e(89610),Ct=e(15302);function ut({children:S,className:R,...ft}){const{modal:rt,canOpen:Mt}=Ae.useContext();if(!Mt)return null;if((0,ot.A)(S))return S({open:rt.open,close:rt.close,visible:rt.visible});const Ht=mt()("VariantMatrix__OpenButton",R);return(0,t.jsx)(P.A,{onClick:rt.open,className:Ht,startIcon:(0,t.jsx)(Ct.A,{}),...ft,children:S})}const oe=ut;var Ut=e(20440),bt=e(21658);function de({variantId:S,children:R}){const ft=(0,c.useMemo)(()=>({variantId:S}),[S]),rt=(0,r.G)(Mt=>(0,G.Ox)(Mt,ft));return(0,t.jsxs)(At.A,{className:"VariantCellHeader",hidden:!rt?.id,width:"100%",gap:1,children:[(0,t.jsxs)(At.A,{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:1,width:"100%",children:[(0,t.jsx)(Ut.A,{color:rt?.color}),R,(0,t.jsx)(Ae.VariantCellEdit,{variantId:S})]}),(0,t.jsxs)(At.A,{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:1,width:"100%",children:[(0,t.jsx)(Yt.A,{children:rt?.sku}),(0,t.jsx)(bt.A,{variant:rt,size:"small"})]})]})}const Pe=de;var xe=e(24401),Fe=e(55629),ie=e(9703);function Bt({colorway:S}){const R=(0,ie.A)(S?.yarn)?S?.yarn:S?.yarn?.yarnId,{Inventories:ft}=Ae.VariantCell;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ft.Inventory,{inventoryId:R,consumption:R?S?.yarn_total:0}),(0,n.A)(S?.lycra,(rt,Mt)=>{if(!rt||!(0,ie.A)(rt)&&(!(0,A.A)(rt)||!("id"in rt)))return;const Ht=(0,ie.A)(rt)?rt:rt?.id;return(0,t.jsx)(ft.Inventory,{inventoryId:Ht,consumption:Ht?S?.lycra_total:void 0},`${Ht}_${Mt}`)})]})}const B=Bt;var x=e(32943),I=e(2155),g=e(3748),V=e(47144);const ht=(0,T.A)(x.A)(({theme:S}
13)=>({"&:not(:hover)":{...S.mixins.striped}})),at=(0,T.A)(Yt.A)(({theme:S})=>({textAlign:"left",...S.mixins.allBreakable}));function y({inventoryId:S,consumption:R,showType:ft=!0}){const rt=(0,c.useMemo)(()=>({inventoryId:S}),[S]),Mt=(0,r.G)(Qt=>(0,vt.pf)(Qt,rt)),Ht=(0,c.useMemo)(()=>V.A.format({value:R,unit:Mt?.measureUnit}),[R,Mt?.measureUnit]);return(0,t.jsx)(ht,{inventoryId:Mt?.id,className:"VariantMatrix__VariantInventory",inventoryType:Mt?.type,justifyContent:"space-between",color:"inherit",shape:"default",uppercase:!1,fullWidth:!0,autoHeight:!0,children:(0,t.jsxs)(At.A,{gap:.5,children:[(0,t.jsxs)(At.A,{flexDirection:"row",alignItems:"center",gap:.5,children:[!!Mt?.color?.value&&(0,t.jsx)(Ut.A.Simple,{background:Mt?.color?.value,style:{width:16,height:16}}),(0,t.jsx)(at,{variant:"body2",children:Mt?.title})]}),(0,t.jsxs)(At.A,{flexDirection:"row",alignItems:"center",gap:.5,children:[!!ft&&(0,t.jsx)(I.A,{inventory:Mt}),(0,t.jsx)(g.A,{inventory:Mt,label:Ht})]})]})})}const _=y,Pt=(0,T.A)(At.A)(({theme:S})=>({borderRadius:S.shape.borderRadius,...S.mixins.striped}));ee.Inventory=_,ee.Colorway=B;function ee({variantId:S}){const R=(0,c.useMemo)(()=>({variantId:S}),[S]),ft=(0,r.G)(Qt=>(0,G.Ox)(Qt,R)),{getVariantData:rt}=Ae.useContext(),Mt=rt(ft?.id),Ht=Qt=>Qt?.item?Qt?.type?[Ft.g.TRIM,Ft.g.LABEL].includes(Qt.type):!0:!1;return(0,t.jsxs)(At.A,{width:"100%",gap:2,className:"VariantMatrix__VariantCellInventory",hidden:!ft?.id,children:[(0,n.A)(ft?.colorway,(Qt,se)=>Qt?.yarn?(0,t.jsx)(xe.A,{contentGap:wt=>wt.spacing(.5),label:`Yarn ${ne.A.numberToLetter(se+1)}`,children:(0,t.jsx)(ee.Colorway,{colorway:Qt})},`${Qt.yarn}_${se}`):null),(0,t.jsx)(xe.A,{label:"Trims and Labels",contentGap:Qt=>Qt.spacing(.5),children:(0,n.A)(Mt?.inventory,(Qt,se)=>Ht(Qt)?(0,t.jsxs)(Pt,{flexDirection:"row",alignItems:"center",gap:1,children:[(0,t.jsx)(_,{inventoryId:Qt?.item,consumption:Qt?.quantity}),(0,t.jsx)(Ae.Copy,{variantId:S,inventoryId:Qt?.item,startIcon:(0,t.jsx)(Fe.A,{}),label:null})]},`${Qt?.item}_${se}`):null)})]})}const fe=ee;me.Header=Pe,me.Inventories=fe;function me({variantId:S,colorwayName:R}){const ft=mt()("VariantMatrix__VariantCell");return(0,t.jsx)(Ae.Cell,{minHeight:400,footer:(0,t.jsx)(Ae.Copy,{label:"Copy trims and labels to...",variantId:S,variant:"text",fullWidth:!0,uppercase:!0}),header:(0,t.jsx)(Pe,{variantId:S,children:(0,t.jsx)(Yt.A,{variant:"h5",textTransform:"uppercase",marginBottom:0,children:R})}),className:ft,children:(0,t.jsx)(fe,{variantId:S})})}const Be=me;var Le=e(77273);const ze=$t.Nc.object().shape({inventory:$t.Nc.array().of(Le.x).required().min(1)});function Ve(S={}){return{form:(0,Wt.mN)({...S,resolver:(0,$t.L2)(ze)})}}function le({variantId:S}){const R=(0,N.hS)(),ft=(0,c.useMemo)(()=>({variantId:S}),[S]),rt=(0,r.G)(Xt=>(0,G.Ox)(Xt,ft)),{getVariantData:Mt,setVariantData:Ht,matrixData:Qt}=Ae.useContext(),se=(0,c.useMemo)(()=>{const Xt=Mt(rt?.id);return{inventory:(0,n.A)(Xt?.inventory,De=>({quantity:De.quantity,order:De.order,type:De.type,item:De.item}))}},[rt?.id,R.visible,Qt]),{form:wt}=Ve({values:se}),Jt=wt.handleSubmit(Xt=>{S&&(Ht({data:Xt,variantId:S}),R.close())}),Te=(0,c.useCallback)(()=>{wt.reset()},[]);return{variant:rt,variantId:S,modal:R,form:wt,reset:Te,onSubmit:Jt}}var pe=e(69610);function Ne({variant:S,form:R,...ft}){return(0,t.jsx)(Wt.Ay,{...ft,children:(0,t.jsx)(xe.A,{label:"Inventories",children:(0,t.jsx)(pe.A,{name:"inventory",control:R.control,variant:S})})})}Oe.Form=Ne;function Oe({variantId:S,children:R,buttonProps:ft,...rt}){const{modal:Mt,form:Ht,variant:Qt,onSubmit:se,reset:wt}=le({variantId:S});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N.Ay,{open:Mt.visible,onClose:Mt.close,title:Qt?.sku,maxWidth:600,actions:(0,t.jsx)(Wt.Ay.Submit,{onClick:se,children:"Apply"}),onTransitionExited:wt,confirmOnClose:Ht.formState.isDirty,confirmProps:{children:(0,t.jsx)(Dt.A.Message.UnsavedLost,{})},fullWidth:!0,...rt,children:(0,t.jsx)(Oe.Form,{form:Ht,variant:Qt})}),(0,t.jsx)(P.A,{onClick:Mt.open,startIcon:(0,t.jsx)(St.A,{}),...ft,children:R})]})}const Qe=Oe,Ye=(0,c.createContext)({});function Ze({children:S,...R}){return(0,t.jsx)(Ye.Provider,{value:R,children:S})}function qe(){return(0,c.useContext)(Ye)}function _e({yarnKey:S,sizeId:R,...ft}
13){const[rt,Mt]=(0,c.useState)(0),{setEdited:Ht,setMatrixData:Qt,setMatrixConsumption:se,matrixConsumption:wt}=Ae.useContext(),Jt=vt.WW[l.gK.YARN],Te=Rt=>{R&&Qt(Ie=>{const ge=Ie?.variants||{};return(0,d.A)(ge,Re=>{Re?.size_id===R&&(0,d.A)(Re?.data?.inventory,(be,ue)=>{be?.type!==l.gK.YARN||be?.order!==S||(0,p.A)(ge,[Re?.variant_id,"data","inventory",ue,"quantity"],Rt)})}),{...Ie,variants:ge}})},Xt=Rt=>{se(Ie=>{const ge=Ie?.yarns?.[S],Re=(0,E.A)(ge?.yarn_waste)||0,be=(0,h.A)(ge?.data,"isBase")?.sizeData,ue=be?.order||0,$e=(0,h.A)(ge?.data,{size:R})?.sizeData?.order||0;return(0,d.A)(ge?.data,(Je,ke)=>{if(!Je?.size)return;const ln=Je?.sizeData?.order||0,cn=ue>$e&&$e>=ln,An=ue<$e&&$e<=ln;if((be?.id===R||cn||An)&&!Je?.overwrite&&(0,p.A)(ge||{},["data",ke,"overwrite"],!0),Je.size!==R)return;const hn=(0,E.A)(Rt)||0,un=hn/100*Re,mn=hn-un;(0,p.A)(ge||{},["data",ke,"yarn_total"],Rt),(0,p.A)(ge||{},["data",ke,"yarn"],mn),(0,p.A)(ge||{},["data",ke,"yarn_waste"],un)}),{...Ie}})},De=Rt=>{Mt((0,E.A)(Rt||0)),Ht(!0),Xt((0,E.A)(Rt||0))};return(0,c.useEffect)(()=>{const Rt=wt?.yarns?.[S];(0,d.A)(Rt?.data,Ie=>{Ie&&Ie?.size===R&&Mt(Ie.yarn_total||0)})},[wt,S]),(0,c.useEffect)(()=>{Te(rt)},[rt]),(0,t.jsx)(st.A,{unit:Jt,onChange:De,value:rt,min:0,...ft})}const tn=_e;ye.Context=Ye,ye.Provider=Ze,ye.useContext=qe,ye.Cell=Gt,ye.VariantCell=Be,ye.VariantCellEdit=Qe,ye.Row=Vt,ye.Header=Lt,ye.Body=Z,ye.OpenButton=oe,ye.Layout=yt,ye.Copy=O,ye.YarnConsumption=tn,ye.LycraConsumption=X,ye.Modal=M,ye.useVariantMatrix=Y;function ye({productId:S,permission:R,...ft}){const rt=Y({productId:S,permission:R});return(0,t.jsxs)(ye.Provider,{...rt,children:[(0,t.jsx)(ye.OpenButton,{...ft}),(0,t.jsx)(ye.Modal,{children:(0,t.jsxs)(ye.Layout,{children:[!rt?.matrix?.variants&&!rt?.loading&&(0,t.jsx)(o.A,{}),!rt?.loading&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ye.Header,{}),(0,t.jsx)(ye.Body,{children:(0,n.A)(rt.matrix?.variants,(Mt,Ht)=>(0,t.jsx)(ye.Row,{children:(0,n.A)(Mt?.sizes,(Qt,se)=>(0,t.jsx)(ye.VariantCell,{colorwayName:Mt.colorwayName,variantId:Qt?.id},Qt?.id||se))},Ht))})]})]})})]})}const Ae=ye},1259(re,et,e){e.d(et,{Ay:()=>Bt,p2:()=>Fe,im:()=>ie});var t=e(74848),n=e(92049),o=e(8058),h=e(92866),i=e(42531),v=e(39241),d=e(27422),c=e(90973),P=e(54346),C=e(91235),r=e(96540),l=e(2454),G=e(62287),H=e(76429),$=e(33318),O=e(27354),A=e(47303),q=e(44251),N=e(51161),K=e(34605),ct=e(23841),z=e(32123),nt=e(22552),b=e(99041);function D({entityType:B,entityId:x,skip:I=!1}){const g=I||!x,{isLoading:V}=ct.h.useSizesQuery(void 0,{skip:I}),{isLoading:ht}=ct.h.useValuesQuery(void 0,{skip:I}),{isLoading:at}=ct.h.useColorsQuery(void 0,{skip:I}),{isFetching:y}=nt.G.useProductQuery({productId:x||void 0},{skip:g||B!=="product"}),{isFetching:_}=b.Yp.useRequestQuery({requestId:x||""},{skip:g||B!=="request"}),{isLoading:Pt}=(0,z.M)({skip:I,skipTrims:!0,skipLabels:!0});return{loading:V||at||ht||Pt||_||y}}function J(B){const{entityType:x,brandPartnerId:I,value:g,onChange:V,loading:ht,onEntityIdChange:at,hideEntitySelect:y,entityId:_,onAddItem:Pt,hideUnavailableItems:ee=!K.A.isAdminZone(),hideSelectedItems:fe=!1,multiple:me=!0,showColorway:Be=!0}=B,Le=Ot=>{if(le)return Ot?.variant||void 0;if(pe&&Ot?.size&&Ot?.colorway)return`${Ot?.colorway}_${Ot?.size}`},ze=Ot=>{if(!Ot||!(0,n.A)(Ot))return{};const kt={};return(0,o.A)(Ot,Zt=>{const ae=Le(Zt);ae&&(kt[ae]={quantity:1,...Zt,id:ae})}),kt},Ve=Ot=>(0,h.A)(Ot),le=x==="product",pe=x==="request",Ne=Ot=>{const kt=le?Oe?.[Ot?.variant||""]:void 0;if(le&&!kt||le&&kt&&!kt?.isActive||le&&I&&Array.isArray(kt?.brandPartnerIds)&&kt?.brandPartnerIds?.length&&!(0,i.A)(kt?.brandPartnerIds,I))return!1;const Zt=Rt?.brandPartnerId;return!(pe&&Zt&&I&&Zt!==I||pe&&Rt?.isArchived)},Oe=(0,l.G)(O.HI),Qe=(0,l.G)($.PZ),[Ye,Ze]=(0,G.P)({value:ze(g)??null,onChange:V,transform:Ve}),[qe,_e]=(0,r.useState)({}),[tn,ye]=(0,r.useState)({}),[Ae,S]=(0,G.P)({value:_,onChange:at}),[R,ft]=(0,r.useState)(),[rt,Mt]=(0,r.useState)(null),[Ht,Qt]=(0,r.useState)(!1),se=()=>{Ze({}),_e({})},wt=Ot=>{S(Ot),ft(void 0),Mt(null),pe&&se()},{loading:Jt}=D({entityType:x,entityId:Ae}),Te=(0,r.useMemo)(()=>({productId:Ae}),[Ae]),Xt=(0,l.G)(Ot=>le?(0,O.qM)(Ot,Te):void 0),De=(0,r.useMemo)(()=>({techPackId:Ae}),[Ae]),Rt=(0,l.G)(Ot=>pe?(0,q.QF)(Ot,De):void 0),Ie=()=>x==="request"?(0,v.A)(Rt?.sizeList):(0,v.A)(Xt?.sizes),ge=()=>x==="request"?(0,v.A)(Rt?.colorwayList):(0,v.A)(Xt?.colors),Re=(0,r.useMemo)(()=>
13{if(pe){if(K.A.isPartnerSide()&&!(0,i.A)([A._b.PROTOS,A._b.GRADING],Rt?.phase))return[];if(K.A.isPartnerSide()&&!(0,i.A)([A.qg.IN_PROGRESS,A.qg.SUBMITTED,A.qg.APPROVED],Rt?.state))return[];if(Rt?.phase===A._b.PROTOS)return(0,v.A)([Rt?.size])}if(le){const Ot=Xt?.groupedVariants;return R?(0,N._)(Ot?.[R],{field:"sizeId"}):(0,v.A)(Xt?.sizeIds)}},[R,x,Xt]),be=(0,r.useMemo)(()=>{if(le){if(!rt)return(0,d.A)(Xt?.groupedVariants);const Ot=[];return(0,o.A)(Xt?.variants,kt=>{kt?.isActive&&kt.sizeId===rt&&kt?.colorId&&!Ot.includes(kt?.colorId)&&Ot.push(kt.colorId)}),Ot}},[rt,Xt,x]),{savedSnackbar:ue}=(0,H.d)(),rn=()=>{!R||!rt||!Ae||Ze(Ot=>{const kt=le?(0,c.A)(Xt?.variants,{colorId:R,sizeId:rt,isActive:!0}):void 0,Zt=kt?.id,ae=Le({colorway:R,size:rt,variant:Zt});if(!ae)return Ot;const Ee={...Ot};return ue("Added to order"),Ee[ae]?(Ee[ae].quantity=(Ee[ae].quantity||0)+1,Ee):(Ee[ae]={colorway:R,size:rt,variant:Zt,id:ae,quantity:1,techPackId:le?Xt?.techPackId:Ae},kt&&Pt?.(kt),Ee)})},$e=({quantity:Ot,itemId:kt,operation:Zt})=>{Ze(ae=>{const Ee={...ae};if(Ee[kt]){const en=Zt==="increment"?(Ee[kt].quantity||0)+Ot:Ot;Ee[kt].quantity=en>0?en:1}return Ee})},Je=Ot=>{Ot&&Ze(kt=>{const Zt={...kt};return delete Zt[Ot],Zt})},ke=Ot=>{Ot&&_e(kt=>{const Zt={...kt};return delete Zt[Ot],Zt})},ln=(Ot,kt)=>{Ze(Zt=>{if(!Zt)return Zt;const ae={...Zt};return ae[Ot]&&(ae[Ot]={...ae[Ot],embroideries:kt}),ae})},cn=Ot=>{const kt=[];return(0,o.A)(Ot,Zt=>{if(le){const ae=Zt?.variant;if(!ae)return;const Ee=Oe?.[ae],en=Ee?.size,Ce=Ee?.color,Ge=Ee?.sku;if(!Ge||!en||!Ce)return;kt.unshift({...Zt,name:Ge,colorData:Ce,sizeData:en,image:Ee.productImage,brandPartnerId:Ee?.brandPartnerId,isInactive:!Ee?.isActive,brandPartnerCode:Ee?.brandPartnerId?Qe?.[Ee?.brandPartnerId]?.code:void 0})}if(pe){const ae=(0,P.A)(Rt?.sizeList,"id"),Ee=(0,P.A)(Rt?.colorwayList,"id");if(!Zt.size||!Zt.colorway)return;const en=ae?.[Zt.size],Ce=Ee?.[Zt.colorway],Ge=Rt?.title;if(!Ge||!en||!Ce)return;kt.unshift({...Zt,name:Ge,colorData:Ce,sizeData:en,brandPartnerCode:Rt?.brandPartner?.code,brandPartnerId:Rt?.brandPartner?.id})}}),kt},An=(0,r.useMemo)(()=>cn(tn),[le,pe,Oe,Rt,tn]),gn=(0,r.useMemo)(()=>cn(qe),[le,pe,Oe,Rt,qe]),hn=!!(Ae&&R&&rt),un=(0,r.useMemo)(()=>{if(!(!Ae||!R))return(0,c.A)(ge(),{id:R})},[R,Rt,Xt,pe,le]),mn=()=>{const Ot={},kt={};(0,o.A)(Ye,Zt=>{const ae=Le(Zt);if(ae){if(!Ne(Zt)){kt[ae]=Zt;return}Ot[ae]=Zt}}),(0,o.A)(qe,Zt=>{const ae=Le(Zt);if(ae){if(!Ne(Zt)){kt[ae]=Zt;return}Ot[ae]=Zt}}),_e(kt),ye(Ot)},dn=Ot=>{const kt=[];return(0,o.A)(Ot,Zt=>{const ae=Le(Zt);ae&&kt.push(ae)}),kt};return(0,r.useEffect)(()=>{if(!Ht){Qt(!0);return}wt(void 0)},[x,I]),(0,r.useEffect)(()=>{me||!g||(0,n.A)(g)||(ft(g.colorway),Mt(g.size||null))},[]),(0,r.useEffect)(()=>{if(!R||!rt||me)return;const Ot=le?(0,c.A)(Xt?.variants,{colorId:R,sizeId:rt,isActive:!0})?.id:void 0,kt=Le({colorway:R,size:rt,variant:Ot});kt&&V&&V({colorway:R,size:rt,variant:Ot,id:kt})},[R,rt]),(0,r.useEffect)(()=>{(0,C.A)(Qe)&&(le&&!(0,C.A)(Oe)||mn())},[g,Oe,Qe,I,le]),(0,r.useEffect)(()=>{const Ot=dn(tn),kt=Ot.sort().join(","),Zt=dn(qe),ae=dn(Ye);if(Ot.length+Zt.length!==ae.length)return;const Ee=ae.sort().join(",");kt!==Ee&&Ze(tn)},[tn,qe]),{product:Xt,sizeId:rt,removeUnavailableItem:ke,selectedColor:un,setSizeId:Mt,colorId:R,setColorId:ft,availableColorIds:be,availableSizeIds:Re,items:Ye,unavailableItemList:gn,entityType:x,entityId:Ae,addItem:rn,changeItemQty:$e,forProduct:le,forRequest:pe,brandPartnerId:I,removeItem:Je,updateItemEmbroideries:ln,canAddItem:hn,showColorway:Be,hideEntitySelect:y,hideSelectedItems:fe,itemList:An,multiple:me,hideUnavailableItems:ee,loading:ht||Jt,setEntityId:wt,sizes:Ie(),colors:ge(),showImages:x==="product"}}const it=(0,r.createContext)({});function Y({children:B,...x}){return(0,t.jsx)(it.Provider,{value:x,children:B})}function dt(){return(0,r.useContext)(it)}var mt=e(24401),At=e(17857),pt=e(30995),yt=e(71543),p=e(11848),E=e(11201),st=e(99682);function Ft({disabled:B,...x}){const{addItem:I,canAddItem:g}=Bt.useContext();return(0,t.jsx)(E.A,{startIcon:(0,t.jsx)(st.A,{}),color:"primary",variant:"text",onClick:I,disabled:B||!g,disabledMessage:g?void 0:"Select both size and color!",fullWidth:!0,up
13percase:!0,...x})}const vt=Ft;var zt=e(25485),X=e(46942),It=e.n(X),Z=e(61774);function W({brandPartnerId:B}){const{useOrderableRequestsQuery:x}=b.Yp,{requestsLoading:I,response:g}=x({brand_partner:B},{skip:!B,selectFromResult:at=>({requestsLoading:at.isLoading,response:at?.data})}),V=(0,r.useMemo)(()=>({techPackIds:(0,N._)(g?.techPacks,{field:"_id"})}),[g]);return{orderableRequests:(0,l.G)(at=>(0,q.K1)(at,V)),options:V.techPackIds,loading:I}}U.useSelect=W;function U({className:B,brandPartnerId:x,loading:I,readOnly:g,helperText:V,...ht}){const{options:at,orderableRequests:y,loading:_}=W({brandPartnerId:x}),Pt=It()("OrderableRequestSelect",B),ee=me=>{const Be=y?.[me];return(0,v.A)([Be?.title,Be?.productSku]).join(" | ")},fe=()=>{if(V)return V;if(!x)return"Please select a brand partner first"};return(0,t.jsx)(Z.A,{className:Pt,loading:_||I,readOnly:!x||g,getOptionLabel:ee,label:"Orderable Request",getOptionKey:me=>me,options:at,helperText:fe(),...ht})}const lt=U;function T({hidden:B,...x}){const{forRequest:I,brandPartnerId:g,entityId:V,setEntityId:ht,hideEntitySelect:at}=Bt.useContext(),y=I?lt:zt.A;return(0,t.jsx)(y,{value:V,brandPartnerId:g,onChange:ht,hidden:B||at,...x})}const xt=T;var jt=e(11397),Tt=e(53652),Gt=e(20440),Yt=e(42617),ne=e(12794),te=e(81821),Lt=e(62456),tt=e(33551),Vt=e(1694),Dt=e(92302);function Et({item:B,...x}){const{changeItemQty:I}=Bt.useContext(),g=at=>{B?.id&&I({itemId:B.id,quantity:(0,Vt.A)(at)||0})},V=()=>{B?.id&&I({itemId:B.id,quantity:-1,operation:"increment"})},ht=()=>{B?.id&&I({itemId:B.id,quantity:1,operation:"increment"})};return(0,t.jsx)(Dt.A,{value:B.quantity,onChange:g,onDecrement:V,onIncrement:ht,min:1,...x})}const Wt=Et;var Nt=e(18342);function $t({itemId:B,hidden:x,...I}){const{removeItem:g}=Bt.useContext();return(0,t.jsx)(E.A,{onClick:()=>B&&g(B),startIcon:(0,t.jsx)(Nt.A,{}),hidden:!B||x,color:"error",confirmProps:{title:"Remove variant?"},confirmOnClick:!0,...I})}const he=$t;function Se(B){const{itemList:x,showImages:I,hideSelectedItems:g,brandPartnerId:V,updateItemEmbroideries:ht}=Bt.useContext();if(g)return null;const at=[{field:"name",label:"Name",span:18,renderField(y){return(0,t.jsxs)(pt.A,{flexDirection:"row",alignItems:"center",gap:1,children:[(0,t.jsx)(ne.A,{label:y?.brandPartnerCode}),(0,t.jsx)(tt.A,{children:y?.name})]})}},{label:"Size",span:6,renderField(y){return(0,t.jsx)(Yt.A,{sizeData:y?.sizeData})}}];return(0,t.jsx)(Tt.A,{items:x,config:at,extraRightWidth:200,extraLeftWidth:I?80:40,showEmpty:!1,hidden:!x?.length,extraLeft:y=>(0,t.jsxs)(pt.A,{gap:1,flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",children:[I&&!!y?.image&&(0,t.jsx)(jt.A,{maxHeight:40,src:y?.image?.smallSrc||y?.image?.src,preview:{src:y?.image?.highResolutionSrc||y?.image?.src}}),I&&!y?.image&&(0,t.jsx)(Lt.A,{fontSize:"large"}),(0,t.jsx)(Gt.A,{color:y?.colorData,width:28})]}),extraRight:y=>(0,t.jsxs)(pt.A,{gap:1,flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[(0,t.jsx)(Wt,{item:y}),(0,t.jsx)(he,{itemId:y.id})]}),renderItem:(y,_)=>(0,t.jsxs)(pt.A,{gap:1,children:[(0,t.jsx)(Tt.A.Item,{itemData:y,..._}),!!y?.techPackId&&(0,t.jsx)(te.Ay,{techPackId:y.techPackId,brandPartnerId:V,value:y.embroideries,onChange:Pt=>ht(y.id,Pt)})]}),hideFooter:!0,hideHeader:!0,...B})}const k=Se;var St=e(69554);function qt({listProps:B,...x}){const{unavailableItemList:I,showImages:g,hideUnavailableItems:V,removeUnavailableItem:ht}=Bt.useContext(),at=(0,r.useMemo)(()=>[{field:"name",label:"Name",span:16,renderField(y){return(0,t.jsxs)(pt.A,{flexDirection:"row",alignItems:"center",gap:1,children:[(0,t.jsx)(ne.A,{label:y?.brandPartnerCode}),(0,t.jsx)(tt.A,{children:y?.name})]})}},{label:"Size",span:4,renderField(y){return(0,t.jsx)(Yt.A,{sizeData:y?.sizeData})}}],[]);return V||!I.length?null:(0,t.jsx)(mt.A,{helperText:"These products were removed due to brand-partner or product restrictions",helperTextProps:{sx:y=>({color:y.palette.warning.main})},label:(0,t.jsx)(St.A,{label:"Unavailable items",color:"warning"}),...x,children:(0,t.jsx)(Tt.A,{items:I,config:at,extraRightWidth:155,extraLeftWidth:g?80:40,showEmpty:!1,extraRight:y=>(0,t.jsxs)(pt.A,{flexDirection:"row",alignItems:"center",gap:1,children:[!!y?.isInactive&&(0,t.jsx)(St.A,{color:"error",label:"Inactive"}),(0,t.jsx)(tt.A,{fontWeight:"bold",children:y?.quantity}),(0,t.jsx)(E.A,{startIcon:(0,t.jsx)(Nt.A,{}),onClick:()=>y?.id&&ht(y?.id),hidden:!y?.id,color:"error",confirmProps:{title:"Remove variant?"},confirmOnClick:!0})]}),extraLeft:y=>(0,t.jsxs)(pt.A,{gap:1,flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",children:[g&&!!y?.image&&(0,t.jsx)(jt.A,{maxHeight:40,src:y?.image?.smallSrc||y?.image?.src,preview:{src:y?.image?.largeSrc||y?.image?.src}}),g&&!y?.image&&(0,t.jsx)(Lt.A,{fontSize:"large"}),(0,t.jsx)(Gt.A,{color:y?.colorData,width:28})]}),hideFooter:!0,hideHeader:!0,...B})})}const Kt=qt;var gt=e(84123),j=e(74722),m=e(77500),u=e(8977),f=e(96291),L=e(27447),a=e(98550);const M={"6405d69dfcb7dd0028559386":"Biella (non-washable)","690ceb439a46aed0386aea63":"Zegna Baruffa (washable)"};function ot({helperText:B,...x}){const{colors:I,colorId:g,setColorId:V,availableColorIds:ht,loading:at,entityId:y,selectedColor:_,showColorway:Pt,product:ee}=Bt.useContext(),fe=!at&&!!y&&!I?.length,me=(0,r.useMemo)(()=>(0,a.d)({product:ee,colors:I}),[ee,I]),Be=(0,r.useMemo)(()=>(0,gt.A)(me),[me]),Le=(0,C.A)(Be)<=1,ze=()=>{if(B)return B;if(fe)return"No colors! You can't add it to the order"};return at||!y?null:(0,t.jsxs)(mt.A,{label:"Variant Color",helperText:ze(
13),...x,children:[!at&&(0,j.A)(Be,([Ve,le])=>{const pe=Le?r.Fragment:mt.A,Ne=Le?{}:{label:(0,m.A)(M,Ve,"")};return(0,t.jsx)(pe,{...Ne,children:(0,t.jsx)(f.A,{colors:le,value:g,availableColorIds:ht,onChange:V})},Ve)}),!!_?.colorway&&!!Pt&&(0,t.jsx)(u.A,{children:(0,t.jsxs)(u.A.Item,{tab:"colorway",children:[(0,t.jsx)(u.A.Summary,{children:_?.name}),(0,t.jsx)(u.A.Details,{children:(0,t.jsx)(L.A.View,{colorway:_?.colorway})})]})})]})}const Ct=ot;var ut=e(90077);function oe({helperText:B,...x}){const{sizes:I,sizeId:g,setSizeId:V,availableSizeIds:ht,loading:at,entityId:y}=Bt.useContext(),_=!at&&y&&!I?.length,Pt=()=>{if(B)return B;if(_)return"No sizes! You can't add it to the order"};return at||!y?null:(0,t.jsx)(ut.A,{helperText:Pt(),sizes:I,label:"Variant Size",value:g,onChange:V,availableSizeIds:ht,...x})}const Ut=oe,bt=(0,p.A)(pt.A)(()=>[{width:"100%",position:"relative"}]);function de({colorPickerProps:B,sizePickerProps:x,...I}){const{loading:g,multiple:V,entityId:ht}=dt();return(0,t.jsxs)(mt.A,{contentGap:at=>at.spacing(2),fullWidth:!0,borderLess:!0,...I,children:[(0,t.jsx)(xt,{}),g&&(0,t.jsx)(At.A,{style:{flex:1,minHeight:200},loading:g}),(0,t.jsxs)(bt,{gap:2.5,flex:1,hidden:g,children:[(0,t.jsx)(Ct,{...B}),(0,t.jsx)(Ut,{...x}),V&&ht&&(0,t.jsx)(vt,{sx:{alignSelf:"flex-start"},hidden:g,fullWidth:!1,variant:"outlined",children:"Add to order"})]}),V&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(yt.A,{}),(0,t.jsx)(k,{}),(0,t.jsx)(Kt,{})]})]})}Pe.useContext=dt,Pe.Context=it,Pe.Provider=Y,Pe.View=de,Pe.useVariantsPicker=J;function Pe({entityType:B,brandPartnerId:x,value:I,onChange:g,entityId:V,onEntityIdChange:ht,hideEntitySelect:at,onAddItem:y,hideSelectedItems:_,multiple:Pt,showColorway:ee,...fe}){const me=J({entityType:B,brandPartnerId:x,value:I,onChange:g,onEntityIdChange:ht,entityId:V,hideEntitySelect:at,hideSelectedItems:_,onAddItem:y,multiple:Pt,showColorway:ee});return(0,t.jsx)(Pe.Provider,{...me,children:(0,t.jsx)(Pe.View,{...fe})})}var xe=e(31782);const Fe=xe.Nc.object().shape({id:xe.Nc.mixed(),quantity:xe.Nc.number().positive().required(),variant:xe.Nc.mixed().nullable().optional(),colorway:xe.Nc.string().required(),size:xe.Nc.string().required(),embroideries:xe.Nc.mixed().optional(),techPackId:xe.Nc.mixed().optional()}),ie=Fe.omit(["quantity"]),Bt=Pe},30193(re,et,e){e.d(et,{A:()=>c});var t=e(74848),n=e(61973),o=e(11201),h=e(49497),i=e(35496),v=e(34605);function d({requestId:P,replace:C,children:r,versionId:l,...G}){const H=(0,h.I)(A=>A.REQUESTS__READ),O=(()=>{if(!P||!H)return;const{boardRequests:A,boardRequest:q,request:N,myDevelopment:K}=i.Ay;return(0,n.B6)({path:A(),end:!1},window.location.pathname)?q(P):v.A.isPartnerSide()?K(P):N(P,void 0,l)})();return O?(0,t.jsx)(n.k2,{to:O,replace:C,children:(0,t.jsx)(o.A.Open,{shape:"round",...G,children:r})}):null}const c=d},84053(re,et,e){e.d(et,{A:()=>h});var t=e(74848),n=e(69554);function o({request:i,hidden:v,label:d,phase:c,...P}){const C=()=>v||(c||d?!1:!i?.phase);return(0,t.jsx)(n.A,{color:"teal",hidden:C(),label:d??i?.statusData?.phaseLabel,...P})}const h=o},28786(re,et,e){e.d(et,{A:()=>i});var t=e(74848),n=e(47303),o=e(69554);function h({request:v,label:d,...c}){const P=()=>v?.statusData?.stateLabel?v?.state===n.qg.SUBMITTED?"purple":v?.state===n.qg.ADJUSTMENTS?"teal":v?.state===n.qg.APPROVED?"success":v?.state===n.qg.ON_HOLD?"warning":v?.state===n.qg.IN_PROGRESS?"info":"default":"default";return(0,t.jsx)(o.A,{color:P(),label:d??v?.statusData?.stateLabel??"Draft",...c})}const i=h},81821(re,et,e){e.d(et,{Ay:()=>Se,lg:()=>he});var t=e(74848),n=e(48256),o=e(27422),h=e(66070),i=e(74722),v=e(19477),d=e(39241),c=e(96540),P=e(42985),C=e(2454),r=e(62287),l=e(99041),G=e(44251),H=e(51161),$=e(34605);function O({techPackId:k,brandPartnerId:St,value:qt,onChange:Kt,availableEmbroideryIds:gt,availableTechPackEmbroideryIds:j,disableAutoApply:m,hideAddButton:u=!1,hideDeleteButton:f=!1}){const L=(0,c.useRef)(!1),a=Array.isArray(j),{data:M,isLoading:ot}=l.Yp.useTechpackEmbroideriesQuery({brandPartnerId:St,withEmbroideries:1,techPackId:k||""},{skip:!k||a}),Ct=a?(j?.length??0)>0:ot||(0,o.A)(M?.techpackEmbroideries).length>0,ut=(0,P.hS)({skipHistory:!0}),oe=(0,C.G)(G.iY),Ut=(0,c.useMemo)(()=>a?gt:(0,H._)(M?.techpackEmbroideries,{field:"id"}),[M,a,gt]),[bt,de]=(0,r.P)({value:qt??[],onChange:Kt}
13),Pe=(0,c.useCallback)(x=>{de(I=>[...I,{...x}])},[de]),xe=(0,c.useCallback)(x=>{de(I=>(0,h.A)(I,(g,V)=>V!==x))},[de]),Fe=(0,c.useCallback)((x,I)=>{de(g=>(0,i.A)(g,(V,ht)=>ht===x?{...I}:V))},[de]),ie=(0,c.useMemo)(()=>(0,H._)(bt,{field:"techpack_embroidery",omitNull:!0}),[bt]),Bt=(0,c.useMemo)(()=>Ct?(0,v.A)(Ut,x=>!ie.includes(x)):!1,[Ct,Ut,ie]),B=(0,c.useCallback)(x=>$.A.isAdminZone()?!0:!x?.auto_apply,[]);return(0,c.useEffect)(()=>{if(m||L.current||!Ut?.length)return;const x=(0,d.A)(Ut.map(I=>{const g=oe?.[I];if(!g?.auto_apply)return null;const V=g.embroiderySet?.default_embroidery;if(!V)return null;const ht=g.embroiderySet?.defaultEmbroidery;return{techpack_embroidery:I,embroidery:V,embroidery_set:g.embroidery_set??void 0,color:ht?.default_color??void 0,text:ht?.default_text??void 0}}));L.current=!0,x.length&&de(x)},[Ut,oe]),{techPackId:k,brandPartnerId:St,availableIds:Ut,availableEmbroideryIds:gt,availableTechPackEmbroideryIds:j,items:bt,modal:ut,hasEmbroideries:Ct,canAddEmbroidery:Bt,selectedTechpackEmbroideryIds:ie,addItem:Pe,removeItem:xe,editItem:Fe,canEmbroideryBeDeleted:B,hideAddButton:u,hideDeleteButton:f}}var A=e(78405),q=e(20440),N=e(30251),K=e(29614),ct=e(86268),z=e(30995),nt=e(69554),b=e(33551);const D=(0,c.createContext)({});function J({children:k,...St}){return(0,t.jsx)(D.Provider,{value:St,children:k})}function it(){return(0,c.useContext)(D)}function Y(){const{items:k}=it(),St=(0,C.G)(G.iY),qt=(0,C.G)(N.Tj);return k.length?(0,t.jsx)(z.A,{gap:1,width:"100%",children:(0,i.A)(k,(Kt,gt)=>{if(!Kt?.techpack_embroidery)return;const j=St?.[Kt.techpack_embroidery],m=Kt.embroidery?j?.embroiderySet?.embroidery?.[Kt.embroidery]:void 0,u=Kt.color?qt?.[Kt.color]:void 0;return(0,t.jsxs)(z.A,{direction:"row",alignItems:"center",gap:1,flexWrap:"wrap",children:[(0,t.jsx)(A.A,{type:"embroidery"}),(0,t.jsx)(K.A,{embroidery:m}),(0,t.jsx)(q.A.Simple,{background:u?.value}),(0,t.jsx)(ct.A,{embroidery:m}),!!Kt.text&&(0,t.jsx)(nt.A,{label:Kt.text}),(0,t.jsxs)(z.A,{flex:1,children:[(0,t.jsx)(b.A,{variant:"caption",textAlign:"right",children:m?.name}),(0,t.jsx)(b.A,{variant:"caption",color:"text.secondary",textAlign:"right",children:j?.place})]})]},`${Kt.techpack_embroidery}-${gt}`)})}):null}var dt=e(11201),mt=e(20898),At=e(87164),pt=e(11848);const yt=(0,pt.A)(At.A)(({theme:k})=>({border:`1px dashed ${k.palette.divider}`,borderRadius:k.shape.borderRadius,padding:k.spacing(2)}));function p(){const{modal:k,hasEmbroideries:St,hideAddButton:qt}=it();return!St||qt?null:(0,t.jsx)(yt,{children:(0,t.jsxs)(z.A,{direction:"row",alignItems:"center",gap:2,children:[(0,t.jsx)(A.A,{type:"embroidery"}),(0,t.jsxs)(z.A,{flex:1,gap:.25,children:[(0,t.jsx)(b.A,{fontWeight:"bold",children:"Add custom embroidery"}),(0,t.jsx)(b.A,{variant:"body2",color:"text.secondary",children:"Pick a text or logo pack. Attach as many as you like."})]}),(0,t.jsx)(dt.A,{startIcon:(0,t.jsx)(mt.A,{}),onClick:k.open,color:"primary",size:"small",uppercase:!0,children:"Add Embroidery"})]})})}var E=e(20588),st=e(16394),Ft=e(95028),vt=e(7661),zt=e(54792),X=e(49785),It=e(65238),Z=e(31782);const W=k=>Z.Nc.object().shape({techpack_embroidery:Z.Nc.mixed(),embroidery:Z.Nc.string().required(),embroidery_set:Z.Nc.mixed().optional(),color:Z.Nc.string().required(),text:k?Z.Nc.string().required():Z.Nc.string().nullable().optional()});function U({techpackEmbroideryId:k,initialValues:St,onSave:qt}){const Kt=(0,c.useRef)(!1),gt=(0,c.useRef)(!1),j=(0,E.mN)({defaultValues:{techpack_embroidery:k,embroidery:St.embroidery??null,embroidery_set:St.embroidery_set??null,color:St.color??null,text:St.text??null},mode:"onChange",resolver:(...Ct)=>(0,Z.L2)(W(Kt.current))(...Ct)}),m=(0,X.FH)({control:j.control,name:"embroidery"}),u=(0,C.G)(Ct=>(0,G.C2)(Ct,{embroideryId:k??void 0}));l.Yp.useTechpackEmbroideryQuery({embroideryId:u?.id||""},{skip:!u?.id});const f=(0,c.useMemo)(()=>(0,d.A)(u?.embroiderySet?.embroideryIds??[]),[u]),L=m?u?.embroiderySet?.embroidery?.[m]:void 0,a=L?.type===It.q.TEXT;Kt.current=a;const M=(0,c.useMemo)(()=>(0,d.A)(L?.allowed_colors??[]),[L]),ot=j.handleSubmit(Ct=>{qt({...Ct})});return(0,c.useEffect)(()=>
13{if(!gt.current){gt.current=!0;return}if(!m)return;const Ct=L?.default_color??L?.allowed_colors?.[0];Ct&&j.setValue("color",Ct),ot()},[m]),{form:j,embroideryIds:f,techpackEmbroidery:u,selectedEmbroidery:L,isText:a,allowedColorIds:M,handleSave:ot}}const lt=(0,pt.A)(dt.A,{shouldForwardProp:k=>k!=="selected"})(({theme:k,selected:St})=>[{borderRadius:"50%",padding:2,outlineOffset:1,outline:k.border.solid(2),outlineColor:"transparent"},St&&{outlineColor:k.palette.primary.main}]);function T({allowedColorIds:k,value:St,onChange:qt,...Kt}){const gt=(0,C.G)(N.Tj),j=St?gt?.[St]?.name:void 0;return(0,t.jsxs)(z.A,{gap:.75,...Kt,children:[(0,t.jsxs)(b.A,{variant:"overline",color:"text.secondary",fontWeight:"bold",children:["Thread color\xA0\xA0",j&&(0,t.jsx)(b.A,{component:"span",variant:"caption",color:"text.secondary",children:j})]}),(0,t.jsx)(z.A,{direction:"row",flexWrap:"wrap",gap:.5,children:(0,i.A)(k,m=>{const u=gt?.[m],f=St===m;return(0,t.jsx)(lt,{selected:f,onClick:()=>qt(m),startIcon:(0,t.jsx)(q.A.Simple,{background:u?.value,dotWidth:24})},m)})})]})}var xt=e(77343);const jt=(0,pt.A)(dt.A,{shouldForwardProp:k=>k!=="selected"})(({theme:k,selected:St})=>({display:"flex",flexDirection:"column",alignItems:"center",gap:k.spacing(.5),padding:k.spacing(1),borderColor:St?k.palette.primary.main:k.palette.divider,position:"relative",flex:1,minWidth:0}));function Tt({embroideryIds:k,techpackEmbroidery:St,value:qt,onChange:Kt,...gt}){return(0,t.jsxs)(z.A,{gap:.75,...gt,children:[(0,t.jsx)(b.A,{variant:"overline",color:"text.secondary",fontWeight:"bold",children:"Choose a logo"}),(0,t.jsx)(At.A,{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:1,children:(0,i.A)(k,j=>{const m=St?.embroiderySet?.embroidery?.[j],u=qt===j;return(0,t.jsxs)(jt,{selected:u,onClick:()=>Kt(j),variant:"outlined",shape:"default",children:[(0,t.jsx)(K.A,{embroidery:m,size:48}),(0,t.jsx)(b.A,{variant:"caption",textAlign:"center",color:"text.primary",noWrap:!0,children:m?.name}),u&&(0,t.jsx)(xt.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:4,right:4}})]},j)})})]})}function Gt({item:k,index:St,...qt}){const{removeItem:Kt,editItem:gt,canEmbroideryBeDeleted:j,hideDeleteButton:m}=Se.useContext(),u=(0,C.G)(Ft.uZ),{form:f,embroideryIds:L,techpackEmbroidery:a,isText:M,allowedColorIds:ot,handleSave:Ct}=U({techpackEmbroideryId:k.techpack_embroidery,initialValues:k,onSave:ut=>gt(St,ut)});return(0,t.jsxs)(z.A,{border:ut=>ut.border.solid(1),bgcolor:ut=>ut.palette.background.paper,padding:1.5,gap:1.5,...qt,children:[(0,t.jsxs)(z.A,{direction:"row",alignItems:"center",gap:1,children:[(0,t.jsx)(A.A,{type:"embroidery",width:20,height:20}),(0,t.jsx)(b.A,{fontWeight:"bold",flex:1,children:a?.name}),(0,t.jsx)(vt.A,{embroiderySet:a?.embroiderySet,size:"small"}),(0,t.jsx)(st.A,{size:"small",onClick:()=>Kt(St),disabled:!j(a),hidden:m})]}),(0,t.jsxs)(E.Ay,{form:f,onChange:Ct,children:[!M&&L.length>0&&(0,t.jsx)(E.Ay.Item,{name:"embroidery",control:f.control,render:({field:ut})=>(0,t.jsx)(Tt,{embroideryIds:L,techpackEmbroidery:a,value:ut.value,onChange:ut.onChange})}),M&&(0,t.jsx)(E.Ay.Input,{name:"text",label:"Text to embroider",control:f.control,required:!0}),ot.length>0&&(0,t.jsx)(E.Ay.Item,{name:"color",control:f.control,render:({field:ut})=>(0,t.jsx)(T,{allowedColorIds:ot,value:ut.value,onChange:oe=>{ut.onChange(oe),Ct()}})})]}),(0,t.jsxs)(b.A,{variant:"overline",color:"text.secondary",fontWeight:"bold",hidden:!a?.place,children:["Place\xA0\xA0",(0,t.jsx)(b.A,{component:"span",variant:"caption",color:"text.secondary",children:a?.place})]}),!!u&&(0,t.jsxs)(b.A,{variant:"body2",color:"text.secondary",children:["Adds + ",(0,zt.A)(u,0)," / unit"]})]})}const Yt=Gt;function ne(){const{items:k,modal:St,canAddEmbroidery:qt,hideAddButton:Kt}=it();return k.length?(0,t.jsxs)(z.A,{gap:1.5,children:[(0,i.A)(k,(gt,j)=>(0,t.jsx)(Yt,{item:gt,index:j},`${gt.techpack_embroidery}-${j}`)),!Kt&&qt&&(0,t.jsx)(dt.A,{startIcon:(0,t.jsx)(mt.A,{}),onClick:St.open,color:"inherit",size:"small",variant:"text",uppercase:!0,children:"Add another Embroidery"})]}):null}function te(k){return(0,t.jsx)(z.A,{gap:2,width:"100%",...k})}function Lt(k){const{modal:St}=it();return(0,t.jsx)(P.Ay,{title:"Add an Embroidery",open:St.visible,onClose:St.close,maxWidth:"xs",fullWidth:!0,...k})}var tt=e(62315),Vt=e(8058),Dt=e(42531),Et=e(13575),Wt=e(71543);function Nt(){const{availableIds:k,selectedTechpackEmbroideryIds:St,addItem:qt,modal:Kt}=it(),gt=(0,C.G)(G.iY),j=(0,C.G)(Ft.uZ),m=(0,c.useMemo)(()=>(0,tt.A)(gt,k||[]),[k,gt]),u=(0,c.useMemo)(()=>{const L={};return(0,Vt.A)(m,a=>{if((0,Dt.A)(St,a.id))return;const M=a.embroiderySet?.type??"other";L[M]||(L[M]=[]),L[M].push(a)}),L},[m,St]),f=L=>{if(!L)return;const a=gt?.[L];if(!a)return;const M=a.embroiderySet?.default_embroidery||a.embroiderySet?.embroideryIds?.[0],ot=M?a.embroiderySet?.embroidery?.[M]:void 0;qt({techpack_embroidery:a.id,embroidery:M,embroidery_set:a.embroidery_set,color:ot?.default_color,text:ot?.default_text}),Kt.close()};return(0,t.jsx)(z.A,{gap:2.5,children:(0,i.A)(u,(L,a)=>(0,t.jsxs)(z.A,{gap:.5,children:[(0,t.jsxs)(b.A,{variant:"overline",color:"text.secondary",fontWeight:"bold",paddingX:1.5,children:[(0,Et.A)(a)," PACKS"]}),(0,t.jsx)(z.A,{divider:(0,t.jsx)(Wt.A,{flexItem:!0}),children:(0,i.A)(L,M=>(0,t.jsxs)(dt.A,{onClick:()=>f(M?.id),shape:"default",children:[(0,t.jsx)(A.A,{type:"embroidery",width:32,height:32}),(0,t.jsx)(z.A,{flex:1,gap:.25,children:(0,t.jsxs)(z.A,{direction:"row",alignItems:"center",gap:1,flexWrap:"wrap",children:[(0,t.jsx)(b.A,{fontWeight:"medium",children:M.name}),(0,t.jsx)(vt.A,{embroiderySet:M.embroiderySet,size:"small"})]})}),!!j&&(0,t.jsxs)(b.A,{variant:"body2",color:"text.secondary",whiteSpace:"nowrap",children:["+ ",(0,zt.A)(j,0)," / unit"]})]},M?.id))})]},a))})}$t.useContext=it,$t.Context=D,$t.Provider=J,$t.Compact=Y,$t.Modal=Lt,$t.Select=Nt,$t.Empty=p,$t.Items=ne,$t.Layout=te,$t.useTechPackEmbroideryPicker=O;function $t({techPackId:k,brandPartnerId:St,value:qt,onChange:Kt,availableEmbroideryIds:gt,availableTechPackEmbroideryIds:j,disableAutoApply:m,hideAddButton:u,hideDeleteButton:f,compactView:L,helperText:a,error:M,...ot}){const Ct=O({techPackId:k,brandPartnerId:St,value:qt,onChange:Kt,availableEmbroideryIds:gt,availableTechPackEmbroideryIds:j,disableAutoApply:m,hideAddButton:u,hideDeleteButton:f}),ut=!!Ct?.items?.length;return!ut&&!Ct.canAddEmbroidery&&!L||!!L&&!ut?null:(0,t.jsx)($t.Provider,{...Ct,children:(0,t.jsxs)($t.Layout,{...ot,children:[!!L&&(0,t.jsx)($t.Compact,{}),!L&&(0,t.jsxs)(t.Fragment,{children:[ut?(0,t.jsx)($t.Items,{}):(0,t.jsx)($t.Empty,{}),(0,t.jsx)($t.Modal,{children:(0,t.jsx)($t.Select,{})}),a&&(0,t.jsx)(n.A,{error:M,children:a})]})]})})}function he(k){const{data:St}=l.Yp.useTechpackEmbroideriesQuery({withEmbroideries:1,techPackId:k||""},{skip:!k}),qt=(0,C.G)(G.iY),Kt=(0,c.useMemo)(()=>(0,H._)(St?.techpackEmbroideries,{field:"id"}),[St]);return(0,c.useMemo)(()=>Kt?.length?(0,d.A)(Kt.map(gt=>{const j=qt?.[gt];if(!j?.auto_apply)return null;const m=j.embroiderySet?.default_embroidery;if(!m)return null;const u=j.embroiderySet?.defaultEmbroidery;return{techpack_embroidery:gt,embroidery:m,embroidery_set:j.embroidery_set??void 0,color:u?.default_color??void 0,text:u?.default_text??void 0}})):[],[Kt,qt])}const Se=$t}}]);

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.