PageSourceSearch

https://sutton-community-farm-52-twkmb.ondigitalocean.app/_next/static/chunks/5004-e9160d7110b4d972.js

js sutton-community-farm-52-twkmb.ondigitalocean.app collected 2026-10-03 14:55:20 UTC 52,662 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5004],{16485:(e,t,n)=>{n.d(t,{E4:()=>o,SV:()=>d,WC:()=>s,XJ:()=>i,_l:()=>a,v4:()=>l});var r=n(71843);(0,r.U)("\n  query boxedProductsForStore($farmId: ID!) {\n    boxedProductsForStore(farmId: $farmId) {\n      id\n      box_id\n      box_contents_id\n      box_contents_week\n      box_contents_year\n      name\n      value\n      uom\n      origin\n      order\n      isExampleContent\n    }\n  }\n"),(0,r.U)("\n  query getBoxable($farm: ID!) {\n    products(\n      filters: {\n        farm: { id: { eq: $farm } }\n        product_type: { in: 2 }\n        boxable: { eq: true }\n      }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        id\n        attributes {\n          name\n        }\n      }\n    }\n  }\n");let i=(0,r.U)("\n  query getSwaps($farm: ID!, $boxContentId: ID!) {\n    products(\n      filters: {\n        farm: { id: { eq: $farm } }\n        product_type: { in: 2 }\n        boxable: { eq: true }\n        swap: { eq: true }\n      }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        id\n        attributes {\n          name\n          price\n          swap\n          hv_swap\n          origin {\n            data {\n              attributes {\n                code\n              }\n            }\n          }\n          boxed_options(\n            filters: { box_content: { id: { eq: $boxContentId } } }\n          ) {\n            data {\n              id\n              attributes {\n                swap\n                hv_swap\n                origin {\n                  data {\n                    attributes {\n                      code\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n"),a=(0,r.U)("\n  query preferences($user: ID!) {\n    preferences(\n      filters: { users_permissions_user: { id: { eq: $user } } }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        id\n        attributes {\n          product {\n            data {\n              id\n            }\n          }\n          preferred\n        }\n      }\n    }\n  }\n"),l=(0,r.U)("\n  mutation createPreference($user: ID!, $product: ID!, $preferred: Boolean!) {\n    createPreference(\n      data: {\n        users_permissions_user: $user\n        product: $product\n        preferred: $preferred\n      }\n    ) {\n      data {\n        id\n      }\n    }\n  }\n"),s=(0,r.U)("\n  mutation updatePreference($id: ID!, $preferred: Boolean!) {\n    updatePreference(id: $id, data: { preferred: $preferred }) {\n      data {\n        id\n      }\n    }\n  }\n"),d=(0,r.U)("\n  mutation deletePreference($id: ID!) {\n    deletePreference(id: $id) {\n      data {\n        id\n      }\n    }\n  }\n"),o=(0,r.U)("\n  query getPreferenceList($farm: ID!) {\n    products(\n      filters: {\n        farm: { id: { eq: $farm } }\n        product_type: { in: 2 }\n        boxable: { eq: true }\n      }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        id\n        attributes {\n          name\n        }\n      }\n    }\n    preferenceGroups(\n      filters: { farm: { id: { eq: $farm } } }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        id\n        attributes {\n          name\n          products(\n            filters: {\n              or: [{ archived: { eq: null } }, { archived: { eq: false } }]\n            }\n            pagination: { limit: -1 }\n          ) {\n            data {\n              id\n              attributes {\n                name\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n")},24345:(e,t,n)=>{n.d(t,{KE:()=>i,dC:()=>a,us:()=>l});var r=n(71843);(0,r.U)("\n  fragment ActiveOrder on OrderEntity {\n    id\n    attributes {\n      week\n      year\n      total\n      discount_total\n      createdAt\n      status\n      delivery_charge\n      order_line_items(pagination: { limit: -1 }) {\n        data {\n          id\n          attributes {\n            name\n            quantity\n            price\n            surcharge\n            subscription_type\n          }\n        }\n      }\n      delivery_round {\n        data {\n          attributes {\n            delivery_day\n            christmas_delivery_day\n            christmas_delivery_week\n          }\n        }\n      }\n      distribution_method {\n        data {\n          attributes {\n            collection_hub_name\n            method\n          }\n        }\n      }\n    }\n  }\n");let i=(0,r.U)("\n  query activeDelivery {\n    activeDelivery {\n      data {\n        ...ActiveOrder\n      }\n    }\n  }\n"),a=(0,r.U)('\n  query getOrders($user: ID!) {\n    orders(\n      filters: { users_permissions_user: { id: { eq: $user } } }\n      pagination: { limit: -1 }\n      sort: "createdAt:desc"\n    ) {\n      data {\n        id\n        attributes {\n          total\n          createdAt\n          status\n        }\n      }\n    }\n  }\n');(0,r.U)("\n  fragment OrderFull on OrderEntity {\n    id\n    attributes {\n      total\n      discount_total\n      createdAt\n      status\n      week\n      year\n      donation\n      delivery_charge\n      delivery_round {\n        data {\n          attributes {\n            delivery_day\n            christmas_delivery_day\n            christmas_delivery_week\n          }\n        }\n      }\n      distribution_method {\n        data {\n          attributes {\n            collection_hub_name\n            method\n          }\n        }\n      }\n      address {\n        data {\n          id\n          attributes {\n            street_1\n            street_2\n            postcode\n            town\n            phone\n          }\n        }\n      }\n      order_line_items(pagination: { limit: -1 }) {\n        data {\n          id\n          attributes {\n            name\n            quantity\n            price\n            subscription_type\n            product {\n              data {\n                id\n                attributes {\n                  product_type\n                  product_badges {\n                    data {\n                      id\n                      attributes {\n                        badge_key\n                      }\n                    }\n                  }\n                }\n              }\n            }\n            swaps {\n              data {\n                id\n                attributes {\n                  price\n                  swap {\n                    data {\n                      id\n                      attributes {\n                        name\n                      }\n                    }\n                  }\n                  boxed_product {\n                    data {\n                      id\n                      attributes {\n                        product {\n                          data {\n                            id\n                          }\n                        }\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n");let l=(0,r.U)("\n  query getOrder($order: ID!) {\n    order(id: $order) {\n      data {\n        ...OrderFull\n      }\n    }\n  }\n")}
1,25004:(e,t,n)=>{n.d(t,{A:()=>tu});var r=n(95155),i=n(12115),a=n(80357),l=n(96869),s=n(4259),d=n(70539),o=n(24627),u=n(80317),c=n(64647),p=n(82019),x=n(1004),h=n(18955),f=n(26302);let m=x.Er?{title:"titleCollection",signUpButton:"signUpCollection"}:{title:"titleDelivery",signUpButton:"signUpDelivery"},b=()=>{let[e,t]=(0,i.useState)(!1),[n,a]=(0,i.useState)("register"),s=(0,f.sf)(),x=(0,h.c)("Sidebar"),b=e=>{a(e),t(!0),"register"===e&&s.capture("signup_dialog_opened")};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.default,{sx:{textAlign:"center"},variant:"outlined",children:(0,r.jsx)(o.default,{children:(0,r.jsxs)(l.default,{spacing:3,alignItems:"center",sx:{py:2,px:3},children:[(0,r.jsx)(u.default,{variant:"h6",children:x(m.title)}),(0,r.jsx)(c.default,{sx:{width:"150px"},variant:"contained",disableElevation:!0,onClick:()=>b("login"),children:x("loginButton")}),(0,r.jsx)(u.default,{variant:"h6",children:x("newCustomer")}),(0,r.jsx)(c.default,{variant:"contained",disableElevation:!0,sx:{width:"150px"},onClick:()=>b("register"),children:x(m.signUpButton)})]})})}),(0,r.jsx)(p.A,{variant:n,open:e,onClose:()=>t(!1)})]})};var v=n(52619),g=n.n(v);let j=()=>{let e=(0,h.c)("Sidebar"),t=x.Er?{title:"titleCollectionNoDeliveryInfo",button:"signUpCollectionNoDeliveryInfo"}:{title:"titleDeliveryNoDeliveryInfo",button:"signUpDelivery"};return(0,r.jsx)(d.default,{sx:{textAlign:"center"},children:(0,r.jsx)(o.default,{children:(0,r.jsxs)(l.default,{spacing:3,children:[(0,r.jsx)(u.default,{children:e(t.title)}),(0,r.jsx)(g(),{href:"/account/delivery-method",passHref:!0,children:(0,r.jsx)(c.default,{variant:"contained",color:"primary",children:e(t.button)})})]})})})};var y=n(72320),_=n(14962),w=n(77524),A=n(24251),k=n(29518),I=n(39970),D=n(19131),S=n(21473),C=n(24345),$=n(70730),O=n(92551),B=n(75426),E=n(34389),q=n(42682),T=n(81827);let M=()=>{var e;let{isAuthenticated:t}=(0,s.A)(),{currency_code:n}=(0,q.P)(),i=(0,h.c)("Sidebar"),l=(0,h.k)(),{data:c,loading:p,startPolling:x}=(0,y.I)(C.KE,{skip:!t}),f=null==c||null==(e=c.activeDelivery)?void 0:e.data;if(p||!f)return null;x(6e4);let m=f.attributes.delivery_round.data.attributes,b=f.attributes.distribution_method.data.attributes,v=(0,$.px)(f.attributes.week,m),g=(0,$.xS)(f.attributes.year,f.attributes.week,v),j=l.dateTime(g,{weekday:"long",month:"short",day:"numeric"});return(0,r.jsxs)(d.default,{variant:"outlined",children:[(0,r.jsx)(o.default,{children:(0,r.jsxs)(a.default,{textAlign:"center",sx:{my:2,mx:4},children:[(0,r.jsx)(u.default,{gutterBottom:!0,variant:"h4",children:i("orderPlaced",{deliveryDay:j})}),(0,r.jsx)(u.default,{component:"span",sx:{color:"#999999",fontWeight:"bold"},children:b.method===O.ok.Collection?i("collectionInfo",{deliveryDay:j,collectionHub:b.collection_hub_name}):i("deliveryInfo",{deliveryDay:j})})]})}),(0,r.jsxs)(_.A,{variant:"outlined",sx:{mx:"-1px !important"},children:[(0,r.jsx)(w.A,{expandIcon:(0,r.jsx)(S.A,{icon:"akar-icons:chevron-down"}),children:(0,r.jsx)(u.default,{children:i("orderDetails")})}),(0,r.jsxs)(A.A,{children:[(0,r.jsx)(k.A,{sx:{borderTop:"1px solid #000",mt:0,mx:0},children:f.attributes.order_line_items.data.map((e,t)=>(0,r.jsxs)(I.Ay,{disableGutters:!0,dense:!0,children:[(0,r.jsx)(D.A,{children:"".concat(e.attributes.quantity," x ").concat(e.attributes.name)}),(0,r.jsx)(D.A,{sx:{textAlign:"right",ml:3},children:(0,T.i)(e.attributes.subscription_type)?null:(0,E.v)(e.attributes.price+e.attributes.surcharge,n)})]},t))}),(0,r.jsx)(B.D,{order:f,distributionMethod:b.method})]})]})]})};var U=n(84389),N=n(4615),F=n(80747),H=n(91012),P=n(84175),L=n(25789),W=n(87123),G=n(71843);(0,G.U)("\n  fragment Swap on SwapEntity {\n    id\n    attributes {\n      price\n      subscription {\n        data {\n          id\n        }\n      }\n      boxed_product {\n        data {\n          id\n          attributes {\n            product {\n              data {\n                attributes {\n                  price\n                }\n              }\n            }\n          }\n        }\n      }\n      swap {\n        data {\n          id\n          attributes {\n            name\n            price\n            origin {\n              data {\n                id\n                attributes {\n                  name\n                  code\n                }\n              }\n            }\n            boxed_options {\n              data {\n                attributes {\n                  origin {\n                    data {\n                      id\n                      attributes {\n                        name\n                        code\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n");let z=(0,G.U)("\n  query swapsInBasket($userId: ID!, $week: Int!, $year: Int!) {\n    swaps(\n      filters: {\n        subscription: { users_permissions_user: { id: { eq: $userId } } }\n        week: { eq: $week }\n        year: { eq: $year }\n      }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        ...Swap\n      }\n    }\n  }\n"),R=(0,G.U)("\n  mutation createSwap(\n    $subscription: ID!\n    $boxed_product: ID!\n    $swap: ID!\n    $box_content: ID!\n    $week: Int!\n    $year: Int!\n    $farmID: ID!\n  ) {\n    createSwap(\n      data: {\n        farm: $farmID\n        subscription: $subscription\n        boxed_product: $boxed_product\n        swap: $swap\n        box_content: $box_content\n        week: $week\n        year: $year\n      }\n    ) {\n      data {\n        ...Swap\n      }\n    }\n  }\n"),K=(0,G.U)("\n  mutation updateSwap($id: ID!, $swap: ID!) {\n    updateSwap(id: $id, data: { swap: $swap }) {\n      data {\n        ...Swap\n      }\n    }\n  }\n"),Y=(0,G.U)("\n  mutation deleteSwap($id: ID!) {\n    deleteSwap(id: $id) {\n      data {\n        id\n      }\n    }\n  }\n");var J=n(20860),Q=n(38032);let V=e=>{var t;let{isAuthenticated:n,user:r}=(0,s.A)(),{deliveryMethod:a}=(0,J.d)(),l={userId:null==r?void 0:r.id,week:null==a?void 0:a.next_fulfillment_week,year:null==a?void 0:a.next_fulfillment_year},{data:d,loading:o,error:u,refetch:c}=(0,y.I)(z,{variables:l,skip:!n||!a}),p=null==d||null==(t=d.swaps)?void 0:t.data,x=(0,i.useMemo)(()=>e?(null==p?void 0:p.filter(t=>{var n,r,i;return(null==t||null==(i=t.attributes)||null==(r=i.subscription)||null==(n=r.data)?void 0:n.id)===e}))||[]:p,[p,e]),[h]=(0,Q.n)(R,{update:(e,t)=>
1{let{data:n}=t,r=null==n?void 0:n.createSwap;e.writeQuery({query:z,variables:l,data:{swaps:{data:[...p,null==r?void 0:r.data]}}})}}),[f]=(0,Q.n)(K,{update:(e,t)=>{let{data:n}=t,r=null==n?void 0:n.updateSwap,i=p.map(e=>{var t;return e.id===(null==r||null==(t=r.data)?void 0:t.id)?null==r?void 0:r.data:e});e.writeQuery({query:z,variables:l,data:{swaps:{data:i}}})}}),[m]=(0,Q.n)(Y,{update:(e,t)=>{let{data:n}=t,r=null==n?void 0:n.deleteSwap,i=p.filter(e=>{var t;return e.id!==(null==r||null==(t=r.data)?void 0:t.id)});e.writeQuery({query:z,variables:l,data:{swaps:{data:i}}})}}),b=async e=>{await h(e)},v=async e=>{await f(e)},g=async e=>{await m(e)};return n&&a?{swaps:x,loading:o,error:u,addSwap:b,updateSwap:v,removeSwap:g,refetch:c}:{loading:!0}};var X=n(43791),Z=n(2124),ee=n(50355),et=n(50301),en=n(60193),er=n(98638),ei=n(42200),ea=n(16485),el=n(44517),es=n(9837);function ed(e){var t;let{data:n,swap:i,disabled:l,handleSwap:s,loadingUpdate:d,getSwapWithinTreshhold:o}=e,{currency_code:u}=(0,q.P)();return(0,r.jsx)(Z.A,{disabled:l||d,disableClearable:!0,disablePortal:!0,freeSolo:!0,id:"products",value:(null==i?void 0:i.attributes.swap.data)||null,onChange:(e,t)=>
1s(t.id),options:(null==(t=n.products.data)?void 0:t.filter(e=>!o(e.attributes.price)||e.attributes.hv_swap))||[],renderOption:(e,t)=>(0,r.jsx)(ec,{props:e,option:t,getSwapWithinTreshhold:o,currency_code:u},null==t?void 0:t.id),getOptionLabel:e=>e.attributes.name,renderInput:e=>{var t;return(0,r.jsxs)(a.default,{sx:{position:"relative"},children:[(0,r.jsx)(eo,{swap:i}),(0,r.jsx)(eu,{swap:i,currency_code:u}),(0,r.jsx)(ee.A,{...e,variant:"standard",placeholder:"Select a swap",sx:{width:"100%","& .MuiInput-root .MuiInput-input":{pl:"30px",pr:o(null==i||null==(t=i.attributes.swap.data)?void 0:t.attributes.price)?"0":"55px"}}})]})}})}function eo(e){var t,n,i,l;let{swap:s}=e;return(0,r.jsx)(r.Fragment,{children:(null==s||null==(t=s.attributes.swap.data)?void 0:t.attributes.origin.data)&&(0,r.jsx)(a.default,{sx:{position:"absolute",top:"50%",transform:"translateY(-50%)"},children:(0,r.jsx)(ei.default,{sx:{width:"20px",height:"15px"},origin:(null==s||null==(i=s.attributes.swap.data)||null==(n=i.attributes.boxed_options.data[0])?void 0:n.attributes.origin.data)||(null==s||null==(l=s.attributes.swap.data)?void 0:l.attributes.origin.data)})})})}function eu(e){let{swap:t,currency_code:n}=e;return(0,r.jsx)(r.Fragment,{children:!!(null==t?void 0:t.attributes.price)&&(0,r.jsxs)(u.default,{variant:"body2",sx:{position:"absolute",top:"50%",transform:"translateY(-50%)",right:0},children:["+ ",(0,E.v)(t.attributes.price,n)]})})}function ec(e){var t;let{props:n,option:i,getSwapWithinTreshhold:a,currency_code:s}=e,d=a(i.attributes.price),{key:o,...c}=n;return(0,r.jsxs)(l.default,{direction:"row",spacing:3,sx:{p:1},...c,children:[(0,r.jsx)(ei.default,{sx:{width:"20px",height:"15px"},origin:(null==(t=i.attributes.boxed_options.data[0])?void 0:t.attributes.origin.data)||i.attributes.origin.data}),(0,r.jsx)(u.default,{flex:1,textAlign:"left",children:i.attributes.name}),!!d&&(0,r.jsxs)(u.default,{variant:"body2",children:["+ ",(0,E.v)(d,s)]})]},o)}function ep(e){let{disabled:t,loading:n,active:i,onClick:a}=e;return(0,r.jsx)(et.default,{title:"Swap",placement:"left",arrow:!0,children:(0,r.jsx)(en.A,{disabled:t,onClick:a,color:i?"secondary":"inherit",sx:{fontSize:"18px",opacity:t?.1:1},id:"swap-button",children:n?(0,r.jsx)(er.default,{size:"18px"}):(0,r.jsx)(S.A,{icon:"charm:swap-horizontal"})})})}let ex=e=>{let{subscriptionId:t,boxContentsId:n,boxed:a,swap:s,limit:d,sx:o}=e,{deliveryMethod:c}=(0,J.d)(),{swaps:p,addSwap:h,updateSwap:f,removeSwap:m}=V(t),[b,v]=(0,i.useState)(!!s),[g,j]=(0,i.useState)(!1),{isBasketLocked:_,nextDelivery:w}=(0,es.A)(),A=(null==p?void 0:p.length)>=d&&!s;(0,i.useEffect)(()=>{v(!!s)},[s]);let{data:k,loading:I}=(0,y.I)(ea.XJ,{variables:{farm:x.tp,boxContentId:n},skip:!b});if(!a||!c)return null;let D=(null==s?void 0:s.id)?f:h,S=g||_&&w.map(e=>e.id).includes(t)||A;return(0,r.jsxs)(l.default,{direction:"row",spacing:3,alignItems:"center",sx:{...o},children:[(0,r.jsx)(ep,{disabled:S,loading:g,active:b,onClick:()=>!A&&void(s&&m&&m({variables:{id:null==s?void 0:s.id},onError:e=>el.default.error("".concat(e.message))}),v(!b))}),(0,r.jsxs)(l.default,{spacing:.5,sx:{width:"100%"},children:[(0,r.jsxs)(l.default,{direction:"row",spacing:1,alignItems:"center",children:[(0,r.jsx)(ei.default,{sx:{width:"20px",height:"auto"},origin:a.origin}),(0,r.jsx)(u.default,{variant:"body2",sx:{textDecoration:b?"line-through":"none"},children:a.name})]}),b&&(!A||(null==s?void 0:s.attributes.swap.data))&&(I?(0,r.jsxs)(l.default,{direction:"row",alignItems:"center",spacing:3,sx:{py:1},children:[(0,r.jsx)(X.default,{width:"20px",height:"15px",variant:"rectangular"}),(0,r.jsx)(X.default,{width:"90px",height:"5px",variant:"rectangular"})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ed,{swap:s,data:k,disabled:A,handleSwap:e=>{j(!0),D&&D({variables:{id:null==s?void 0:s.id,swap:e,farmID:x.tp,subscription:t,boxed_product:a.id,box_content:n,week:c.next_fulfillment_week,year:c.next_fulfillment_year},onCompleted:()=>{j(!1)},onError:e=>{el.default.error("".concat(e.message,", please try a different product.")),j(!1)}})},loadingUpdate:g,getSwapWithinTreshhold:e=>a.value+.25<e?e-a.value:0})}))]})]})},eh=e=>{var t,n,i,s;let{product:d,subscription:o}=e,c=(0,h.c)("Subscription"),{boxContents:p,isExampleContent:x}=(0,P.c)(d.id),{swaps:f}=V(o.id),m=null==(s=(0,L.A)().components)||null==(i=s.MuiCard)||null==(n=i.styleOverrides)||null==(t=n.root)?void 0:t.backgroundColor;return 0===p.length||x?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.default,{sx:{ml:1},direction:"row",spacing:3,children:[(0,r.jsx)(u.default,{fontWeight:"bold",variant:"body2",sx:{flex:1,textAlign:"left"},children:c("boxContents")}),d.attributes.available_swaps>0&&(0,r.jsx)(u.default,{variant:"body2",sx:{opacity:.5},children:c("swaps",{currentSwaps:(null==f?void 0:f.length)||0,maxSwaps:d.attributes.available_swaps||0})})]}),(0,r.jsx)(a.default,{sx:{mx:-2},children:p.map((e,t)=>{let n=null==f?void 0:f.findIndex(t=>t.attributes.boxed_product.data.id===(null==e?void 0:e.id));return(0,r.jsx)(ex,{swap:null==f?void 0:f[n],limit:d.attributes.available_swaps,subscriptionId:o.id,boxContentsId:null==e?void 0:e.box_contents_id,boxed:e,sx:{px:2,py:.5,backgroundColor:(e=>m?e%2==0?m:(0,W.e$)(m,.04):e%2?"#F9F9F9":"#fff")(t)}},t)})})]})};var ef=n(75265),em=n(2021),eb=n(99496),ev=n(73224),eg=n(66370);function ej(e){let t=(0,h.c)("AlertDialogTemplate"),{open:n,onClose:i,title:a,c
1ontent:l,closeText:s=t("close")}=e;return(0,r.jsxs)(ef.A,{open:n,onClose:i,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-content",children:[(0,r.jsx)(em.A,{id:"alert-dialog-title",children:a}),(0,r.jsx)(eb.A,{children:(0,r.jsx)(ev.A,{id:"alert-dialog-content",children:l})}),(0,r.jsx)(eg.A,{sx:{px:3,pb:2,pt:0},children:(0,r.jsx)(c.default,{onClick:i,variant:"contained",autoFocus:!0,children:s})})]})}var ey=n(21641),e_=n(92862),ew=n(67613),eA=n(20048),ek=n(73170),eI=n(91500),eD=n(93488);let eS=e=>{var t;let{subscription:n,disabled:i,type:a,onEdit:s,onLockedAlert:d}=e,o=(e=>{var t;let{country:n,currency_code:r,email:i}=(0,q.P)(),{deliveryMethod:a}=(0,J.d)(),{isBasketLocked:l,nextDelivery:s}=(0,es.A)();if(!a)return null;let d=e.attributes.product.data,o=e.attributes.variant.data||d,{isCurrentWeekLocked:u}=(0,eD.c)(d.attributes,a,null==(t=e.attributes)?void 0:t.next_week,n);return{product:d,item:o,isLocked:u,disableEdit:s.includes(e)&&l,currency_code:r,email:i}})(n),c=(0,h.c)("Settings"),p=(0,h.c)("Subscription");if(!o)return null;let{product:x,item:f,isLocked:m,disableEdit:b,currency_code:v,email:g}=o;return(0,r.jsxs)(I.Ay,{sx:{minHeight:"80px",alignItems:"center"},secondaryAction:!i&&(0,r.jsx)(et.default,{title:m?p("disabled_by_locked",{farmEmail:g}):p("edit"),placement:"right",arrow:!0,children:(0,r.jsx)(en.A,{edge:"end","aria-label":"edit",onClick:()=>m?d():s(),disabled:b,children:(0,r.jsx)(S.A,{icon:m?"iconamoon:lock":"clarity:note-edit-line"})})}),children:[(0,r.jsx)(ey.A,{sx:{mr:2,gap:.5,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:(0,r.jsx)(ew.A,{alt:f.attributes.name,sx:{maxWidth:"60px"},src:(0,eA.A)(null==(t=x.attributes.thumbnail.data)?void 0:t.attributes.url)})}),(0,r.jsx)(D.A,{disableTypography:!0,primary:(0,r.jsxs)(r.Fragment,{children:[n&&(0,r.jsxs)(l.default,{direction:"row",alignItems:"center",spacing:1,children:[(0,r.jsx)(S.A,{icon:"ci:repeat"}),(0,r.jsx)(u.default,{variant:"body2",sx:{fontSize:"0.8rem"},alignItems:"center",children:(0,ek.e)(n.attributes.recurring,c)})]}),(0,r.jsx)(u.default,{variant:"body1",sx:{fontWeight:"bold"},children:f.attributes.name})]}),secondary:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.default,{direction:"row",spacing:2,alignItems:"center",children:[(0,r.jsxs)(u.default,{variant:"body2",sx:{flex:1},children:[n.attributes.quantity," x"," ",(0,r.jsx)(e_.A,{quantity:n.attributes.amount||f.attributes.quantity,uom:f.attributes.uom})]}),!(0,T.i)(a)&&(0,r.jsx)(u.default,{variant:"body1",sx:{fontWeight:"bold"},children:(0,E.v)(n.attributes.amount?f.attributes.price/f.attributes.quantity*n.attributes.amount:f.attributes.price,v)})]}),(0,r.jsx)(eI.ProductBadgesGroup,{size:"s",product_badges:x.attributes.product_badges.data.map(e=>e.attributes.badge_key)})]})})]})},eC=e=>{let{subscription:t,disabled:n,hideBoxContent:a=!1,type:l}=e,[s,d]=(0,i.useState)(!1),[o,u]=(0,i.useState)(!1),{deliveryMethod:c}=(0,J.d)(),{email:p}=(0,q.P)(),x=(0,h.c)("Subscription");if(!c)return null;let f=t.attributes.product.data,m=1===f.attributes.product_type;return(0,r.jsxs)(k.A,{sx:{width:"100%",color:"#000"},children:[(0,r.jsx)(eS,{subscription:t,disabled:n,type:l,onEdit:()=>d(!0),onLockedAlert:()=>u(!0)}),!a&&m&&(0,r.jsx)(eh,{product:f,subscription:t}),(0,r.jsx)(H.A,{open:s,onClose:()=>d(!1),children:(0,r.jsx)(F.A,{open:s,onClose:()=>d(!1),product:f.attributes,subscription:t,type:l})}),(0,r.jsx)(ej,{open:o,onClose:()=>u(!1),title:x("locked_subscription"),content:x("disabled_by_locked",{farmEmail:p})})]})};var e$=n(36792),eO=n(36308);let eB=(e,t)=>e.reduce((e,n)=>{let r=eE(n),i=n.attributes.amount,a=null==t?void 0:t.find(e=>n.id===e.attributes.subscription.data.id),l=eq(i,r),s=a?a.attributes.price:0;return e+n.attributes.quantity*(l+s)},0),eE=e=>{let t=e.attributes.variant.data;return t||e.attributes.product.data},eq=(e,t)=>e?t.attributes.price/t.attributes.quantity*e:t.attributes.price,eT=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{swaps:t}=V(),n=eB(e,t),r=(0,i.useMemo)(()=>!!e.find(e=>1===e.attributes.product.data.attributes.product_type),[e]);return e?{subtotal:n,hasVegbox:r}:{subtotal:0,loading:!0}},eM=e=>{var t,n;let{subscriptions:i}=e,{subtotal:l}=eT(i),{currency_code:s}=(0,q.P)(),{getSettingValue:d}=(0,eO.t)(),o=(0,h.c)("Basket"),c=null!=(t=d(e$.qE.SUBBASKET_NAME))?t:"",p=Number(null!=(n=d(e$.qE.SUBBASKET_MIN_SPEND))?n:0);return(0,r.jsxs)(a.default,{sx:{borderTop:"1px solid #000",mt:2},children:[(0,r.jsx)(u.default,{variant:"h4",textAlign:"center",sx:{mt:2},children:c}
1),l<p&&(0,r.jsx)(N.default,{severity:"error",children:o("minSpendError",{minSpend:(0,E.v)(p,s),basketName:c})}),i.map(e=>(0,r.jsx)(eC,{subscription:e,type:e$.jJ.SUB_BASKET},e.id))]})};var eU=n(28568),eN=n.n(eU);let eF=(e,t)=>e*(t.percentage/100);(0,G.U)("\n  fragment DiscountFull on Discount {\n    discount_applied_id\n    percentage\n    type\n    code\n    description\n    discounted_products {\n      id\n    }\n    usage_rule\n    usage_rule_value\n  }\n");let eH=(0,G.U)("\n  mutation applyDiscountCode($code: String!) {\n    applyDiscountCode(code: $code) {\n      id\n    }\n  }\n"),eP=(0,G.U)("\n  query discountAppliedToMe {\n    discountAppliedToMe {\n      ...DiscountFull\n    }\n  }\n"),eL=(0,G.U)("\n  mutation deleteDiscountApplied($id: ID!) {\n    deleteDiscountApplied(id: $id) {\n      data {\n        id\n      }\n    }\n  }\n"),eW=()=>{var e;let{user:t}=(0,s.A)(),{data:n,loading:r,error:i}=(0,y.I)(eP),a=null==n?void 0:n.discountAppliedToMe,l=((e,t)=>{if(!e)return{appliesNow:!1,eligibleOrderNumber:null};let n=t+1;switch(e.usage_rule){case O.KN.Unlimited||O.KN.OrderLimit:return{appliesNow:!0,eligibleOrderNumber:null};case O.KN.SpecificOrders:{let t=e.usage_rule_value;if(t.includes(n))return{appliesNow:!0,eligibleOrderNumber:null};let r=t.filter(e=>e>n).sort((e,t)=>e-t)[0];return{appliesNow:!1,eligibleOrderNumber:null!=r?r:null}}default:return{appliesNow:!0,eligibleOrderNumber:null}}})(a,null!=(e=null==t?void 0:t.order_count)?e:0);return{discount:a,loading:r,error:i,eligibility:l}},eG=e=>{let{nextDelivery:t}=(0,es.A)(),{swaps:n}=V(),{deliveryMethod:r}=(0,J.d)(),{discount:i,eligibility:a}=eW(),{settings:l}=(0,eO.t)(),s=null!=e?e:t;if(!s||!r)return{subtotal:0,discountTotal:0,deliveryCost:0,packingFee:0,total:0,loading:!0,hasVegbox:!1};let d=eB(s,n),o=s.some(e=>1===e.attributes.product.data.attributes.product_type),u=a.appliesNow?((e,t,n)=>e&&0!==t.length?e.type===O.kJ.WholeOrder?eF(n,e):((e,t)=>t.reduce((t,n)=>{let r=eE(n);if(!e.discounted_products.find(e=>e.id===r.id))return t;let i=eq(n.attributes.amount,r);return eF(n.attributes.quantity*i,e)+t},0))(e,t):0)(i,s,d):0,c=((e,t,n)=>{if(!n||!t)return 0;let r=e.filter(e=>e.attributes.product.data.attributes.has_packing_fee);return 0===r.length||eB(r)>=n?0:t})(s,Number(l.packing_fee),Number(l.packing_fee_spend_limit)),p=((e,t,n)=>0===e.cost||x.tp===e$.Ih.BARCOMBE&&n||x.tp===e$.Ih.LEEDS_VEG_BOX&&t>=30||x.tp===e$.Ih.WYE_ORGANIC&&t>=35||x.tp===e$.Ih.LMOP&&(t>=25||n)||x.tp===e$.Ih.WILDFARM&&(t>=20||n)||x.tp===e$.Ih.LOCAVORE&&t>=45||x.tp===e$.Ih.SHILLINGFORD&&t>=30||x.tp===e$.Ih.GOODERY&&t>=35||x.tp===e$.Ih.CAMBRIDGE_CUT_FLOWERS&&(t>=45||n)||x.tp===e$.Ih.VALLEY_ROOTS&&t>=30||x.tp===e$.Ih.FFOREST_MOUNTAIN&&t>=30?0:e.cost)(r,d,o),h=p+d+c-u;return{subtotal:d,hasVegbox:o,packingFee:c,deliveryCost:p,discountTotal:u,total:h}},ez=e=>{let{currency_code:t}=(0,q.P)(),{settings:n}=(0,eO.t)(),i=(0,h.c)("Basket"),a=i("dialogPackingFeeContent",{packingFeeName:n.packing_fee_name||"",packingFee:(0,E.v)(n.packing_fee,t),packingFeeSpend:(0,E.v)(n.packing_fee_spend_limit,t)});return(0,r.jsxs)(ef.A,{maxWidth:"sm",...e,children:[(0,r.jsx)(em.A,{children:i("dialogPackingFeeTitle",{packingFeeName:n.packing_fee_name||""})}),(0,r.jsx)(u.default,{children:a}),(0,r.jsx)(eg.A,{children:(0,r.jsx)(c.default,{variant:"contained",disableElevation:!0,onClick:()=>e.onClose("closeButtonClick"),children:"close"})})]})},eR=e=>{let{subscriptions:t}=e,n=(0,h.c)("Basket"),s=(0,h.c)("DeliveryMethodsTemplate"),{currency_code:d}=(0,q.P)(),{subtotal:o,packingFee:u,deliveryCost:c,total:p,discountTotal:x}=eG(t),{deliveryMethod:f}=(0,J.d)(),{settings:m}=(0,eO.t)(),[b,v]=(0,i.useState)(!1);return f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.A,{dense:!0,children:[o!==p&&(0,r.jsxs)(I.Ay,{children:[(0,r.jsx)(D.A,{children:n("subtotal")}),(0,r.jsx)(D.A,{sx:{textAlign:"right"},children:(0,E.v)(o,d)})]}),0!==x&&(0,r.jsxs)(I.Ay,{children:[(0,r.jsx)(D.A,{children:n("discount")}),(0,r.jsx)(D.A,{sx:{textAlign:"right"},children:(0,E.v)(x,d)})]}),0!==u&&(0,r.jsxs)(I.Ay,{children:[(0,r.jsx)(D.A,{children:(0,r.jsxs)(l.default,{direction:"row",alignItems:"center",children:[(0,r.jsx)(a.default,{children:m.packing_fee_name||n("packingFee")})," ",(0,r.jsx)(en.A,{onClick:()=>
1v(!0),sx:{my:-1},children:(0,r.jsx)(S.A,{icon:"material-symbols:help-outline",sx:{fontSize:"20px"}})})]})}),(0,r.jsx)(D.A,{sx:{textAlign:"right"},children:(0,E.v)(u,d)})]}),(0,r.jsxs)(I.Ay,{children:[(0,r.jsx)(D.A,{children:eN()(s(f.method))}),(0,r.jsx)(D.A,{sx:{textAlign:"right"},children:0===c?n("free"):(0,E.v)(c,d)})]}),(0,r.jsxs)(I.Ay,{children:[(0,r.jsx)(D.A,{children:n("total")}),(0,r.jsx)(D.A,{sx:{textAlign:"right"},children:(0,E.v)(p,d)})]})]}),(0,r.jsx)(ez,{open:b,onClose:()=>v(!1)})]}):null};var eK=n(97983);let eY=()=>{let{deliveryMethod:e}=(0,J.d)(),t=(0,h.c)("Basket"),n=(0,h.c)("DeliveryMethodsTemplate");return e?(0,r.jsx)(a.default,{sx:{m:2},children:(0,r.jsx)(eK.Y,{href:"/account/holidays",children:(0,r.jsxs)(l.default,{direction:"row",alignItems:"center",spacing:1,children:[(0,r.jsx)(S.A,{icon:"zondicons:pause-outline"})," ",(0,r.jsx)(u.default,{variant:"body2",children:t("pauseDeliveries",{method:n(e.method)})})]})})}):null},eJ=()=>{let{deliveryMethod:e}=(0,J.d)(),{nextDelivery:t}=(0,es.A)(),n=(0,h.c)("Basket"),i=(0,h.c)("DeliveryMethodsTemplate");if(!e)return null;if(!t.length)return(0,r.jsx)(N.default,{severity:"warning",sx:{mt:3},children:n("emptyWarning",{method:i(e.method)})});let l=t.filter(e=>e.attributes.type!==e$.jJ.SUB_BASKET),s=t.filter(e=>e.attributes.type===e$.jJ.SUB_BASKET);return(0,r.jsxs)(a.default,{children:[l.map(e=>(0,r.jsx)(eC,{subscription:e},e.id)),s.length>0&&(0,r.jsx)(eM,{subscriptions:s}),(0,r.jsx)(U.default,{}),(0,r.jsx)(eR,{}),(0,r.jsx)(U.default,{}),!e$.eC.includes(x.tp)&&(0,r.jsx)(eY,{})]})};var eQ=n(50316),eV=n(57994);let eX=()=>{let{isBasketLocked:e,nextProcessDate:t}=(0,es.A)(),[n,a]=(e=>{let t=new Date(e).getTime(),[n,r]=(0,i.useState)(t-new Date().getTime());return(0,i.useEffect)(()=>{let e=setInterval(()=>{r(t-new Date().getTime())},1e3);return()=>clearInterval(e)},[t]),(e=>[Math.floor(e%864e5/36e5),Math.floor(e%36e5/6e4),Math.floor(e%6e4/1e3)])(n)})(t),l=(0,h.c)("Basket"),{deliveryMethod:s}=(0,J.d)();if(!t||!s)return null;if(e)return(0,r.jsx)(u.default,{children:l("yourBasketisLocked",{method:s.method})});let d=new Date,o=(0,eQ.c)(t,d)+1;return(0,eV.M)(t,d)>24?(0,r.jsx)(u.default,{children:l("daysToMakeChanges",{days:o})}):n>0?(0,r.jsx)(u.default,{children:l("hoursLeftToMakeChanges",{hours:n})}):a>0?(0,r.jsx)(u.default,{children:l("minutesLeftToMakeChanges",{minutes:a})}):null};var eZ=n(16615),e0=n(84053);let e1=(0,n(67909).default)(()=>Promise.all([n.e(3200),n.e(2083)]).then(n.bind(n,52083)),{loadableGenerated:{webpack:()=>[52083]},ssr:!1}),e2=()=>{let e=(0,h.c)("Basket"),t=(0,h.c)("DeliveryMethodsTemplate"),[n,a]=(0,i.useState)(!1),{user:l,initialize:d}=(0,s.A)(),{deliveryMethod:o}=(0,J.d)();return l&&o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.default,{onClick:()=>a(!0),component:"span",sx:{textDecoration:"underline",cursor:"pointer"},children:l.address?e("setupPayment",{method:t(o.method)}):e("addAddress",{method:t(o.method)})}),(0,r.jsxs)(ef.A,{open:n,onClose:()=>a(!1),fullWidth:!0,maxWidth:"sm",children:[(0,r.jsx)(em.A,{children:e("setupTitle",{item:e(l.address?"paymentMethod":"address")})}),(0,r.jsx)(eb.A,{dividers:!0,children:l.address?(0,r.jsx)(e1,{onClose:()=>a(!1)}):(0,r.jsx)(e0.t,{onComplete:e=>d(),onClose:()=>a(!1)})})]})]}):null};var e5=n(57327),e3=n(33319);let e4=()=>{var e;let{user:t}=(0,s.A)(),{isNextDeliveryOnHoliday:n}=(0,e3.w)(),{currency_code:i}=(0,q.P)(),{deliveryMethod:a}=(0,J.d)(),l=(0,h.c)("Basket"),d=(0,h.k)(),o=(0,h.c)("DeliveryMethodsTemplate"),{subtotal:c,hasVegbox:p,loading:f}=eG(),{data:m,loading:b}=(0,y.I)(e5.Md,{variables:{farm:x.tp}});if(!t||!a)return null;let v=(0,$.px)(a.next_fulfillment_week,a),g=(0,$.xS)(a.next_fulfillment_year,a.next_fulfillment_week,v),j=d.dateTime(g,{weekday:"long",month:"short",day:"numeric"}),{address:_,credit:w}=t;if(!_)return(0,r.jsx)(e8,{severity:"error",children:(0,r.jsx)(e2,{})});if(w&&w.amount<c&&!t.payment)return(0,r.jsxs)(e8,{severity:"error",children:[(0,r.jsx)(u.default,{sx:{mb:1},children:l("insufficientCredit",{amount:(0,E.v)(w.amount||0,i)})}),(0,r.jsx)(e2,{})]});if(!t.payment&&!w)return(0,r.jsx)(e8,{severity:"error",children:(0,r.jsx)(e2,{})});if(n(a))if(t.donate_holidays)return(0,r.jsxs)(e8,{severity:"error",children:[(0,r.jsx)(u.default,{sx:{mb:1},children:l("donationOnHoliday",{deliveryDay:j})}),(0,r.jsx)(e9,{children:l("changeHolidaysDonation")})]});else return(0,r.jsxs)(e8,{severity:"error",children:[(0,r.jsx)(u.default,{sx:{mb:1},children:l("noDelivery",{method:o(a.method),deliveryDay:j})}),(0,r.jsx)(e9,{children:l("changeHolidays")})]});if(f||b)return(0,r.jsx)(eZ.A,{});let A=function(e,t,n,r,i,a){let l=e.filter(e=>"delivery"===t&&e.attributes.applies_on_delivery||"collection"===t&&e.attributes.applies_on_collection),s=[];for(let e of l){if("hasBox"===e.attributes.option)if(n)return[];else s.push(i("addBox",{boxType:"veg"}));if("minSpend"===e.attributes.option)if(Number(r)>=Number(e.attributes.value))return[];else s.push(i("spendMinimum",{value:(0,E.v)(e.attributes.value,a)}))}return s}((null==m||null==(e=m.conversionRules)?void 0:e.data)||[],a.method,p,c,l,i);return A.length>0?(0,r.jsx)(e8,{severity:"error",children:(0,r.jsx)(u.default,{children:l("pleaseDoToEnable",{messages:A.join(" or "),method:o(a.method)})})}):(0,r.jsx)(e8,{severity:"success",children:(0,r.jsx)(u.default,{children:l("confirmed",{method:o(a.method)})})})},e8=e=>{let{severity:t,children:n}=e;return(0,r.jsx)(a.default,{sx:{padding:2.5,backgroundColor:"error"===t?"#ff1744":"primary.main",color:"error"===t?"#fff":"primary.contrastText"},children:(0,r.jsxs)(l.default,{direction:"row",spacing:3,alignItems:"center",children:[(0,r.jsx)(S.A,{s
1x:{fontSize:"23px",minWidth:"20px"},icon:"error"===t?"akar-icons:circle-alert":"material-symbols:check-circle-outline"}),(0,r.jsx)(a.default,{children:n})]})})},e9=e=>{let{children:t}=e;return(0,r.jsx)(g(),{href:"/account/holidays",passHref:!0,children:(0,r.jsx)(u.default,{sx:{color:"#fff",textDecoration:"underline",cursor:"pointer"},children:t})})},e6=e=>{let{week:t,subscriptions:n,showSummary:i}=e,{deliveryMethod:l}=(0,J.d)(),{isDateBooked:s}=(0,e3.w)(),d=(0,h.c)("Basket"),o=(0,h.k)();if(!l)return null;let c=n.filter(e=>e.attributes.type!==e$.jJ.SUB_BASKET),p=n.filter(e=>e.attributes.type===e$.jJ.SUB_BASKET),x=(0,$.px)(t,l),f=(0,$.xS)((0,$.S4)(t),t,x),m=o.dateTime(f,{weekday:"long",month:"short",day:"numeric"});return(0,r.jsxs)(a.default,{children:[(0,r.jsx)(a.default,{display:"flex",alignItems:"center",sx:{backgroundColor:s(f)?"error.main":"primary.light",px:4,py:2,my:2,mx:-3},children:(0,r.jsx)(u.default,{sx:{color:"primary.contrastText"},children:0===t?d("arrivingWeekly"):d("preorderDateMessage",{status:s(f)?"booked":"available",deliveryDate:m})})}),c.map(e=>(0,r.jsx)(eC,{subscription:e,hideBoxContent:!0},e.id)),p.length>0&&(0,r.jsx)(eM,{subscriptions:p}),i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(U.default,{}),(0,r.jsx)(eR,{subscriptions:n})]})]})},e7=()=>{let{preOrders:e,isBasketLocked:t}=(0,es.A)();return(0,r.jsx)(r.Fragment,{children:e.map(e=>{let{week:n,subscriptions:i}=e;return(0,r.jsx)(e6,{week:n,subscriptions:i,showSummary:t},n)})})};var te=n(51003);let tt=e=>{let{discount:t}=e,n=(0,h.c)("Basket"),i=!!t;return(0,r.jsxs)(_.A,{elevation:0,children:[(0,r.jsx)(w.A,{sx:{fontSize:"0.875rem"},expandIcon:(0,r.jsx)(S.A,{icon:"uiw:down"}),children:n(i?"promoCodeActive":"addPromoCode")}),(0,r.jsx)(A.A,{children:i?(0,r.jsx)(tr,{discount:t}):(0,r.jsx)(tn,{})})]})},tn=()=>{let[e,t]=(0,i.useState)(""),n=(0,h.c)("Basket"),[a,{loading:s}]=(0,Q.n)(eH,{variables:{code:e},onCompleted:()=>el.default.success(n("discountAppliedSuccess")),onError:e=>el.default.error(e.message),refetchQueries:["discountAppliedToMe"]});return(0,r.jsxs)(l.default,{direction:"row",spacing:1,children:[(0,r.jsx)(ee.A,{size:"small",label:n("enterCode"),value:e,onChange:e=>{t(e.target.value)}}),(0,r.jsx)(c.default,{variant:"contained",size:"small",onClick:()=>a(),disabled:""===e,loading:s,children:n("applyButton")})]})},tr=e=>{let{discount:t}=e,n=(0,h.c)("Basket"),{eligibility:i}=eW(),{deliveryMethod:s}=(0,J.d)(),[d,{loading:o}]=(0,Q.n)(eL,{variables:{id:t.discount_applied_id},onCompleted:()=>el.default.success(n("discountRemovedSuccess")),onError:e=>el.default.error(e.message),refetchQueries:["discountAppliedToMe"]});return(0,r.jsxs)(a.default,{sx:{textAlign:"left"},children:[(0,r.jsxs)(l.default,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1},children:[(0,r.jsx)(S.A,{icon:"ic:baseline-discount"}),(0,r.jsx)(u.default,{variant:"body2",component:"span",sx:{fontWeight:500},children:t.code})]}),(0,r.jsx)(u.default,{variant:"body2",sx:{mb:1},children:ti(t,n)}),(0,r.jsx)(u.default,{variant:"body2",children:(()=>{var e;let t=null!=(e=null==s?void 0:s.method)?e:"delivery";return i.appliesNow?n("discountInfoAppliesNow"):i.eligibleOrderNumber?n("discountInfoFutureOrder",{orderNumber:i.eligibleOrderNumber,method:t}):n("discountInfoNextOrder",{method:t})})()}),(0,r.jsx)(c.default,{sx:{mt:2},onClick:()=>d(),loading:o,children:n("removeButton")})]})},ti=(e,t)=>{if(e.description)return e.description;let n=Math.round(e.percentage);
1if(e.usage_rule===O.KN.SpecificOrders){let r=e.usage_rule_value||[];if(r.length>0)return ta(n,r,t)}return e.usage_rule===O.KN.OrderLimit?tl(n,e.usage_rule_value,t):t("discountDescriptionDefault",{percentage:n})},ta=(e,t,n)=>{let r=ts(t,n);return n("discountDescriptionSpecificOrders",{percentage:e,orders:r,orderCount:t.length})},tl=(e,t,n)=>1===t?n("discountDescriptionOrderLimitSingle",{percentage:e}):n("discountDescriptionOrderLimitMultiple",{percentage:e,limit:t}),ts=(e,t)=>{if(0===e.length)return"";let n=[...e].sort((e,t)=>e-t).map(te.Ro);return 1===n.length?n[0]:2===n.length?t("discountOrderNumbersTwo",{first:n[0],second:n[1]}):t("discountOrderNumbersMultiple",{allButLast:n.slice(0,-1).join(", "),last:n[n.length-1]})},td=()=>{let{user:e}=(0,s.A)(),{deliveryMethod:t}=(0,J.d)(),{isNextDeliveryOnHoliday:n}=(0,e3.w)(),{discount:i}=eW(),{isBasketLocked:l}=(0,es.A)(),c=(0,h.c)("Basket"),p=(0,h.k)();if(!e||!t)return null;let f=(0,$.px)(t.next_fulfillment_week,t),m=(0,$.xS)(t.next_fulfillment_year,t.next_fulfillment_week,f),b=p.dateTime(m,{weekday:"long",month:"short",day:"numeric"});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(d.default,{variant:"outlined",children:[(0,r.jsx)(e4,{}),(0,r.jsxs)(o.default,{children:[(0,r.jsxs)(a.default,{textAlign:"center",sx:{mb:3},children:[(0,r.jsx)(to,{user:e,isOnHoliday:n(t),deliveryMethod:t}),(0,r.jsx)(u.default,{children:c("fulfillmentDate",{method:t.method,date:b})}),(0,r.jsx)(eX,{}),e$.eC.includes(x.tp)&&(0,r.jsx)(a.default,{sx:{display:"flex",justifyContent:"center"},children:(0,r.jsx)(eY,{})}),(0,r.jsx)(eJ,{})]}),!l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(U.default,{}),(0,r.jsx)(tt,{discount:i})]})]}),(0,r.jsx)(e4,{})]}),(0,r.jsx)(d.default,{variant:"outlined",children:(0,r.jsxs)(o.default,{children:[(0,r.jsx)(u.default,{variant:"h4",children:c("futurePreorders")}),(0,r.jsx)(e7,{}),l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(U.default,{}),(0,r.jsx)(tt,{discount:i})]})]})})]})},to=e=>{let{user:t,isOnHoliday:n,deliveryMethod:i}=e,a=(0,h.c)("Basket"),l=a("nextDelivery",{method:(0,h.c)("DeliveryMethodsTemplate")(i.method)});return n&&(l=a(t.donate_holidays?"donationActive":"onHoliday")),(0,r.jsx)(u.default,{variant:"h3",children:l})},tu=e=>{let{isAuthenticated:t}=(0,s.A)(),{deliveryMethod:n,loadingDeliveryMethod:i}=(0,J.d)();return t?i?(0,r.jsx)(a.default,{...e,children:(0,r.jsx)(eZ.A,{})}):n?(0,r.jsx)(a.default,{...e,children:(0,r.jsxs)(l.default,{spacing:3,children:[(0,r.jsx)(M,{}),(0,r.jsx)(td,{})]})}):(0,r.jsx)(a.default,{...e,children:(0,r.jsx)(j,{})}):(0,r.jsx)(a.default,{...e,children:(0,r.jsx)(b,{})})}},33319:(e,t,n)=>{n.d(t,{w:()=>f});var r=n(71843);(0,r.U)("\n  query getHoliday($id: ID!) {\n    holiday(id: $id) {\n      data {\n        id\n        attributes {\n          start_date\n          end_date\n          createdAt\n          updatedAt\n        }\n      }\n    }\n  }\n");let i=(0,r.U)("\n  query getHolidays($user: ID!) {\n    holidays(\n      filters: { user: { id: { eq: $user } } }\n      pagination: { limit: -1 }\n    ) {\n      data {\n        id\n        attributes {\n          start_date\n          end_date\n          createdAt\n          updatedAt\n        }\n      }\n    }\n  }\n"),a=(0,r.U)("\n  mutation bookHoliday($start_date: Date!, $end_date: Date!
1) {\n    createHoliday(data: { start_date: $start_date, end_date: $end_date }) {\n      data {\n        id\n        attributes {\n          start_date\n          end_date\n          createdAt\n          updatedAt\n        }\n      }\n    }\n  }\n"),l=(0,r.U)("\n  mutation editHoliday($id: ID!, $start_date: Date!, $end_date: Date!) {\n    updateHoliday(\n      id: $id\n      data: { start_date: $start_date, end_date: $end_date }\n    ) {\n      data {\n        id\n        attributes {\n          start_date\n          end_date\n          createdAt\n          updatedAt\n        }\n      }\n    }\n  }\n"),s=(0,r.U)("\n  mutation deleteHoliday($id: ID!) {\n    deleteHoliday(id: $id) {\n      data {\n        id\n      }\n    }\n  }\n");var d=n(93596),o=n(72320),u=n(38032),c=n(70730),p=n(18955),x=n(44517),h=n(4259);function f(){var e;let{user:t}=(0,h.A)(),n=(0,p.c)("HolidaysTemplate"),{data:r,loading:f,error:m}=(0,o.I)(i,{variables:{user:null==t?void 0:t.id},skip:!t}),b=(null==r||null==(e=r.holidays)?void 0:e.data)||[],[v,{loading:g}]=(0,u.n)(a),[j,{loading:y}]=(0,u.n)(l),[_,{loading:w}]=(0,u.n)(s),A=e=>(0,d.bX)(e,b);return{holidays:b,loading:f,error:m,isNextDeliveryOnHoliday:e=>A((0,d.tH)(e)),isDateBooked:A,createHoliday:(e,r)=>{let{start_date:a,end_date:l}=e;v({variables:{start_date:(0,c.mM)(a),end_date:(0,c.mM)(l)},onCompleted:()=>{null==r||r(),x.default.success(n("holidayBookedSuccessfully"))},onError:e=>{console.error(e),x.default.error(n("holidayBookError"))},refetchQueries:[{query:i,variables:{user:null==t?void 0:t.id}}]})},loadingCreate:g,editHoliday:(e,r)=>{let{id:a,attributes:{start_date:l,end_date:s}}=e;j({variables:{id:a,start_date:(0,c.mM)(l),end_date:(0,c.mM)(s)},onCompleted:()=>{null==r||r(),x.default.success(n("holidayUpdated"))},onError:e=>{console.error(e),x.default.error(n("holidayUpdateError"))},refetchQueries:[{query:i,variables:{user:null==t?void 0:t.id}}]})},loadingEdit:y,deleteHoliday:(e,r)=>{_({variables:{id:e},onCompleted:()=>{null==r||r(),x.default.success(n("holidayDeleted"))},onError:e=>{console.error(e),x.default.error(n("holidayDeleteError"))},refetchQueries:[{query:i,variables:{user:null==t?void 0:t.id}}]})},loadingDelete:w}}},75426:(e,t,n)=>{n.d(t,{D:()=>u});var r=n(95155),i=n(29518),a=n(39970),l=n(19131),s=n(34389);n(12115);var d=n(42682),o=n(18955);let u=e=>{let{order:t,distributionMethod:n}=e,{currency_code:u}=(0,d.P)(),c=(0,o.c)("Basket"),p=(0,o.c)("DeliveryMethodsTemplate");return(0,r.jsxs)(i.A,{sx:{borderTop:"1px solid #000",mt:2},children:[t.attributes.discount_total>0&&(0,r.jsxs)(a.Ay,{disableGutters:!0,dense:!0,children:[(0,r.jsx)(l.A,{children:c("discount")}),(0,r.jsx)(l.A,{sx:{textAlign:"right"},children:(0,s.v)(t.attributes.discount_total,u)})]}),t.attributes.delivery_charge>0&&(0,r.jsxs)(a.Ay,{disableGutters:!0,dense:!0,children:[(0,r.jsx)(l.A,{children:p(n.toLowerCase())}),(0,r.jsx)(l.A,{sx:{textAlign:"right"},children:(0,s.v)(t.attributes.delivery_charge,u)})]}),(0,r.jsxs)(a.Ay,{disableGutters:!0,dense:!0,children:[(0,r.jsx)(l.A,{children:c("total")}),(0,r.jsx)(l.A,{sx:{textAlign:"right"},children:(0,s.v)(t.attributes.total,u)})]})]})}},84053:(e,t,n)=>{n.d(t,{t:()=>U});var r=n(95155),i=n(96869),a=n(4615),l=n(37440),s=n(80317),d=n(84389),o=n(12115),u=n(38032),c=n(88587),p=n(4259),x=n(2124),h=n(50355),f=n(80357),m=n(97179),b=n(67053),v=n.n(b),g=n(54851),j=n(76293),y=n.n(j),_=n(50391),w=n(18955);function A(e){let{onCompleted:t}=e,n=(0,w.c)("AddressTemplate"),[i]=(0,o.useState)(y()()),[a,l]=(0,o.useState)(null),[d,u]=(0,o.useState)(""),[c,p]=(0,o.useState)([]),b=(0,o.useMemo)(()=>(0,g.A)(async e=>{let{input:t}=e;try{let e=await _.A.post("/address/autosuggest",{input:t,session:i});200===e.status&&p(e.data)}catch(e){console.error(e)}},400),[i]);(0,o.useEffect)(()=>{if(""===d)return void p(a?[a]:[]);try{b({input:d})}catch(e){console.error(e)}},[a,d,b]);let j=async e=>{p(e?[e,...c]:c),l(e);try{let n=await _.A.post("/address/autocomplete",{id:e.place_id,session:i});200===n.status&&t(n.data)}catch(e){console.error(e)}};return(0,r.jsx)(x.A,{fullWidth:!0,id:"google-map-demo",getOptionLabel:e=>"string"==typeof e?e:e.description,filterOptions:e=>e,options:c,autoComplete:!0,includeInputInList:!0,filterSelectedOptions:!0,value:a,noOptionsText:n("noLocations"),onChange:(e,t)=>
1j(t),onInputChange:(e,t)=>{u(t)},renderInput:e=>{let{InputProps:t,inputProps:i,...a}=e,{ref:l,...s}=t||{};return(0,r.jsx)(h.A,{...a,slotProps:{input:{ref:l,...s},htmlInput:i},label:n("findAddress"),helperText:n("helperText"),fullWidth:!0})},renderOption:(e,t)=>{let n=t.structured_formatting.main_text_matched_substrings||[],i=v()(t.structured_formatting.main_text,n.map(e=>[e.offset,e.offset+e.length]));return(0,r.jsx)(f.default,{component:"li",...e,children:(0,r.jsx)(m.default,{container:!0,alignItems:"center",children:(0,r.jsxs)(m.default,{sx:{wordWrap:"break-word"},children:[i.map((e,t)=>(0,r.jsx)(f.default,{component:"span",sx:{fontWeight:e.highlight?"bold":"regular"},children:e.text},t)),(0,r.jsx)(s.default,{variant:"body2",color:"text.secondary",children:t.structured_formatting.secondary_text})]})})})}})}var k=n(20860),I=n(97866),D=n(42682),S=n(64647),C=n(41521),$=n(38227),O=n(35068),B=n(50735),E=n(36792),q=n(25704);function T(e){var t,n,l,s,d;let{initialValues:o,onSubmit:u,onClose:c,error:p,farmCountry:x="GB"}=e,h=(0,w.c)("OnBoardingPage"),f=O.Ik().shape({street_1:O.Yj().required(h("validationStreet1Required")),postcode:(0,B.L)({requiredMessage:h("validationPostcodeRequired"),
1country:x,matchesMessage:h("validationPostcodeMatches",{example:null==(t=E.wI[x])?void 0:t.example})}).transform(q.h),town:O.Yj().required(h("validationTownRequired"))});return(0,r.jsx)(C.l1,{initialValues:{street_1:null!=(n=o.street_1)?n:"",street_2:null!=(l=o.street_2)?l:"",postcode:null!=(s=o.postcode)?s:"",town:null!=(d=o.town)?d:"",coordinates:o.coordinates},enableReinitialize:!0,validationSchema:f,onSubmit:u,children:()=>(0,r.jsx)(C.lV,{children:(0,r.jsxs)(m.default,{container:!0,spacing:2,children:[p&&(0,r.jsx)(m.default,{size:{xs:12},children:(0,r.jsx)(a.default,{variant:"outlined",severity:"error",children:p})}),(0,r.jsx)(m.default,{size:{xs:12,md:6},children:(0,r.jsx)(C.D0,{component:$.A,name:"street_1",label:h("address"),variant:"outlined",fullWidth:!0,required:!0})}),(0,r.jsx)(m.default,{size:{xs:12,md:6},children:(0,r.jsx)(C.D0,{component:$.A,name:"street_2",label:h("houseName"),variant:"outlined",fullWidth:!0})}),(0,r.jsx)(m.default,{size:{xs:12,md:6},children:(0,r.jsx)(C.D0,{component:$.A,name:"postcode",label:h("postcode"),variant:"outlined",fullWidth:!0,required:!0})}),(0,r.jsx)(m.default,{size:{xs:12,md:6},children:(0,r.jsx)(C.D0,{component:$.A,name:"town",label:h("town"),variant:"outlined",fullWidth:!0,required:!0})}),(0,r.jsx)(m.default,{size:{xs:12},children:(0,r.jsxs)(i.default,{direction:"row",spacing:3,children:[(0,r.jsx)(S.default,{type:"submit",variant:"contained",disableElevation:!0,size:"large",children:h("saveDeliveryAddress")}),!!c&&(0,r.jsx)(S.default,{variant:"outlined",size:"large",onClick:c,children:h("close")})]})})]})})})}var M=n(26302);let U=e=>{let{onComplete:t,onClose:n}=e,x=(0,w.c)("OnBoardingPage"),{user:h}=(0,p.A)(),{country:f}=(0,D.P)(),{deliveryMethod:m,availableDeliveryMethods:b}=(0,k.d)(),v=(0,M.sf)(),[g,j]=(0,o.useState)(),[y,_]=(0,o.useState)(!1),[S,C]=(0,o.useState)(void 0),[$,O]=(0,o.useState)(""),[B,E]=(0,o.useState)({street_1:"",street_2:"",postcode:"",town:"",coordinates:void 0}),[U]=(0,u.n)(c.Y8),N=async e=>{try{let n={...e,postcode:(0,q.h)(e.postcode)};(await b(n.postcode)).some(e=>e.distribution_method_id===(null==m?void 0:m.distribution_method_id))?h&&U({variables:{user:h.id,...e},onCompleted:e=>{v.capture("new_address_added"),null==t||t(e)},onError:e=>O(e.message)}):(E(e),C(e))}catch(e){O(e.message)}};return S?(0,r.jsxs)(i.default,{spacing:3,children:[(0,r.jsxs)(a.default,{severity:"warning",variant:"outlined",children:[x("changeDeliveryMethod"),(0,r.jsx)(l.default,{onClick:()=>C(!1),sx:{cursor:"pointer",ml:1},children:x("changeDeliveryAddress")})]}),(0,r.jsx)(I.oh,{postcode:S.postcode,onComplete:()=>C(!1)})]}):(0,r.jsxs)(i.default,{spacing:3,children:[(0,r.jsx)(A,{onCompleted:e=>{let t=function(e,t){var n={home:["street_number"],postal_code:["postal_code"],street:["street_address","route"],region:["administrative_area_level_1","administrative_area_level_2","administrative_area_level_3","administrative_area_level_4","administrative_area_level_5"],city:["locality","postal_town","sublocality","sublocality_level_1","sublocality_level_2","sublocality_level_3","sublocality_level_4"],country:["country"]},r={home:"",postal_code:"",street:"",region:"",city:"",country:""};return e.forEach(e=>{for(var t in n)-1!==n[t].indexOf(e.types[0])&&(r[t]=e.long_name)}),{...r,coordinates:[t.location.lng,t.location.lat]}}(e.address_components,e.geometry);j(t),E(e=>{var n,r;return{...e,street_1:t.home?"".concat(t.home," ").concat(t.street):t.street,postcode:null!=(n=t.postal_code)?n:"",town:null!=(r=t.city)?r:"",coordinates:t.coordinates}})}}),(0,r.jsxs)(s.default,{align:"center",children:[x("cantFindAddress"),(0,r.jsx)(l.default,{onClick:()=>_(!0),sx:{cursor:"pointer",ml:1},children:x("createManually")})]}),(g||y)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.default,{}),(0,r.jsx)(T,{initialValues:B,onSubmit:N,onClose:n,error:$,farmCountry:null!=f?f:"GB"})]})]})}},93596:(e,t,n)=>{n.d(t,{Bl:()=>v,J3:()=>p,L$:()=>x,_6:()=>f,bX:()=>c,dY:()=>h,fN:()=>g,hn:()=>u,tH:()=>m,vF:()=>b});var r=n(26467),i=n(6180),a=n(87848),l=n(8086),s=n(99228),d=n(14187),o=n(70730);function u(e,t){let n=(0,o.OG)(e.start_date),i=(0,o.OG)(e.end_date);return t.some(e=>{let t=(0,r.H)(e.attributes.start_date),a=(0,r.H)(e.attributes.end_date);return(0,o.RA)({rangeA:{start:n,end:i},rangeB:{start:t,end:a}})})}function c(e,t){let n=(0,o.OG)(e);return t.some(e=>{let t=(0,r.H)(e.attributes.start_date),i=(0,r.H)(e.attributes.end_date);return(0,o.xR)({date:n,range:{start:t,end:i}})})}function p(e,t){return(0,i.k)({start:(0,o.OG)(e.start_date),end:(0,o.OG)(e.end_date)}).filter(e=>(0,a.g)(e)===(0,o.px)((0,l.s)(e),t)).length}function x(e){let t=(0,s.a)(new Date,6);return e.filter(e=>{let n=(0,r.H)(e.attributes.start_date);return(0,d.d)(n,t)})}function h(e){let t=(0,o.OG)(new Date),n=(0,r.H)(e.attributes.start_date),i=(0,r.H)(e.attributes.end_date);return(0,o.xR)({date:t,range:{start:n,end:i}})}function f(e){let t=(0,o.OG)(new Date);return(0,r.H)(e.attributes.end_date)<t}function m(e){let t=(0,o.px)(e.next_fulfillment_week,e),n=(0,o.xS)(e.next_fulfillment_year,e.next_fulfillment_week,t);return(0,o.OG)(n)}function b(e){return e.reduce((e,t)=>
1(f(t)?e.expiredHolidays.push(t):e.scheduledHolidays.push(t),e),{scheduledHolidays:[],expiredHolidays:[]})}function v(e){return e.sort((e,t)=>{let n=(0,r.H)(e.attributes.start_date),i=(0,r.H)(t.attributes.start_date);return n.getTime()-i.getTime()})}function g(e,t){return(0,o.OG)(e)<m(t)}},97983:(e,t,n)=>{n.d(t,{Y:()=>s});var r=n(95155);n(12115);var i=n(37440),a=n(52619),l=n.n(a);let s=e=>{let{children:t,href:n,sx:a,...s}=e;return(0,r.jsx)(l(),{passHref:!0,href:n,children:(0,r.jsx)(i.default,{sx:{cursor:"pointer",...a},...s,component:"span",children: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.