@heycater/qualification-funnel 1.19.27 → 1.19.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1435,7 +1435,7 @@
1435
1435
  justify-content: center;
1436
1436
  background-size: cover;
1437
1437
  background-position: bottom center;
1438
- `;var Pq=new Map,Dq=new WeakMap,Nq=0;function Rq(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(Dq.has(n)||(Nq+=1,Dq.set(n,Nq.toString())),Dq.get(n)):"0":e[t]);var n}).toString()}function Aq(e,t,n,r){if(void 0===n&&(n={}),void 0===r&&(r=undefined),void 0===window.IntersectionObserver&&void 0!==r){var o=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:"number"==typeof n.threshold?n.threshold:0,time:0,boundingClientRect:o,intersectionRect:o,rootBounds:o}),function(){}}var i=function(e){var t=Rq(e),n=Pq.get(t);if(!n){var r,o=new Map,i=new IntersectionObserver(function(t){t.forEach(function(t){var n,i=t.isIntersecting&&r.some(function(e){return t.intersectionRatio>=e});e.trackVisibility&&void 0===t.isVisible&&(t.isVisible=i),null==(n=o.get(t.target))||n.forEach(function(e){e(i,t)})})},e);r=i.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:i,elements:o},Pq.set(t,n)}return n}(n),a=i.id,s=i.observer,l=i.elements,u=l.get(e)||[];return l.has(e)||l.set(e,u),u.push(t),s.observe(e),function(){u.splice(u.indexOf(t),1),0===u.length&&(l.delete(e),s.unobserve(e)),0===l.size&&(s.disconnect(),Pq.delete(a))}}const Fq=({children:e,height:t,isFloating:n,...r})=>C.jsxs(C.Fragment,{children:[C.jsx(zm,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:n?"fixed":"relative",...r,children:e}),n&&C.jsx("div",{style:{height:`${t}px`}})]});function Iq(){var e,t;const{inView:n,ref:r,entry:o}=function(e){var t=void 0===e?{}:e,n=t.threshold,r=t.delay,o=t.trackVisibility,i=t.rootMargin,a=t.root,s=t.triggerOnce,l=t.skip,u=t.initialInView,c=t.fallbackInView,d=g.useRef(),f=g.useState({inView:!!u}),p=f[0],h=f[1],m=g.useCallback(function(e){void 0!==d.current&&(d.current(),d.current=void 0),l||e&&(d.current=Aq(e,function(e,t){h({inView:e,entry:t}),t.isIntersecting&&s&&d.current&&(d.current(),d.current=void 0)},{root:a,rootMargin:i,threshold:n,trackVisibility:o,delay:r},c))},[Array.isArray(n)?n.toString():n,a,i,s,l,o,c,r]);g.useEffect(function(){d.current||!p.entry||s||l||h({inView:!!u})});var v=[m,p.inView,p.entry];return v.ref=v[0],v.inView=v[1],v.entry=v[2],v}({threshold:1}),i=(null==(e=null==o?void 0:o.boundingClientRect)?void 0:e.height)||0,a=!o||(null==(t=o.boundingClientRect)?void 0:t.y)>0;return{height:i,isFloating:!n&&a,ref:r}}const zq={de:"German",en:"English"};function $q(e){const{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,email:o,company:i,has_recurring_need:a}=e;return{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,billingEmail:o,billingName:i,name:i,hasRecurringNeed:a}}function Bq(){const{locale:e}=LE(),t=Mm();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(qF,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:zq[e]||zq.de},accountAttributes:$q(n),opportunityAttributes:zF(n)},{client:t});return r}catch(r){r instanceof Error&&sq.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function qq(){const e=Mm();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:o,deliveryAddressCountry:i,deliveryAddressPostalCode:a,deliveryAddressStreet:s,deliveryAddressStreetNumber:l,email:u,first_name:c,last_name:d,phone:f,catering_categories:p,event_date:h,has_recurring_need:m,is_multi_day:g,number_of_carnivore:v,lead_type:y,number_of_vegans:b,number_of_vegetarians:w,price_per_person:x,service_type:C,team_size:k,delivery_frequency:S,budget_range:E,leadSource:_,conversionUrl:L,entranceUrl:O,referrerUrl:j,landingPageSource:M}=t,T=b+w+v,{data:{createQfLead:P}}=await((e,{client:t})=>t.mutation(WF,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${o}, ${i}`,cateringCategories:p,eventDate:new Date(h).toDateString(),hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:v,numberOfVegans:b,numberOfVegetarians:w,numberOfPeople:T,totalBudget:T*x,leadType:y,serviceType:C,teamSize:k,deliveryFrequency:S,budgetRange:E,leadSource:_,conversionUrl:L,entranceUrl:O,referrerUrl:j,landingPageSource:M},{client:e});return P}catch(n){n&&sq.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}const Wq=e=>{const t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return t?decodeURIComponent(t[2]):void 0};function Vq(){const{state:e}=tj(),t="qualification"in e?e.qualification:null,n=Mm(),{currentUserAccount:r}=JO(),o=LE(),{funnelCheckout:i}=Bq(),{createQfLead:a}=qq(),s=e=>{var n,i,a,s;const l=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:c,city:d,country:f}=(null==(i=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:i.billingAddress)||{street:l,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const p=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel",h=t.answers,m=!!h.event_type,g=h.min_order_number||0,v=m?{number_of_carnivore:g,number_of_vegans:0,number_of_vegetarians:0}:{};return{...h,...v,...e,phone:e.phone||"",catererSlug:null==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:u||"",billingAddressPostalCode:c||"",billingAddressCity:d||"",billingCountry:f||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:l,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:p,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n,r;const o=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,l="regular_employee_catering"===o||"full_service_event"===o,{deliveryAddressCountry:u}=e,c=["United Kingdom","Great Britain","UK"].includes(u);if(!l&&!c){const{signInToken:t,customerAccount:n,opportunity:r}=await i(s(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}try{const n=(null==(r=null==t?void 0:t.leadSource)?void 0:r.includes("/events"))?"events-landingpage":"Qualification Funnel",o=(null==t?void 0:t.answers)||{},i=await a({...e,...o,leadSource:n,conversionUrl:window.location.href,entranceUrl:Wq("entrance_url"),referrerUrl:Wq("referrer_url"),landingPageSource:null==t?void 0:t.leadSource});if(!i)return console.error("[HeyCater Funnel] createQfLead returned undefined/null"),{success:!1,isUkLead:c};const{success:s}=i;return void 0===s&&console.error("[HeyCater Funnel] createQfLead response missing success field:",i),{success:s,isUkLead:c}}catch(d){return console.error("[HeyCater Funnel] createQfLead failed:",d),{success:!1,isUkLead:c}}},submitAsExistingCustomer:async e=>{const t=s(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=zF(e),{data:r}=await t.mutation($F,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const Uq="qualification-request-form",Hq={},Zq=/^\+?[1-9]\d{6,14}$/,Yq=({isLoggedIn:e})=>US.object().shape({first_name:US.string().required(),last_name:US.string().required(),company:US.string().required(),email:US.string().required().email(),phone:e?US.string():US.string().matches(Zq,"Invalid phone number").required(),deliveryAddressStreet:US.string().min(1).required(),deliveryAddressStreetNumber:US.string().min(1).required(),deliveryAddressPostalCode:US.string().min(1).required(),deliveryAddressCity:US.string().min(1).required(),deliveryAddressCountry:US.string().min(1).required(),comment:US.string()});function Kq({header:e=null}){var t,n,r;const[o,i]=g.useState(!1),[a,s]=g.useState(!1),{t:l}=Wd("qualification"),{submitAsNewCustomer:u,submitAsExistingCustomer:c}=Vq(),d=Lj({display:"all-answers"}),f=uj("xs"),{state:p}=tj(),{ref:h,isFloating:m,height:v}=Iq(),{validateAddress:y}=uq({cacheValidations:Hq}),b=f&&m,w="qualification"in p?p.qualification:null,{actions:x}=tj(),{currentUserAccount:k}=JO(),S=LE(),[E,_]=g.useState(!1),{deliveryAddressStreetAndNumber:L,deliveryAddressPostalCode:O,deliveryAddressCity:j,deliveryAddressCountry:M}=(null==k?void 0:k.owner)||{},[T,P]=g.useState(""),[D,N]=g.useState(""),R=k?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:L,postalCode:O,city:j,country:M}):"";g.useEffect(()=>{!async function(){if(!R)return;const{streetName:e,streetNumber:t}=await y(R);P(e),N(t)}()},[R]);const{funnelContextRef:A}=CM(),F=({isFormValid:e})=>{const t=C.jsxs(Wm,{id:"request-form__submit-btn",block:"true","data-logged-in":!!k,"data-valid":e,"data-leadsource":"qualification"in p?p.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&C.jsx(zm,{mr:2,style:{alignItems:"flex-start"},children:C.jsx(rl,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),l("request.form.submit")]});return f?C.jsx(Fq,{height:v,isFloating:b,children:C.jsx(eW,{py:2,px:b&&2,$floating:b,children:t})}):C.jsx(zm,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:t})},I={first_name:(null==k?void 0:k.firstName)||"",last_name:(null==k?void 0:k.lastName)||"",company:(null==(t=null==k?void 0:k.owner)?void 0:t.companyName)||"",deliveryAddressStreet:T||"",deliveryAddressStreetNumber:D||"",deliveryAddressPostalCode:O||"",deliveryAddressCity:j||"",deliveryAddressCountry:M||"",email:(null==k?void 0:k.email)||"",phone:(null==(r=null==(n=null==k?void 0:k.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)||""},z=!!k;return o?C.jsx(Lq,{isUkLead:a}):C.jsxs(xq,{children:[e,C.jsx(CB,{initialValues:I,validationSchema:Yq({isLoggedIn:z}),onSubmit:async e=>{var t;_(!0);const n=null==(t=null==w?void 0:w.answers)?void 0:t.service_type,r=A.current.service_type;console.log("[Optimeleon Debug] handleSubmit called",{serviceType:n,serviceTypeType:typeof n,serviceTypeLength:null==n?void 0:n.length,serviceTypeFromContext:r,contextServiceTypeType:typeof r,allAnswers:JSON.stringify(null==w?void 0:w.answers),funnelContext:JSON.stringify(A.current)});const o=n||r;console.log("[Optimeleon Debug] About to track funnel_form_submitted with:",o),vM("funnel_form_submitted",o);const a="regular_employee_catering"===n||"full_service_event"===n,{deliveryAddressCountry:l}=e,d=["United Kingdom","Great Britain","UK"].includes(l);if(a||d){const t=await u(e),{success:n}=t;return n?(s(d),i(!0),hM(A.current,{is_uk_lead:d}),mM(A.current),console.log("[Optimeleon Debug] Lead-only flow - tracking funnel_completed with:",o),vM("funnel_completed",o),void yM("submit_qf_request")):(console.error("[HeyCater Funnel] Lead submission failed. Result:",t),void _(!1))}let f="",p="";if(k)try{const t=await c(e);if(!t||!t.id)return console.error("[HeyCater Funnel] submitAsExistingCustomer returned invalid opportunity:",t),void _(!1);p=t.userId,f=`/account/requests/${t.id}`}catch(h){return h instanceof Error&&sq.notify(h),void _(!1)}else{const t=await u(e),{signInToken:n,opportunity:r}=t||{};if(!r||!r.id)return console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:",t),void _(!1);p=r.userId,f=n?`/${S.locale}/account/requests/${r.id}?one_time_sign_in_token=${n}`:`/${S.locale}/account/external/requests/${r.id}`}p&&(function(e){if("undefined"==typeof window)return;const{googleTagId:t}=RE();if(window.gtag&&t)try{window.gtag("config",t,{user_id:e})}catch(n){console.error("[gtag] Failed to identify user:",n)}}(p),function(e){"undefined"!=typeof window&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({userId:e}))}(p)),hM(A.current,{is_logged_in:!!k}),mM(A.current),console.log("[Optimeleon Debug] Regular flow - tracking funnel_completed with:",o),vM("funnel_completed",o),yM("submit_qf_request"),x.setRequest(e),((e="/")=>{window.location.href=`${RE().customerAppHost}${e}`})(f)},enableReinitialize:!0,children:e=>{var t,n;return C.jsxs(Xq,{id:Uq,name:Uq,children:[C.jsxs(Gq,{children:[C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,name:"first_name",label:l("request.form.firstName"),placeholder:l("request.form.firstName"),component:Sq})}),C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,name:"last_name",label:l("request.form.lastName"),placeholder:l("request.form.lastName"),component:Sq})})]}),C.jsx(Gq,{children:C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,name:"company",label:l("request.form.company"),placeholder:l("request.form.company"),component:Sq})})}),C.jsx(Gq,{children:C.jsx(Qq,{children:C.jsx(jB,{required:!0,name:"delivery_address",label:l("request.form.deliveryAddress"),placeholder:l("request.form.deliveryAddress"),helperText:l("request.form.helpText.address"),defaultValue:R,component:pq})})}),C.jsxs(Gq,{children:[!k&&C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,type:"email",name:"email",label:l("request.form.email"),placeholder:l("request.form.email"),helperText:l("request.form.helpText.email"),component:Sq})}),!(null==(n=null==(t=null==k?void 0:k.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&C.jsx(Qq,{$half:!0,children:C.jsx(Eq,{label:l("request.form.phone"),name:"phone",formik:e,helperText:l("request.form.helpText.phone")})})]}),C.jsx(Gq,{children:C.jsx(Qq,{children:C.jsx(jB,{name:"comment",label:l("request.form.comment"),placeholder:l("request.form.commentPlaceholder"),component:Sq,multiline:!0})})}),C.jsx(jB,{type:"hidden",name:"deliveryAddressStreet"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressStreetNumber"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressPostalCode"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressCity"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressCountry"}),C.jsxs(zm,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[C.jsx(Jm,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:l("selection.yourSelection")}),C.jsx(Jq,{children:d.map(e=>C.jsx(Ej,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),C.jsx(zm,{ref:h,children:C.jsx(F,{isFormValid:e.isValid})})]})}})]})}const Gq=_p.div`
1438
+ `;var Pq=new Map,Dq=new WeakMap,Nq=0;function Rq(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(Dq.has(n)||(Nq+=1,Dq.set(n,Nq.toString())),Dq.get(n)):"0":e[t]);var n}).toString()}function Aq(e,t,n,r){if(void 0===n&&(n={}),void 0===r&&(r=undefined),void 0===window.IntersectionObserver&&void 0!==r){var o=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:"number"==typeof n.threshold?n.threshold:0,time:0,boundingClientRect:o,intersectionRect:o,rootBounds:o}),function(){}}var i=function(e){var t=Rq(e),n=Pq.get(t);if(!n){var r,o=new Map,i=new IntersectionObserver(function(t){t.forEach(function(t){var n,i=t.isIntersecting&&r.some(function(e){return t.intersectionRatio>=e});e.trackVisibility&&void 0===t.isVisible&&(t.isVisible=i),null==(n=o.get(t.target))||n.forEach(function(e){e(i,t)})})},e);r=i.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:i,elements:o},Pq.set(t,n)}return n}(n),a=i.id,s=i.observer,l=i.elements,u=l.get(e)||[];return l.has(e)||l.set(e,u),u.push(t),s.observe(e),function(){u.splice(u.indexOf(t),1),0===u.length&&(l.delete(e),s.unobserve(e)),0===l.size&&(s.disconnect(),Pq.delete(a))}}const Fq=({children:e,height:t,isFloating:n,...r})=>C.jsxs(C.Fragment,{children:[C.jsx(zm,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:n?"fixed":"relative",...r,children:e}),n&&C.jsx("div",{style:{height:`${t}px`}})]});function Iq(){var e,t;const{inView:n,ref:r,entry:o}=function(e){var t=void 0===e?{}:e,n=t.threshold,r=t.delay,o=t.trackVisibility,i=t.rootMargin,a=t.root,s=t.triggerOnce,l=t.skip,u=t.initialInView,c=t.fallbackInView,d=g.useRef(),f=g.useState({inView:!!u}),p=f[0],h=f[1],m=g.useCallback(function(e){void 0!==d.current&&(d.current(),d.current=void 0),l||e&&(d.current=Aq(e,function(e,t){h({inView:e,entry:t}),t.isIntersecting&&s&&d.current&&(d.current(),d.current=void 0)},{root:a,rootMargin:i,threshold:n,trackVisibility:o,delay:r},c))},[Array.isArray(n)?n.toString():n,a,i,s,l,o,c,r]);g.useEffect(function(){d.current||!p.entry||s||l||h({inView:!!u})});var v=[m,p.inView,p.entry];return v.ref=v[0],v.inView=v[1],v.entry=v[2],v}({threshold:1}),i=(null==(e=null==o?void 0:o.boundingClientRect)?void 0:e.height)||0,a=!o||(null==(t=o.boundingClientRect)?void 0:t.y)>0;return{height:i,isFloating:!n&&a,ref:r}}const zq={de:"German",en:"English"};function $q(e){const{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,email:o,company:i,has_recurring_need:a}=e;return{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,billingEmail:o,billingName:i,name:i,hasRecurringNeed:a}}function Bq(){const{locale:e}=LE(),t=Mm();return{funnelCheckout:async n=>{var r;try{const o=await((e,{client:t})=>t.mutation(qF,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:zq[e]||zq.de},accountAttributes:$q(n),opportunityAttributes:zF(n)},{client:t});if(!(null==(r=null==o?void 0:o.data)?void 0:r.funnelCheckout)){const e=new Error("funnelCheckout returned no data");throw sq.notify(e,e=>{e.addMetadata("funnelCheckoutArgs",n),e.addMetadata("funnelCheckoutResult",o)}),e}return o.data.funnelCheckout}catch(o){throw o instanceof Error&&sq.notify(o,e=>{e.addMetadata("funnelCheckoutArgs",n)}),o}}}}function qq(){const e=Mm();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:o,deliveryAddressCountry:i,deliveryAddressPostalCode:a,deliveryAddressStreet:s,deliveryAddressStreetNumber:l,email:u,first_name:c,last_name:d,phone:f,catering_categories:p,event_date:h,has_recurring_need:m,is_multi_day:g,number_of_carnivore:v,lead_type:y,number_of_vegans:b,number_of_vegetarians:w,price_per_person:x,service_type:C,team_size:k,delivery_frequency:S,budget_range:E,leadSource:_,conversionUrl:L,entranceUrl:O,referrerUrl:j,landingPageSource:M}=t,T=b+w+v,{data:{createQfLead:P}}=await((e,{client:t})=>t.mutation(WF,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${o}, ${i}`,cateringCategories:p,eventDate:new Date(h).toDateString(),hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:v,numberOfVegans:b,numberOfVegetarians:w,numberOfPeople:T,totalBudget:T*x,leadType:y,serviceType:C,teamSize:k,deliveryFrequency:S,budgetRange:E,leadSource:_,conversionUrl:L,entranceUrl:O,referrerUrl:j,landingPageSource:M},{client:e});return P}catch(n){n&&sq.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}const Wq=e=>{const t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return t?decodeURIComponent(t[2]):void 0};function Vq(){const{state:e}=tj(),t="qualification"in e?e.qualification:null,n=Mm(),{currentUserAccount:r}=JO(),o=LE(),{funnelCheckout:i}=Bq(),{createQfLead:a}=qq(),s=e=>{var n,i,a,s;const l=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:c,city:d,country:f}=(null==(i=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:i.billingAddress)||{street:l,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const p=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel",h=t.answers,m=!!h.event_type,g=h.min_order_number||0,v=m?{number_of_carnivore:g,number_of_vegans:0,number_of_vegetarians:0}:{};return{...h,...v,...e,phone:e.phone||"",catererSlug:null==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:u||"",billingAddressPostalCode:c||"",billingAddressCity:d||"",billingCountry:f||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:l,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:p,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n,r;const o=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,l="regular_employee_catering"===o||"full_service_event"===o,{deliveryAddressCountry:u}=e,c=["United Kingdom","Great Britain","UK"].includes(u);if(l||c)try{const n=(null==(r=null==t?void 0:t.leadSource)?void 0:r.includes("/events"))?"events-landingpage":"Qualification Funnel",o=(null==t?void 0:t.answers)||{},i=await a({...e,...o,leadSource:n,conversionUrl:window.location.href,entranceUrl:Wq("entrance_url"),referrerUrl:Wq("referrer_url"),landingPageSource:null==t?void 0:t.leadSource});if(!i)return console.error("[HeyCater Funnel] createQfLead returned undefined/null"),{success:!1,isUkLead:c};const{success:s}=i;return void 0===s&&console.error("[HeyCater Funnel] createQfLead response missing success field:",i),{success:s,isUkLead:c}}catch(d){return console.error("[HeyCater Funnel] createQfLead failed:",d),{success:!1,isUkLead:c}}else try{const t=await i(s(e));return{signInToken:t.signInToken,customerAccount:t.customerAccount,opportunity:t.opportunity,isUkLead:!1}}catch(d){throw console.error("[HeyCater Funnel] funnelCheckout failed:",d),d}},submitAsExistingCustomer:async e=>{const t=s(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=zF(e),{data:r}=await t.mutation($F,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const Uq="qualification-request-form",Hq={},Zq=/^\+?[1-9]\d{6,14}$/,Yq=({isLoggedIn:e})=>US.object().shape({first_name:US.string().required(),last_name:US.string().required(),company:US.string().required(),email:US.string().required().email(),phone:e?US.string():US.string().matches(Zq,"Invalid phone number").required(),deliveryAddressStreet:US.string().min(1).required(),deliveryAddressStreetNumber:US.string().min(1).required(),deliveryAddressPostalCode:US.string().min(1).required(),deliveryAddressCity:US.string().min(1).required(),deliveryAddressCountry:US.string().min(1).required(),comment:US.string()});function Kq({header:e=null}){var t,n,r;const[o,i]=g.useState(!1),[a,s]=g.useState(!1),{t:l}=Wd("qualification"),{submitAsNewCustomer:u,submitAsExistingCustomer:c}=Vq(),d=Lj({display:"all-answers"}),f=uj("xs"),{state:p}=tj(),{ref:h,isFloating:m,height:v}=Iq(),{validateAddress:y}=uq({cacheValidations:Hq}),b=f&&m,w="qualification"in p?p.qualification:null,{actions:x}=tj(),{currentUserAccount:k}=JO(),S=LE(),[E,_]=g.useState(!1),{deliveryAddressStreetAndNumber:L,deliveryAddressPostalCode:O,deliveryAddressCity:j,deliveryAddressCountry:M}=(null==k?void 0:k.owner)||{},[T,P]=g.useState(""),[D,N]=g.useState(""),R=k?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:L,postalCode:O,city:j,country:M}):"";g.useEffect(()=>{!async function(){if(!R)return;const{streetName:e,streetNumber:t}=await y(R);P(e),N(t)}()},[R]);const{funnelContextRef:A}=CM(),F=({isFormValid:e})=>{const t=C.jsxs(Wm,{id:"request-form__submit-btn",block:"true","data-logged-in":!!k,"data-valid":e,"data-leadsource":"qualification"in p?p.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&C.jsx(zm,{mr:2,style:{alignItems:"flex-start"},children:C.jsx(rl,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),l("request.form.submit")]});return f?C.jsx(Fq,{height:v,isFloating:b,children:C.jsx(eW,{py:2,px:b&&2,$floating:b,children:t})}):C.jsx(zm,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:t})},I={first_name:(null==k?void 0:k.firstName)||"",last_name:(null==k?void 0:k.lastName)||"",company:(null==(t=null==k?void 0:k.owner)?void 0:t.companyName)||"",deliveryAddressStreet:T||"",deliveryAddressStreetNumber:D||"",deliveryAddressPostalCode:O||"",deliveryAddressCity:j||"",deliveryAddressCountry:M||"",email:(null==k?void 0:k.email)||"",phone:(null==(r=null==(n=null==k?void 0:k.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)||""},z=!!k;return o?C.jsx(Lq,{isUkLead:a}):C.jsxs(xq,{children:[e,C.jsx(CB,{initialValues:I,validationSchema:Yq({isLoggedIn:z}),onSubmit:async e=>{var t;_(!0);const n=null==(t=null==w?void 0:w.answers)?void 0:t.service_type,r=A.current.service_type;console.log("[Optimeleon Debug] handleSubmit called",{serviceType:n,serviceTypeType:typeof n,serviceTypeLength:null==n?void 0:n.length,serviceTypeFromContext:r,contextServiceTypeType:typeof r,allAnswers:JSON.stringify(null==w?void 0:w.answers),funnelContext:JSON.stringify(A.current)});const o=n||r;console.log("[Optimeleon Debug] About to track funnel_form_submitted with:",o),vM("funnel_form_submitted",o);const a="regular_employee_catering"===n||"full_service_event"===n,{deliveryAddressCountry:l}=e,d=["United Kingdom","Great Britain","UK"].includes(l);if(a||d){const t=await u(e),{success:n}=t;return n?(s(d),i(!0),hM(A.current,{is_uk_lead:d}),mM(A.current),console.log("[Optimeleon Debug] Lead-only flow - tracking funnel_completed with:",o),vM("funnel_completed",o),void yM("submit_qf_request")):(console.error("[HeyCater Funnel] Lead submission failed. Result:",t),void _(!1))}let f="",p="";if(k)try{const t=await c(e);if(!t||!t.id)return console.error("[HeyCater Funnel] submitAsExistingCustomer returned invalid opportunity:",t),void _(!1);p=t.userId,f=`/account/requests/${t.id}`}catch(h){return h instanceof Error&&sq.notify(h),void _(!1)}else{const t=await u(e),{signInToken:n,opportunity:r}=t||{};if(!r||!r.id)return console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:",t),void _(!1);p=r.userId,f=n?`/${S.locale}/account/requests/${r.id}?one_time_sign_in_token=${n}`:`/${S.locale}/account/external/requests/${r.id}`}p&&(function(e){if("undefined"==typeof window)return;const{googleTagId:t}=RE();if(window.gtag&&t)try{window.gtag("config",t,{user_id:e})}catch(n){console.error("[gtag] Failed to identify user:",n)}}(p),function(e){"undefined"!=typeof window&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({userId:e}))}(p)),hM(A.current,{is_logged_in:!!k}),mM(A.current),console.log("[Optimeleon Debug] Regular flow - tracking funnel_completed with:",o),vM("funnel_completed",o),yM("submit_qf_request"),x.setRequest(e),((e="/")=>{window.location.href=`${RE().customerAppHost}${e}`})(f)},enableReinitialize:!0,children:e=>{var t,n;return C.jsxs(Xq,{id:Uq,name:Uq,children:[C.jsxs(Gq,{children:[C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,name:"first_name",label:l("request.form.firstName"),placeholder:l("request.form.firstName"),component:Sq})}),C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,name:"last_name",label:l("request.form.lastName"),placeholder:l("request.form.lastName"),component:Sq})})]}),C.jsx(Gq,{children:C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,name:"company",label:l("request.form.company"),placeholder:l("request.form.company"),component:Sq})})}),C.jsx(Gq,{children:C.jsx(Qq,{children:C.jsx(jB,{required:!0,name:"delivery_address",label:l("request.form.deliveryAddress"),placeholder:l("request.form.deliveryAddress"),helperText:l("request.form.helpText.address"),defaultValue:R,component:pq})})}),C.jsxs(Gq,{children:[!k&&C.jsx(Qq,{$half:!0,children:C.jsx(jB,{required:!0,type:"email",name:"email",label:l("request.form.email"),placeholder:l("request.form.email"),helperText:l("request.form.helpText.email"),component:Sq})}),!(null==(n=null==(t=null==k?void 0:k.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&C.jsx(Qq,{$half:!0,children:C.jsx(Eq,{label:l("request.form.phone"),name:"phone",formik:e,helperText:l("request.form.helpText.phone")})})]}),C.jsx(Gq,{children:C.jsx(Qq,{children:C.jsx(jB,{name:"comment",label:l("request.form.comment"),placeholder:l("request.form.commentPlaceholder"),component:Sq,multiline:!0})})}),C.jsx(jB,{type:"hidden",name:"deliveryAddressStreet"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressStreetNumber"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressPostalCode"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressCity"}),C.jsx(jB,{type:"hidden",name:"deliveryAddressCountry"}),C.jsxs(zm,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[C.jsx(Jm,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:l("selection.yourSelection")}),C.jsx(Jq,{children:d.map(e=>C.jsx(Ej,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),C.jsx(zm,{ref:h,children:C.jsx(F,{isFormValid:e.isValid})})]})}})]})}const Gq=_p.div`
1439
1439
  display: flex;
1440
1440
  flex-wrap: wrap;
1441
1441
  margin: 0 -${({theme:e})=>e.spacing(1)}px;
@@ -2616,7 +2616,7 @@
2616
2616
  opacity: 0.9;
2617
2617
  transform: translateY(-1px);
2618
2618
  }
2619
- `,$H=({ratings:e,onCancel:t,funnelContextRef:n,updateContext:r})=>{var o;const{i18n:i}=Wd(),a=null==(o=i.language)?void 0:o.startsWith("de"),s=LE(),{state:l,actions:u,answerOf:c}=tj(),[d,f]=g.useState(0),[p,h]=g.useState("questions"),[m,v]=g.useState(20),[y,b]=g.useState(!1),[w,x]=g.useState(null),[k,S]=g.useState(null),E=g.useRef(!1),{submitAsNewCustomer:_}=Vq(),L=lU[d],O=t||(()=>window.history.back());g.useEffect(()=>{if("redesign_people_count"===L){const e=c("min_order_number"),t=c("price_per_person");void 0===e&&u.answerQuestion("min_order_number",100),void 0===t&&u.answerQuestion("price_per_person",m)}},[L,u,c,m]),g.useEffect(()=>{!E.current&&n.current.session_id&&(E.current=!0,gM(n.current,L))},[n.current.session_id,L]);const j=g.useCallback((e,t)=>{let r=t;t instanceof Date&&(r=DL(t,"yyyy-MM-dd")),pM(n.current,{step_id:L,step_index:d,question_id:e,answer_value:r,is_last_question:!0})},[n,d,L]),M=g.useCallback(()=>{const e=d+1;e>=lU.length?h("loading"):f(e)},[d]),T=g.useCallback(()=>{d>0&&f(d-1)},[d]),P=g.useCallback(e=>{const t=lU.indexOf(e);t>=0&&("contact"===p&&h("questions"),f(t))},[p]),D=g.useCallback(e=>{u.answerQuestion("city",e),j("city",e),r({city:e}),M()},[u,j,r,M]),N=g.useCallback(e=>{const t=function(e){return lO[e]}(e);u.answerQuestion("event_type",e),u.answerQuestion("service_type",t.service_type),u.answerQuestion("catering_categories",[t.catering_category]),j("event_type",e),r({service_type:t.service_type,total_steps:cU()}),M()},[u,j,r,M]),R=g.useCallback(e=>{e&&(u.answerQuestion("event_date",e),j("event_date",e))},[u,j]),A=g.useCallback(e=>{u.answerQuestion("is_multi_day",e),j("is_multi_day",e)},[u,j]),F=g.useCallback(e=>{u.answerQuestion("min_order_number",e),j("min_order_number",e)},[u,j]),I=g.useCallback(e=>{v(e),u.answerQuestion("price_per_person",e),j("price_per_person",e)},[u,j]),z=g.useCallback(()=>{h("contact")},[]),$=g.useCallback(async e=>{b(!0);try{const t={first_name:e.vorname,last_name:e.nachname,company:e.firma,email:e.email,phone:e.telefon,deliveryAddressStreet:e.deliveryAddressStreet,deliveryAddressStreetNumber:e.deliveryAddressStreetNumber,deliveryAddressPostalCode:e.deliveryAddressPostalCode,deliveryAddressCity:e.deliveryAddressCity,deliveryAddressCountry:e.deliveryAddressCountry||"Germany",comment:e.kommentar},r=await _(t),{signInToken:o,opportunity:i}=r||{};if(null==i?void 0:i.id){const e=o?`/${s.locale}/account/requests/${i.id}?one_time_sign_in_token=${o}`:`/${s.locale}/account/external/requests/${i.id}`;S(e)}mM(n.current),x(e),h("done")}catch(t){console.error("Failed to submit request:",t),b(!1)}},[_,n,s.locale]),B=g.useCallback(()=>{h("questions"),f(lU.length-1)},[]),q=g.useCallback(()=>{switch(L){case"redesign_city":return!!c("city");case"redesign_event_type":return!!c("event_type");case"redesign_date":return!!c("event_date");case"redesign_people_count":const e=c("min_order_number");return"number"==typeof e&&e>0;default:return!1}},[L,c]);if("loading"===p)return C.jsx(qH,{children:C.jsx(WH,{$fullWidth:!0,children:C.jsx(FU,{onComplete:z})})});if("contact"===p){const e=a?"Fast geschafft – nur noch deine Kontaktdaten":"Almost done – just your contact details",t=a?"Danach meldet sich dein Cateringexperte und schickt dir passende Angebote.":"Your catering expert will then get in touch and send you matching offers.";return C.jsxs(qH,{children:[C.jsx(fU,{currentStepId:sU,onStepClick:P}),C.jsxs(WH,{children:[C.jsxs(VH,{children:[C.jsx(UH,{children:C.jsx(xD,{height:20})}),C.jsx(HH,{children:C.jsx(ZH,{children:a?"Schritt 5 von 5":"Step 5 of 5"})}),C.jsx(KH,{children:C.jsx(GH,{$progress:100})})]}),C.jsxs(QH,{children:[C.jsx(JH,{onClick:O,children:a?"Abbrechen":"Cancel"}),C.jsx(XH,{children:a?"Schritt 5 von 5":"Step 5 of 5"})]}),C.jsxs(fZ,{children:[C.jsx(tZ,{children:e}),C.jsx(nZ,{children:t}),C.jsx(JU,{onSubmit:$,onBack:B,isSubmitting:y})]})]})]})}if("done"===p){const e=(null==w?void 0:w.vorname)||"",t=(null==w?void 0:w.email)||"",n=a?[{n:"1",title:"Wir prüfen deine Anfrage",desc:"Unser Team schaut sich deine Anfrage an."},{n:"2",title:"Du erhältst Angebote",desc:"Innerhalb weniger Stunden bekommst du bis zu 3 passende Angebote."},{n:"3",title:"Buche deinen Favoriten",desc:"Vergleiche die Angebote und buche, wenn du bereit bist."}]:[{n:"1",title:"We review your request",desc:"Our team will look at your request."},{n:"2",title:"You receive offers",desc:"Within a few hours you'll receive up to 3 matching offers."},{n:"3",title:"Book your favorite",desc:"Compare the offers and book when you're ready."}];return C.jsx(qH,{children:C.jsx(WH,{$fullWidth:!0,children:C.jsxs(pZ,{children:[C.jsx(hZ,{children:C.jsx(xD,{height:24})}),C.jsxs(mZ,{children:[C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M20 6L9 17l-5-5"})}),a?"Anfrage gesendet":"Request sent"]}),C.jsx(gZ,{children:a?`Danke, ${e}!`:`Thank you, ${e}!`}),C.jsx(vZ,{children:a?"Wir haben deine Anfrage erhalten und stellen jetzt passende Angebote für dich zusammen.":"We have received your request and are now putting together matching offers for you."}),C.jsxs(yZ,{children:[C.jsx(bZ,{children:a?"So geht es weiter":"What happens next"}),C.jsx(wZ,{children:n.map(e=>C.jsxs(xZ,{children:[C.jsx(CZ,{children:e.n}),C.jsxs(kZ,{children:[C.jsx(SZ,{children:e.title}),C.jsx(EZ,{children:e.desc})]})]},e.n))})]}),C.jsx(_Z,{children:a?C.jsxs(C.Fragment,{children:["Eine Bestätigung ist unterwegs an ",C.jsx("strong",{children:t}),"."]}):C.jsxs(C.Fragment,{children:["A confirmation is on its way to ",C.jsx("strong",{children:t}),"."]})}),k&&C.jsx(LZ,{onClick:()=>window.location.href=k,children:a?"Zu meiner Anfrage":"View my request"})]})})})}const W=uU[L],V=a?W.titleDe:W.titleEn,U=a?W.subtitleDe:W.subtitleEn,H=cU(),Z=(()=>{const e=[],t=c("city"),n=c("event_type"),r=c("event_date");if(t&&e.push(eV[t]||t),n&&d>=2){const t=a?tV:nV;e.push(t[n]||n)}return d>=3&&r&&e.push(DL(r,"dd.MM.yy")),e})(),Y=d>0,K=d>=1&&Z.length>0;return C.jsxs(qH,{children:[C.jsx(fU,{currentStepId:L,onStepClick:P}),C.jsxs(WH,{children:[C.jsxs(VH,{children:[C.jsx(UH,{children:C.jsx(xD,{height:20})}),C.jsxs(HH,{children:[C.jsx(ZH,{children:a?`Schritt ${d+1} von ${H}`:`Step ${d+1} of ${H}`}),C.jsx(YH,{onClick:O,children:a?"Abbrechen":"Cancel"})]}),C.jsx(KH,{children:C.jsx(GH,{$progress:(d+1)/H*100})})]}),C.jsxs(QH,{children:[C.jsx(JH,{onClick:O,children:a?"Abbrechen":"Cancel"}),C.jsx(XH,{children:a?`Schritt ${d+1} von ${H}`:`Step ${d+1} of ${H}`})]}),C.jsxs(eZ,{children:[C.jsx(tZ,{children:V}),U&&C.jsx(nZ,{children:U}),C.jsx(rZ,{children:(()=>{switch(L){case"redesign_city":return C.jsx(aV,{selected:c("city"),onSelect:D});case"redesign_event_type":return C.jsx(gV,{selected:c("event_type"),onSelect:N,variant:"primary"});case"redesign_date":return C.jsx(EV,{value:c("event_date"),onChange:R,isMultiDay:!!c("is_multi_day"),onMultiDayChange:A});case"redesign_people_count":return C.jsx(qV,{peopleCount:c("min_order_number")||100,budgetPerPerson:m,onPeopleCountChange:F,onBudgetPerPersonChange:I});default:return null}})()})]}),C.jsxs(oZ,{children:[K&&C.jsxs(iZ,{children:[C.jsx(aZ,{children:a?"Deine Auswahl:":"Your selection:"}),Z.map((e,t)=>C.jsx(lZ,{children:e},t))]}),C.jsxs(sZ,{children:[C.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M20 6L9 17l-5-5"})}),a?"Deine Anfrage ist kostenlos & unverbindlich":"Your request is free & non-binding"]}),C.jsxs(uZ,{children:[Y&&C.jsx(cZ,{type:"button",onClick:T,children:a?"Zurück":"Back"}),C.jsx(dZ,{type:"button",onClick:M,disabled:!q(),children:a?"Weiter":"Continue"})]})]})]})]})},BH=Op`
2619
+ `,$H=({ratings:e,onCancel:t,funnelContextRef:n,updateContext:r})=>{var o;const{i18n:i}=Wd(),a=null==(o=i.language)?void 0:o.startsWith("de"),s=LE(),{state:l,actions:u,answerOf:c}=tj(),[d,f]=g.useState(0),[p,h]=g.useState("questions"),[m,v]=g.useState(20),[y,b]=g.useState(!1),[w,x]=g.useState(null),[k,S]=g.useState(null),E=g.useRef(!1),{submitAsNewCustomer:_}=Vq(),L=lU[d],O=t||(()=>window.history.back());g.useEffect(()=>{if("redesign_people_count"===L){const e=c("min_order_number"),t=c("price_per_person");void 0===e&&u.answerQuestion("min_order_number",100),void 0===t&&u.answerQuestion("price_per_person",m)}},[L,u,c,m]),g.useEffect(()=>{!E.current&&n.current.session_id&&(E.current=!0,gM(n.current,L))},[n.current.session_id,L]);const j=g.useCallback((e,t)=>{let r=t;t instanceof Date&&(r=DL(t,"yyyy-MM-dd")),pM(n.current,{step_id:L,step_index:d,question_id:e,answer_value:r,is_last_question:!0})},[n,d,L]),M=g.useCallback(()=>{const e=d+1;e>=lU.length?h("loading"):f(e)},[d]),T=g.useCallback(()=>{d>0&&f(d-1)},[d]),P=g.useCallback(e=>{const t=lU.indexOf(e);t>=0&&("contact"===p&&h("questions"),f(t))},[p]),D=g.useCallback(e=>{u.answerQuestion("city",e),j("city",e),r({city:e}),M()},[u,j,r,M]),N=g.useCallback(e=>{const t=function(e){return lO[e]}(e);u.answerQuestion("event_type",e),u.answerQuestion("service_type",t.service_type),u.answerQuestion("catering_categories",[t.catering_category]),j("event_type",e),r({service_type:t.service_type,total_steps:cU()}),M()},[u,j,r,M]),R=g.useCallback(e=>{e&&(u.answerQuestion("event_date",e),j("event_date",e))},[u,j]),A=g.useCallback(e=>{u.answerQuestion("is_multi_day",e),j("is_multi_day",e)},[u,j]),F=g.useCallback(e=>{u.answerQuestion("min_order_number",e),j("min_order_number",e)},[u,j]),I=g.useCallback(e=>{v(e),u.answerQuestion("price_per_person",e),j("price_per_person",e)},[u,j]),z=g.useCallback(()=>{h("contact")},[]),$=g.useCallback(async e=>{b(!0);try{const t={first_name:e.vorname,last_name:e.nachname,company:e.firma,email:e.email,phone:e.telefon,deliveryAddressStreet:e.deliveryAddressStreet,deliveryAddressStreetNumber:e.deliveryAddressStreetNumber,deliveryAddressPostalCode:e.deliveryAddressPostalCode,deliveryAddressCity:e.deliveryAddressCity,deliveryAddressCountry:e.deliveryAddressCountry||"Germany",comment:e.kommentar},r=await _(t),{signInToken:o,opportunity:i}=r||{};if(!i||!i.id)return console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:",r),void b(!1);const a=o?`/${s.locale}/account/requests/${i.id}?one_time_sign_in_token=${o}`:`/${s.locale}/account/external/requests/${i.id}`;S(a),mM(n.current),x(e),h("done")}catch(t){console.error("Failed to submit request:",t),b(!1)}},[_,n,s.locale]),B=g.useCallback(()=>{h("questions"),f(lU.length-1)},[]),q=g.useCallback(()=>{switch(L){case"redesign_city":return!!c("city");case"redesign_event_type":return!!c("event_type");case"redesign_date":return!!c("event_date");case"redesign_people_count":const e=c("min_order_number");return"number"==typeof e&&e>0;default:return!1}},[L,c]);if("loading"===p)return C.jsx(qH,{children:C.jsx(WH,{$fullWidth:!0,children:C.jsx(FU,{onComplete:z})})});if("contact"===p){const e=a?"Fast geschafft – nur noch deine Kontaktdaten":"Almost done – just your contact details",t=a?"Danach meldet sich dein Cateringexperte und schickt dir passende Angebote.":"Your catering expert will then get in touch and send you matching offers.";return C.jsxs(qH,{children:[C.jsx(fU,{currentStepId:sU,onStepClick:P}),C.jsxs(WH,{children:[C.jsxs(VH,{children:[C.jsx(UH,{children:C.jsx(xD,{height:20})}),C.jsx(HH,{children:C.jsx(ZH,{children:a?"Schritt 5 von 5":"Step 5 of 5"})}),C.jsx(KH,{children:C.jsx(GH,{$progress:100})})]}),C.jsxs(QH,{children:[C.jsx(JH,{onClick:O,children:a?"Abbrechen":"Cancel"}),C.jsx(XH,{children:a?"Schritt 5 von 5":"Step 5 of 5"})]}),C.jsxs(fZ,{children:[C.jsx(tZ,{children:e}),C.jsx(nZ,{children:t}),C.jsx(JU,{onSubmit:$,onBack:B,isSubmitting:y})]})]})]})}if("done"===p){const e=(null==w?void 0:w.vorname)||"",t=(null==w?void 0:w.email)||"",n=a?[{n:"1",title:"Wir prüfen deine Anfrage",desc:"Unser Team schaut sich deine Anfrage an."},{n:"2",title:"Du erhältst Angebote",desc:"Innerhalb weniger Stunden bekommst du bis zu 3 passende Angebote."},{n:"3",title:"Buche deinen Favoriten",desc:"Vergleiche die Angebote und buche, wenn du bereit bist."}]:[{n:"1",title:"We review your request",desc:"Our team will look at your request."},{n:"2",title:"You receive offers",desc:"Within a few hours you'll receive up to 3 matching offers."},{n:"3",title:"Book your favorite",desc:"Compare the offers and book when you're ready."}];return C.jsx(qH,{children:C.jsx(WH,{$fullWidth:!0,children:C.jsxs(pZ,{children:[C.jsx(hZ,{children:C.jsx(xD,{height:24})}),C.jsxs(mZ,{children:[C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M20 6L9 17l-5-5"})}),a?"Anfrage gesendet":"Request sent"]}),C.jsx(gZ,{children:a?`Danke, ${e}!`:`Thank you, ${e}!`}),C.jsx(vZ,{children:a?"Wir haben deine Anfrage erhalten und stellen jetzt passende Angebote für dich zusammen.":"We have received your request and are now putting together matching offers for you."}),C.jsxs(yZ,{children:[C.jsx(bZ,{children:a?"So geht es weiter":"What happens next"}),C.jsx(wZ,{children:n.map(e=>C.jsxs(xZ,{children:[C.jsx(CZ,{children:e.n}),C.jsxs(kZ,{children:[C.jsx(SZ,{children:e.title}),C.jsx(EZ,{children:e.desc})]})]},e.n))})]}),C.jsx(_Z,{children:a?C.jsxs(C.Fragment,{children:["Eine Bestätigung ist unterwegs an ",C.jsx("strong",{children:t}),"."]}):C.jsxs(C.Fragment,{children:["A confirmation is on its way to ",C.jsx("strong",{children:t}),"."]})}),k&&C.jsx(LZ,{onClick:()=>window.location.href=k,children:a?"Zu meiner Anfrage":"View my request"})]})})})}const W=uU[L],V=a?W.titleDe:W.titleEn,U=a?W.subtitleDe:W.subtitleEn,H=cU(),Z=(()=>{const e=[],t=c("city"),n=c("event_type"),r=c("event_date");if(t&&e.push(eV[t]||t),n&&d>=2){const t=a?tV:nV;e.push(t[n]||n)}return d>=3&&r&&e.push(DL(r,"dd.MM.yy")),e})(),Y=d>0,K=d>=1&&Z.length>0;return C.jsxs(qH,{children:[C.jsx(fU,{currentStepId:L,onStepClick:P}),C.jsxs(WH,{children:[C.jsxs(VH,{children:[C.jsx(UH,{children:C.jsx(xD,{height:20})}),C.jsxs(HH,{children:[C.jsx(ZH,{children:a?`Schritt ${d+1} von ${H}`:`Step ${d+1} of ${H}`}),C.jsx(YH,{onClick:O,children:a?"Abbrechen":"Cancel"})]}),C.jsx(KH,{children:C.jsx(GH,{$progress:(d+1)/H*100})})]}),C.jsxs(QH,{children:[C.jsx(JH,{onClick:O,children:a?"Abbrechen":"Cancel"}),C.jsx(XH,{children:a?`Schritt ${d+1} von ${H}`:`Step ${d+1} of ${H}`})]}),C.jsxs(eZ,{children:[C.jsx(tZ,{children:V}),U&&C.jsx(nZ,{children:U}),C.jsx(rZ,{children:(()=>{switch(L){case"redesign_city":return C.jsx(aV,{selected:c("city"),onSelect:D});case"redesign_event_type":return C.jsx(gV,{selected:c("event_type"),onSelect:N,variant:"primary"});case"redesign_date":return C.jsx(EV,{value:c("event_date"),onChange:R,isMultiDay:!!c("is_multi_day"),onMultiDayChange:A});case"redesign_people_count":return C.jsx(qV,{peopleCount:c("min_order_number")||100,budgetPerPerson:m,onPeopleCountChange:F,onBudgetPerPersonChange:I});default:return null}})()})]}),C.jsxs(oZ,{children:[K&&C.jsxs(iZ,{children:[C.jsx(aZ,{children:a?"Deine Auswahl:":"Your selection:"}),Z.map((e,t)=>C.jsx(lZ,{children:e},t))]}),C.jsxs(sZ,{children:[C.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M20 6L9 17l-5-5"})}),a?"Deine Anfrage ist kostenlos & unverbindlich":"Your request is free & non-binding"]}),C.jsxs(uZ,{children:[Y&&C.jsx(cZ,{type:"button",onClick:T,children:a?"Zurück":"Back"}),C.jsx(dZ,{type:"button",onClick:M,disabled:!q(),children:a?"Weiter":"Continue"})]})]})]})]})},BH=Op`
2620
2620
  from { opacity: 0; transform: translateY(8px); }
2621
2621
  to { opacity: 1; transform: none; }
2622
2622
  `,qH=_p.div`