diff --git a/get/mia.html b/get/mia.html index ec8ff1ab8382fcecc175e89f6e63a60b1599d5ad..bf8123131404f005b32f999989608ceafa36aa9e 100644 --- a/get/mia.html +++ b/get/mia.html @@ -23,6 +23,7 @@ footer{text-align:center;color:#6f6656;font-size:12px;margin-top:6px}footer b{co
Install it
  1. Open this page in Safari.
  2. Tap the gold Open button below. Your app opens and signs you in.
  3. In the app, tap Share (the square with an arrow), then Add to Home Screen, then Add.
  4. Open it from your Home Screen.

Don't add this page to your Home Screen, add the app.

  1. Open this page in Chrome.
  2. Tap the gold Open button below. Your app opens and signs you in.
  3. In the app, tap Install app when it pops up, or tap ⋮ then Install app / Add to Home screen.
  4. Open it from your Home screen.

If Chrome says “This app cannot be installed”, you're still on this page. Tap the gold Open button first.

Open Cover Charge for Staff
+
New icon (October 2026)

The apps now have a new, bolder icon and the short name Anchorage. If you added the app before, your old icon stays as it was: press and hold the old icon, remove it from your Home screen, then open this page again (from your own link) and add the app back. It signs you in again from your link.

- + + @@ -42,12 +45,12 @@
The Anchorage
- + -

Opening The Anchorage · Managers…

+

Opening Anchorage Manager…

diff --git a/staff-app/_expo/static/js/web/[did]-4c838cde200773b5606b9763aaf7bfd3.js b/staff-app/_expo/static/js/web/[did]-4c838cde200773b5606b9763aaf7bfd3.js new file mode 100644 index 0000000000000000000000000000000000000000..e658268bd9e4171cc553bf26d7add0f89c99cdcd --- /dev/null +++ b/staff-app/_expo/static/js/web/[did]-4c838cde200773b5606b9763aaf7bfd3.js @@ -0,0 +1 @@ +__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}});var t=_r(_d[0]),n=_r(_d[1]),l=e(_r(_d[2])),s=e(_r(_d[3])),r=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]);function f(){const{rid:e,did:f}=(0,t.useLocalSearchParams)(),b=(0,u.useRestaurant)(e),j=(0,u.useMenu)(e).find(e=>e.id===f),x=(0,u.useCustomer)(),m=(0,u.useRecipeCards)(e).find(e=>e.id===j?.recipeCardId),y=m?.signOff&&m.photo?(0,h.recipeCards)().photoSource(m.photo):null,k=(0,u.useStore)(e=>e.addLine),[v,w]=(0,n.useState)(()=>(j?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[S,C]=(0,n.useState)(1),[B,$]=(0,n.useState)(''),[I,P]=(0,n.useState)(!1),[L,T]=(0,n.useState)(!1),[D,O]=(0,n.useState)(!1),[A,M]=(0,n.useState)(!1),R=(0,n.useMemo)(()=>j?(0,d.effectiveAllergens)(j,v):{},[j,v]);if(!b||!j)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Dish not found."})});const q=(0,d.conflictsFor)(R,x.allergies),_=(j.price??0)+(j.optionGroups??[]).flatMap(e=>e.choices).filter(e=>v.includes(e.id)).reduce((e,t)=>e+t.priceDelta,0),N=j.soldOut||!j.signOff||null===j.price,G=(e,t)=>{const n=j.optionGroups.find(t=>t.id===e);w(e=>{const l=n.choices.map(e=>e.id);return n.multi?e.includes(t)?e.filter(e=>e!==t):[...e,t]:e.includes(t)&&!n.required?e.filter(e=>e!==t):[...e.filter(e=>!l.includes(e)),t]})},z=e=>{u.useStore.getState().basket.restaurantId!==b.id&&u.useStore.getState().startBasket(b.id,'takeaway'),k({itemId:j.id,qty:S,choiceIds:v,notes:B,override:e?{allergens:q.contains,at:(new Date).toISOString()}:void 0}),P(!1),M(!0)};return(0,p.jsxs)(o.Screen,{title:j.name,subtitle:b.name,right:(0,p.jsx)(a.BasketButton,{}),children:[y?(0,p.jsx)(l.default,{testID:"dish-photo",source:y,accessibilityLabel:`${j.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,p.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,p.jsx)(o.T,{weight:"bold",size:20,colour:g.colours.gold,children:null===j.price?j.priceNote:(0,c.gbp)(_)}),j.dietary.map(e=>(0,p.jsx)(o.Badge,{kind:"green",label:e},e))]}),(0,p.jsx)(o.T,{children:j.description}),q.contains.length?(0,p.jsx)(o.Banner,{kind:"danger",title:`Blocked: contains ${q.contains.map(d.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${x.allergies.filter(e=>q.contains.includes(e.allergen)).map(e=>`${(0,d.allergenLabel)(e.allergen)} \u2014 ${(0,d.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,q.may.length?(0,p.jsx)(o.Banner,{kind:"warn",title:`Warning: may contain ${q.may.map(d.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(j.optionGroups??[]).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:e.choices.map(t=>(0,p.jsx)(o.Chip,{label:t.label,sub:t.priceDelta?`+${(0,c.gbp)(t.priceDelta)}`:void 0,selected:v.includes(t.id),onPress:()=>G(e.id,t.id)},t.id))})]},e.id)),(0,p.jsx)(o.Card,{children:(0,p.jsx)(r.AllergenPanel,{item:j,map:R,declared:x.allergies})}),b.fictional?null:(0,p.jsx)(o.ExampleAllergenNotice,{}),(0,p.jsx)(o.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:B,onChangeText:$}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Quantity"}),(0,p.jsx)(o.Stepper,{value:S,onChange:C,label:"quantity"})]}),A?(0,p.jsx)(o.Banner,{kind:"success",title:"Added to basket",children:q.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,N?(0,p.jsx)(o.Banner,{kind:"warn",children:j.soldOut?'Sold out today.':j.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):q.contains.length?(0,p.jsxs)(s.default,{style:{gap:8},children:[(0,p.jsx)(o.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,p.jsx)(o.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{T(!1),O(!1),P(!0)},testID:"override-open"})]}):(0,p.jsxs)(o.Row,{gap:8,children:[(0,p.jsx)(o.Button,{style:{flex:1},label:`Add ${S} to basket \xb7 ${(0,c.gbp)(_*S)}`,onPress:()=>z(!1),testID:"add-to-basket"}),A?(0,p.jsx)(o.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,p.jsxs)(o.Sheet,{visible:I,onClose:()=>P(!1),title:"Allergy override",children:[(0,p.jsx)(o.Banner,{kind:"danger",title:`${j.name} contains ${q.contains.map(d.allergenLabel).join(', ')}`,children:`Your profile says: ${x.allergies.filter(e=>q.contains.includes(e.allergen)).map(e=>`${(0,d.allergenLabel)(e.allergen)} \u2014 ${(0,d.severityLabel)(e.severity)}`).join('; ')}.`}),(0,p.jsx)(o.Toggle,{label:"I understand this dish contains an allergen I have declared",value:L,onChange:T}),(0,p.jsx)(o.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:D,onChange:O}),(0,p.jsx)(o.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,p.jsx)(o.Button,{kind:"danger",disabled:!L||!D,label:"Confirm override and add",onPress:()=>z(!0),testID:"override-confirm"})]})]})}},760,[785,12,178,109,806,807,791,792,794,797,808,799,6]); \ No newline at end of file diff --git a/staff-app/_expo/static/js/web/[oid]-56d81b26be27e5e79ac78f59a7cf908f.js b/staff-app/_expo/static/js/web/[oid]-56d81b26be27e5e79ac78f59a7cf908f.js new file mode 100644 index 0000000000000000000000000000000000000000..8292b8e075c0c4f5923a712eb02d30862186aaed --- /dev/null +++ b/staff-app/_expo/static/js/web/[oid]-56d81b26be27e5e79ac78f59a7cf908f.js @@ -0,0 +1 @@ +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},n=_r(d[3]),o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),b=_r(d[10]),y=_r(d[11]);const j=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],x=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function w(){const{oid:e}=(0,t.useLocalSearchParams)(),l=(0,p.useOrder)(e),w=(0,p.useRestaurant)(l?.restaurantId),[f,T]=(0,s.useState)(0),[C,S]=(0,s.useState)(''),[k,v]=(0,s.useState)(!1),[P,M]=(0,s.useState)(!1),[$,R]=(0,s.useState)(1),[A,I]=(0,s.useState)(0),[O,B]=(0,s.useState)(l?.split?.ways??1);if(!l||!w)return(0,y.jsx)(i.Screen,{title:"Order",children:(0,y.jsx)(i.T,{children:"Order not found."})});const N='takeaway'===l.type?j:x,H=Math.max(0,N.findIndex(([e])=>e===l.status)),_=Math.round(l.subtotal*A/100),D='table'===l.type?l.subtotal+(l.split?l.tip:_):l.total,F=D-l.paid,q=l.split?.ways??O,L=l.split?.paidShares??0,W=Math.ceil(D/q),Y='collected'===l.status||'closed'===l.status;return(0,y.jsxs)(i.Screen,{title:`Order ${l.ref}`,subtitle:`${w.name} \xb7 ${'table'===l.type?`Table ${l.tableNo}`:`Collection at ${l.slotTime?(0,h.hm)(new Date(l.slotTime)):'\u2014'}`}`,children:['takeaway'===l.type?(0,y.jsx)(i.Banner,{kind:"success",title:'ready'===l.status?'Your order is ready!':'Order placed and paid (demo)',children:'ready'===l.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${l.ref} at the bar when you arrive.`}):null,(0,y.jsxs)(i.Card,{children:[(0,y.jsx)(i.H2,{children:"Status"}),N.map(([e,t],s)=>(0,y.jsxs)(i.Row,{gap:10,children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=H?b.colours.gold:b.colours.surface2,borderWidth:1,borderColor:b.colours.gold}}),(0,y.jsx)(i.T,{weight:s===H?'semibold':'regular',colour:s<=H?b.colours.text:b.colours.muted,children:t})]},e)),l.allergyAck?(0,y.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",l.allergyAck.by,", ",(0,h.hm)(new Date(l.allergyAck.at)),")"]}):l.allergies.length?(0,y.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==l.type||Y?null:(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.Button,{small:!0,kind:'on-my-way'===l.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(l.id,'on-my-way')}),(0,y.jsx)(i.Button,{small:!0,kind:'here'===l.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(l.id,'here')})]})]}),(0,y.jsxs)(i.Card,{children:[(0,y.jsx)(i.H2,{children:"Items"}),l.lines.map((e,t)=>(0,y.jsxs)(r.default,{children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,y.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,y.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,y.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Muted,{children:"Subtotal"}),(0,y.jsx)(i.T,{children:(0,u.gbp)(l.subtotal)})]}),l.giftCardApplied?(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Muted,{children:"Of which gift card"}),(0,y.jsxs)(i.T,{colour:b.colours.green,children:["\u2212",(0,u.gbp)(l.giftCardApplied)]})]}):null,l.tip?(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Muted,{children:"Tip"}),(0,y.jsx)(i.T,{children:(0,u.gbp)(l.tip)})]}):null,(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.T,{weight:"semibold",children:"Paid (demo)"}),(0,y.jsx)(i.T,{weight:"semibold",colour:b.colours.gold,children:(0,u.gbp)(l.paid)})]})]}),'table'===l.type&&'closed'!==l.status&&'cancelled'!==l.status?(0,y.jsxs)(i.Card,{highlight:b.colours.gold,children:[(0,y.jsxs)(i.H2,{children:["Your bill \u2014 Table ",l.tableNo]}),l.split?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(i.T,{children:["Total ",(0,u.gbp)(D)," \xb7 split ",q," way",q>1?'s':''," \xb7 ",(0,u.gbp)(W)," each"]}),(0,y.jsxs)(i.T,{children:["Shares paid: ",L," of ",q," \xb7 remaining ",(0,u.gbp)(F)]}),q>1?(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.T,{children:"Shares to pay now"}),(0,y.jsx)(i.Stepper,{value:$,onChange:R,min:1,max:q-L,label:"shares"})]}):null,(0,y.jsx)(i.Button,{label:`Pay ${q>1?`${$} share${$>1?'s':''}`:'bill'} \xb7 ${(0,u.gbp)(Math.min(F,W*$))}`,onPress:()=>M(!0),testID:"pay-bill"})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,y.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,y.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:A===e,onPress:()=>I(e)},e))}),(0,y.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,y.jsx)(i.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,y.jsxs)(i.T,{children:["Total ",(0,u.gbp)(l.subtotal+_),O>1?` \xb7 ${(0,u.gbp)(Math.ceil((l.subtotal+_)/O))} each`:'']}),(0,y.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(l.id,O,_),testID:"get-bill"})]})]}):null,!Y||l.rated||k?null:(0,y.jsxs)(i.Card,{highlight:b.colours.gold,children:[(0,y.jsx)(i.H2,{children:"How was everything?"}),(0,y.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",w.name," only, never published."]}),(0,y.jsx)(o.Stars,{value:f,onChange:T}),f?(0,y.jsx)(i.Field,{label:"Anything to add? (optional)",value:C,onChangeText:S}):null,(0,y.jsx)(i.Button,{label:"Send feedback",disabled:!f,onPress:()=>{p.repo.feedback.add({restaurantId:w.id,orderId:l.id,customerId:l.customerId,customerName:l.customerName,stars:f,comment:C,context:'table'===l.type?`Table ${l.tableNo}`:`Takeaway ${l.ref}`}),v(!0)},testID:"send-rating"})]}),k||l.rated?(0,y.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,Y?(0,y.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>t.router.push(`/customer/${w.id}/loyalty`)}):null,(0,y.jsx)(n.MockPay,{visible:P,onClose:()=>M(!1),amount:Math.min(F,W*$),restaurantId:w.id,title:`Pay \u2014 Table ${l.tableNo}`,onPaid:e=>{p.repo.orders.payTable(l.id,{shares:$,giftCardCode:e.giftCardCode}),M(!1),R(1)}})]})}},773,[785,12,109,790,809,791,792,794,796,797,799,6]); \ No newline at end of file diff --git a/staff-app/_expo/static/js/web/__common-571ca2e6232d0d49fef1eb7969397adb.js b/staff-app/_expo/static/js/web/__common-571ca2e6232d0d49fef1eb7969397adb.js new file mode 100644 index 0000000000000000000000000000000000000000..8d897100d810209736f9d56626540eed999f0ced --- /dev/null +++ b/staff-app/_expo/static/js/web/__common-571ca2e6232d0d49fef1eb7969397adb.js @@ -0,0 +1,254 @@ +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n){return Object.keys(t).forEach(function(c){"default"===c||Object.prototype.hasOwnProperty.call(n,c)||Object.defineProperty(n,c,{enumerable:!0,get:function(){return t[c]}})}),t}Object.defineProperty(e,"__esModule",{value:!0}),r(d[0]),t(r(d[1]),e),t(r(d[2]),e),t(r(d[3]),e),t(r(d[4]),e)},785,[982,983,993,994,996]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ChefApp=function({section:e}={}){const{r:w,rid:T,me:A,now:H}=(0,P.useChef)(3e4),q=(0,C.useSignedIn)(),se=q?.id??P.CHEF_ID,te=e?Z[e]:void 0,[ie,le]=(0,c.useState)(te?.tab??'home'),[oe,re]=(0,c.useState)(te?.k??null),[ae,ne]=(0,c.useState)(te?.stock??'levels'),[de,ce]=(0,c.useState)(void 0),[ue,he]=(0,c.useState)(te?.gp??'dishes'),pe=(0,c.useRef)(null),ge=(0,t.ymd)(H),be=(0,t.ymd)(new Date(H.getTime()+864e5)),fe=(0,O.useTravelDay)('chef',ge),ke='home'===ie&&!fe;(0,n.useKitchenTodoChime)(T,ge),(0,K.useAlertWatcher)(T,{kinds:['takeaway']}),(0,c.useEffect)(()=>{(0,C.ensureAttendance)((new Date).toISOString().slice(0,10),H)},[]);const xe=(0,c.useCallback)((e,s=null)=>{le(e),re(s),pe.current?.scrollTo({y:0,animated:!1})},[]);(0,c.useEffect)(()=>{const e=u.default.addEventListener('hardwareBackPress',()=>oe?(re(null),!0):'home'!==ie&&(le('home'),!0));return()=>e.remove()},[ie,oe]);const me=oe?X.find(e=>e.id===oe):null,ye=(0,b.default)().width<430,je=me?me.title:{home:'Today in the kitchen',stock:'Stock',gp:'GP & costing',creator:_.CREATOR_TITLE,orders:'Ordering',kitchen:'Kitchen'}[ie];return(0,J.jsxs)(k.SafeAreaView,{style:{flex:1,backgroundColor:v.colours.bg},edges:['top','bottom'],children:[(0,J.jsxs)(f.default,{style:{paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:v.colours.border,gap:6},children:[(0,J.jsx)(f.default,{style:{alignItems:'center'},children:(0,J.jsx)(f.default,{testID:"header-me",accessibilityLabel:`Signed in as ${A.replace(' (example)','')}, Head Chef`,style:{borderWidth:1,borderColor:v.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'86%'},children:(0,J.jsxs)(j.Row,{gap:6,children:[(0,J.jsx)(E.StaffAvatar,{id:P.CHEF_ID,size:24,ring:!1}),(0,J.jsxs)(j.T,{size:13,weight:"semibold",colour:v.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[A.replace(' (example)','')," \xb7 Head Chef"]})]})})}),(0,J.jsxs)(j.Row,{gap:10,children:[(0,J.jsx)(x.RestaurantLogo,{rid:T,size:ye?36:44}),(0,J.jsxs)(f.default,{style:{flex:1,minWidth:0},children:[(0,J.jsx)(j.T,{weight:"semibold",size:ye?15:17,numberOfLines:1,children:w.name}),(0,J.jsx)(j.T,{size:12,colour:v.colours.muted,numberOfLines:1,children:"Head Chef app"}),(0,J.jsx)(x.PoweredBy,{})]}),(0,J.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Open Cover Charge for Staff",onPress:()=>{const e=(0,W.appUrl)('staff');e&&window.location.assign(e)},style:{borderWidth:1,borderColor:v.colours.gold,borderRadius:14,paddingHorizontal:8,paddingVertical:3},children:(0,J.jsx)(j.T,{size:12,colour:v.colours.gold,children:"Staff app \u203a"})}),(0,J.jsx)(y.VoiceSlot,{})]})]}),(0,J.jsxs)(p.default,{ref:pe,contentContainerStyle:{padding:14,paddingBottom:60,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,J.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[me?(0,J.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>re(null),hitSlop:10,children:(0,J.jsx)(j.T,{size:15,colour:v.colours.gold,children:"\u2039 Kitchen"})}):null,(0,J.jsx)(j.T,{size:22,weight:"bold",style:{flex:1,textAlign:me?'right':'left'},children:je})]}),'home'===ie?(0,J.jsx)(O.DayBar,{app:"chef",today:ge}):null,'home'===ie&&fe?(0,J.jsx)(O.DayView,{rid:T,day:fe,today:ge,app:"chef"}):null,ke?(0,J.jsx)(i.CoversToday,{rid:T,onPress:()=>xe('kitchen','bookings')}):null,ke?(0,J.jsx)(l.LastFoodBanner,{rid:T,now:H}):null,ke?(0,J.jsx)(o.NextTableFreeCard,{rid:T,now:H}):null,ke?(0,J.jsx)(r.KitchenSignoffs,{rid:T,today:ge,by:A,app:"chef"}):null,ke?(0,J.jsxs)(f.default,{style:{gap:4},children:[(0,J.jsx)(r.PlattersBooked,{rid:T,date:ge,label:"Platters booked today"}),(0,J.jsx)(r.PlattersBooked,{rid:T,date:be,label:"Platters booked tomorrow"})]}):null,ke?(0,J.jsx)(U.ChefAssistantButton,{}):null,ke?(0,J.jsx)(ee,{go:(e,s)=>{'stock'===e&&s&&ne(s),'gp'===e&&s&&he(s),'orders'===e&&ce(s),xe(e,'kitchen'===e?s??null:null)}}):null,'stock'===ie?(0,J.jsx)(B.StockScreen,{initial:ae},ae):null,'gp'===ie?(0,J.jsx)(S.GpScreen,{initial:ue},ue):null,'creator'===ie?(0,J.jsx)(_.DishCreator,{rid:T,canPublish:!1}):null,'orders'===ie?(0,J.jsx)(I.OrdersScreen,{focus:de},de??'all'):null,'kitchen'!==ie||me?null:(0,J.jsxs)(f.default,{style:{gap:10},children:[(0,J.jsx)(f.default,{style:{borderRadius:14,borderWidth:1,borderColor:v.colours.border,backgroundColor:v.colours.surface,overflow:'hidden'},children:X.map((e,s)=>(0,J.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>re(e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:v.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,J.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,J.jsxs)(f.default,{style:{flex:1},children:[(0,J.jsx)(j.T,{weight:"medium",children:e.title}),(0,J.jsx)(j.Muted,{children:e.sub})]}),(0,J.jsx)(j.T,{colour:v.colours.muted,children:"\u203a"})]})},e.id))}),(0,J.jsx)(j.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in Cover Charge for Managers."}),(0,J.jsxs)(j.Muted,{center:!0,children:["Head Chef app \xb7 ",s.APP_VERSION," \xb7 ",'live'===Y.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'mypay'===oe?(0,J.jsxs)(f.default,{style:{gap:10},testID:"chef-mypay",children:[(0,J.jsx)(L.MyPeriods,{staffId:se}),(0,J.jsx)($.MyHoursPay,{staffId:se}),(0,J.jsx)(D.MyTips,{staffId:se})]}):null,'bookings'===oe?(0,J.jsx)(d.TodaysBookings,{rid:T,today:ge,by:A,app:"chef"}):null,'specials'===oe?(0,J.jsx)(G.SpecialsEditor,{rid:T,me:A,app:"chef",now:H}):null,'prep'===oe?(0,J.jsx)(R.PrepScreen,{}):null,'live'===oe?(0,J.jsx)(R.TeamScreen,{}):null,'waste'===oe?(0,J.jsx)(R.WasteScreen,{}):null,'recipes'===oe?(0,J.jsx)(N.RecipeCards,{rid:T,actor:{name:A,role:'head-chef'},mode:"edit"}):null,'allergens'===oe?(0,J.jsx)(R.AllergenScreen,{openCards:()=>xe('kitchen','recipes')}):null,'compliance'===oe?(0,J.jsx)(R.ComplianceScreen,{}):null,'haccp'===oe?(0,J.jsx)(F.HaccpLog,{mode:"chef",me:A,meId:P.CHEF_ID,now:H}):null,'accidents'===oe?(0,J.jsx)(z.AccidentBook,{app:"chef",me:A,meId:P.CHEF_ID,now:H,seeAll:!1}):null]}),(0,J.jsx)(f.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderTopWidth:1,borderColor:v.colours.border,backgroundColor:v.colours.surface},children:Q.map(e=>{const s=ie===e.id;return(0,J.jsxs)(h.default,{accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:e.label,onPress:()=>xe(e.id),style:{flex:1,alignItems:'center',paddingVertical:8,paddingHorizontal:2,minHeight:52},children:[(0,J.jsx)(j.T,{size:18,colour:s?v.colours.gold:v.colours.muted,children:e.icon}),(0,J.jsx)(j.T,{size:e.label.length>10?10:11,weight:s?'semibold':'regular',colour:s?v.colours.gold:v.colours.muted,center:!0,children:e.label})]},e.id)})}),(0,J.jsx)(U.ChefAssistantSheet,{go:(e,s)=>{'orders'===e?(ce(s),xe('orders')):'gp'===e?xe('gp'):xe('kitchen',e)}}),(0,J.jsx)(M.AlertHost,{variant:"chef",rid:T,skipTakeaway:!0}),(0,J.jsx)(V.KitchenFlash,{rid:T,me:A})]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=e(_r(_d[9]));_r(_d[10]);var h=e(_r(_d[11])),p=e(_r(_d[12])),b=e(_r(_d[13])),f=e(_r(_d[14])),k=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),v=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),P=_r(_d[23]),S=_r(_d[24]),R=_r(_d[25]),I=_r(_d[26]),A=_r(_d[27]),H=_r(_d[28]),B=_r(_d[29]),$=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),D=_r(_d[33]),E=_r(_d[34]),W=_r(_d[35]),z=_r(_d[36]),_=_r(_d[37]),F=_r(_d[38]),G=_r(_d[39]),M=_r(_d[40]),V=_r(_d[41]),K=_r(_d[42]),N=_r(_d[43]),q=_r(_d[44]),U=_r(_d[45]),Y=_r(_d[46]),J=_r(_d[47]);const Q=[{id:'home',label:'Home',icon:'\u2302'},{id:'stock',label:'Stock',icon:'\u25a4'},{id:'gp',label:'GP',icon:'%'},{id:'creator',label:_.CREATOR_TITLE,icon:'\u271a'},{id:'orders',label:'Orders',icon:'\u270e'},{id:'kitchen',label:'Kitchen',icon:'\u2668'}],X=[{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'bookings',title:'Today\u2019s bookings',sub:'Covers, allergens to sign off, platters and other reservations, dogs, access and vegan/vegetarian'},{id:'recipes',title:'Recipe cards',sub:'Plating photo, ingredients, method, allergens, section and price; you sign each card off before it goes live'},{id:'specials',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, 86, team & chat',sub:'Orders, readiness alerts, sold out, who\u2019s on, rota, team chat and private messages'},{id:'waste',title:'Waste log',sub:'Item, quantity, reason and cost; weekly total and % of sales'},{id:'allergens',title:'Allergens',sub:'14-allergen matrix from the recipe cards, costing cross-check and audit log'},{id:'compliance',title:'Kitchen compliance',sub:'Fridge, freezer, cooking and cooling temps; cleaning; daily checks'}],Z={stock:{tab:'stock',stock:'levels'},'stock-take':{tab:'stock',stock:'take'},deliveries:{tab:'stock',stock:'deliveries'},gp:{tab:'gp',gp:'dishes'},'price-changes':{tab:'gp',gp:'changes'},'gp-week':{tab:'gp',gp:'week'},'menu-engineering':{tab:'gp',gp:'engineering'},orders:{tab:'orders'},prep:{tab:'kitchen',k:'prep'},live:{tab:'kitchen',k:'live'},waste:{tab:'kitchen',k:'waste'},recipes:{tab:'kitchen',k:'recipes'},'recipe-cards':{tab:'kitchen',k:'recipes'},allergens:{tab:'kitchen',k:'allergens'},compliance:{tab:'kitchen',k:'compliance'},haccp:{tab:'kitchen',k:'haccp'},specials:{tab:'kitchen',k:'specials'},accidents:{tab:'kitchen',k:'accidents'},'new-dish':{tab:'creator'}};function ee({go:e}){const{k:s,c:t,menu:i,now:l,rid:o,me:r}=(0,P.useChef)(3e4),n=(0,A.useSheetReminders)(),d=(0,P.useWeek)(),{covers:c,label:u}=(0,P.useForecast)(),p=(0,I.useSuggestions)(),b=s.ingredients.filter(e=>e.onHand<=0||(0,P.isLow)(e.onHand,e.par)),k=p.filter(e=>e.ordersToday&&!e.placedToday),x=(0,T.priceImpacts)(i,s.recipes,s.ingredients,s.targetGp).filter(e=>e.dropped.length),y=s.deliveries.filter(e=>'expected'===e.status),C=t.filter(e=>e.below),S=(0,q.useRecipeCards)(o).filter(e=>!e.signOff);return(0,J.jsxs)(f.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,J.jsx)(F.MissedBanner,{now:l,onPress:()=>e('kitchen','haccp')}),n.map(s=>(0,J.jsx)(h.default,{accessibilityRole:"button",onPress:()=>e('orders',s.supplierId),children:(0,J.jsxs)(j.Banner,{kind:'red'===s.tone?'danger':'warn',title:`\u23f0 ${s.text}`,children:["Tap to open the ",s.name," order sheet. Nothing is sent until you press Send."]})},s.supplierId)),S.length?(0,J.jsx)(h.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,J.jsxs)(j.Banner,{kind:"warn",title:`${S.length} recipe card${1===S.length?'':'s'} awaiting your sign-off`,children:[S.slice(0,4).map(e=>e.dish).join(', '),". Guests see \"awaiting allergen sign-off\" and cannot order these until you sign them off."]})}):null,(0,J.jsx)(H.ShellfishTile,{rid:o,by:r,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,J.jsxs)(j.Row,{wrap:!0,gap:10,children:[(0,J.jsx)(P.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,P.pct1)(d.theo),sub:`Target ${s.targetGp}% \xb7 actual ${(0,P.pct1)(d.actual)}`,tone:d.theoe('gp','week')}),(0,J.jsx)(P.Tile,{label:"Stock value",value:(0,w.gbp)((0,P.stockValue)(s.ingredients)),sub:"At cost",onPress:()=>e('stock','levels')}),(0,J.jsx)(P.Tile,{label:"Items low or out",value:`${b.length}`,sub:b.slice(0,3).map(e=>e.name).join(', '),tone:b.some(e=>e.onHand<=0)?'red':b.length?'amber':'green',onPress:()=>e('stock','levels')}),(0,J.jsx)(P.Tile,{label:"Waste this week",value:(0,w.gbp)(d.wasteWeek),sub:d.sales?`${(0,P.pct1)(d.wasteWeek/d.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),(0,J.jsx)(P.Tile,{label:"Covers forecast today",value:`${c}`,sub:u,onPress:()=>e('kitchen','prep')}),(0,J.jsx)(P.Tile,{label:"Orders due today",value:`${k.length}`,sub:k.map(e=>`${e.s.name.replace(/^(Example|Sample) /,'')} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:k.some(e=>e.cutPassed)?'red':k.length?'amber':'green',onPress:()=>e('orders')})]}),x.map(e=>(0,J.jsxs)(j.Banner,{kind:"danger",title:`${e.ing.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%: ${e.dropped.length} dish${1===e.dropped.length?'':'es'} drop below target`,children:[e.dropped.map(e=>e.item.name).join(', '),". Open GP \u203a Price changes."]},e.ing.id)),y.length?(0,J.jsx)(h.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,J.jsx)(j.Banner,{kind:"info",title:`${y.length} deliver${1===y.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,J.jsx)(h.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,J.jsxs)(j.Banner,{kind:"warn",title:`${C.length} dishes below ${s.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,J.jsx)(j.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[_.CREATOR_TITLE,'creator'],['Prep list','prep'],['Live tickets & 86','live'],['Allergens','allergens'],['Accident book','accidents']].map(([s,t])=>(0,J.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:s,onPress:()=>'creator'===t?e('creator'):e('kitchen',t),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:v.colours.gold,backgroundColor:v.colours.surface},children:(0,J.jsxs)(j.T,{weight:"semibold",children:[s," \u203a"]})},t))}),(0,J.jsx)(j.Badge,{kind:"neutral",label:"Demo data \xb7 nothing is ordered or sent"})]})}},786,[908,796,876,877,878,894,881,1036,12,215,104,245,133,269,109,271,883,882,791,794,799,884,1093,1096,1097,1098,1124,1125,891,1126,913,879,914,915,898,816,917,1133,918,1136,887,1142,889,909,797,1147,798,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"APP_VARIANT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"ENTRY",{enumerable:!0,get:function(){return s}}),_e.isAllowedPath=function(e,t=c){return'/'===e||''===e||f[t].test(e)},_e.canShow=function(e,t=c){return t===e||'owner'===t&&'customer'===e};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e};const u=o.default.expoConfig?.extra?.appVariant??void 0??'owner',c=['owner','staff','customer','display','chef'].includes(u)?u:'owner',s={owner:'/owner',staff:'/team',customer:`/customer/${t.VENUE_RID}`,display:'/display',chef:'/kitchen'},f={owner:/^\/(owner|customer|table)(\/|$)/,customer:/^\/(customer|table)(\/|$)/,staff:/^\/team(\/|$)/,display:/^\/display(\/|$)/,chef:/^\/kitchen(\/|$)/}},787,[856,390]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PERMISSIONS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"can",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"CHEF_SECTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"chefSectionAllowed",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"rotaView",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"chatView",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"ticketView",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"supplierView",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"auditView",{enumerable:!0,get:function(){return p}});const e={owner:'all',manager:'all',staff:new Set(['rota-shifts','tickets','eighty-six','allergens']),chef:new Set(['stock','costing','gp','waste','dish-sales','prep','ordering','allergens','compliance','rota-shifts','kitchen-chat','tickets','eighty-six','specials'])},t=(t,n)=>{const a=e[t];return'all'===a||a.has(n)},n={stock:'stock','stock-take':'stock',deliveries:'stock',gp:'gp','price-changes':'gp','gp-week':'gp','menu-engineering':'dish-sales',orders:'ordering',prep:'prep',live:'tickets',waste:'waste',allergens:'allergens',compliance:'compliance',haccp:'compliance',accidents:'compliance','new-dish':'gp',specials:'specials',recipes:'allergens','recipe-cards':'allergens'},a=e=>e in n&&t('chef',n[e]),s=(e,n,a)=>t(e,'staff-personal')?{staff:n,shifts:a}:{staff:n.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:a.filter(e=>e.published).map(({id:e,staffId:t,date:n,day:a,start:s,end:c,published:l})=>({id:e,staffId:t,date:n,day:a,start:s,end:c,published:l}))},c=(e,t)=>'chef'===e?t.filter(e=>'kitchen'===e.ch&&!e.removed):t,l=(e,n)=>t(e,'customer-personal')?n:n.map(({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:p,handoverCheck:f,allergyChain:u,bookingId:h,readiness:m,createdAt:b,restaurantId:k,notes:y,accepted:w,allergyTicks:j})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:p,handoverCheck:f,allergyChain:u,bookingId:h,readiness:m,createdAt:b,restaurantId:k,notes:y,accepted:w,allergyTicks:j})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),p=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text))},788,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_DWELL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"dwellBands",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"bandLabel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fmtMins",{enumerable:!0,get:function(){return o}}),_e.dwellFor=function(e,t,r=[]){const o=n(e),i=Math.max(0,o.findIndex(e=>t<=e.upTo)),s=o[i]??o[o.length-1];if(!1===e?.settings.dwellLearn)return{mins:s.mins,learned:!1,samples:0};const a=0===i?1:o[i-1].upTo+1,u=r.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt&&e.partySize>=a&&e.partySize<=s.upTo).map(e=>(new Date(e.finishedAt).getTime()-new Date(e.seatedAt).getTime())/6e4).filter(e=>e>=20&&e<=360).sort((e,t)=>e-t);if(u.length<8)return{mins:s.mins,learned:!1,samples:u.length};const l=u[Math.floor(u.length/2)];return{mins:5*Math.round((s.mins+l)/2/5),learned:!0,samples:u.length}},Object.defineProperty(_e,"DAYS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"ruleText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"ANCHORAGE_EVENTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"regularEventsOf",{enumerable:!0,get:function(){return l}}),_e.occursOn=m,_e.nextOccurrence=function(e,t){const n=f(t);for(let t=0;t<400;t++){const r=c(new Date(n.getFullYear(),n.getMonth(),n.getDate()+t));if(m(e,r))return r}return null},_e.expandEvents=function(e,t,n,r){const o=[];if(!t.some(e=>e.active))return o;const i=f(n),s=f(r);for(let n=i;n<=s;n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1)){const r=c(n);for(const n of t)m(n,r)&&o.push({id:`${n.id}:${r}`,restaurantId:e,date:r,title:n.name,kind:'event',example:!1,source:'regular',description:[n.time?`from ${n.time}`:'',n.lastFood?`last food orders ${n.lastFood}`:'',n.notes??''].filter(Boolean).join(' \xb7 '),busier:n.busier,lastFood:n.lastFood,time:n.time})}return o},_e.lastFoodOn=function(t,n){if(!t)return null;const r=f(n).getDay(),o=t.settings.lastFoodByDay?.[r],s=(0,e.kitchenHoursOn)(t,f(n));let a=s?{time:s[1],reason:'kitchen closes'}:null;o&&(!a||oe?.settings.dwellBands?.length?e.settings.dwellBands:t,r=(e,t)=>{const n=0===t?1:e[t-1].upTo+1,r=e[t].upTo;return r>=9999?`${n} or more covers`:n===r?`${n} cover${1===n?'':'s'}`:`${n}\u2013${r} covers`},o=e=>e%60==0?`${e/60} hour${60===e?'':'s'}`:e>60?`${Math.floor(e/60)} h ${e%60} min`:`${e} min`;const i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],s=['','first','second','third','fourth'],a=e=>'last'===e.kind?`Last ${i[e.weekday]} of every month`:'nth'===e.kind?`${s[e.n][0].toUpperCase()}${s[e.n].slice(1)} ${i[e.weekday]} of every month`:'weekly'===e.kind?`Every ${i[e.weekday]}`:`One-off: ${e.date}`,u=[{id:'ev-music-night',name:'Music Night',rule:{kind:'last',weekday:0},time:'20:00',notes:'Live music from 8pm.',busier:!0,lastFood:'19:00',active:!0}],l=e=>e?.settings.regularEvents??('anchorage'===e?.id?u:[]),d=e=>String(e).padStart(2,'0'),c=e=>`${e.getFullYear()}-${d(e.getMonth()+1)}-${d(e.getDate())}`,f=e=>new Date(Number(e.slice(0,4)),Number(e.slice(5,7))-1,Number(e.slice(8,10)));function m(e,t){if(!e.active)return!1;const n=e.rule;if('once'===n.kind)return n.date===t;const r=f(t);return r.getDay()===n.weekday&&('weekly'===n.kind||('nth'===n.kind?Math.ceil(r.getDate()/7)===n.n:new Date(r.getFullYear(),r.getMonth(),r.getDate()+7).getMonth()!==r.getMonth()))}const b=e=>e?.settings.afterLastFood??'drinks',y=e=>{const[t,n]=e.split(':').map(Number);return`${t%12||12}${n?`:${d(n)}`:''}${t<12?'am':'pm'}`},p=e=>e?.settings.showTakeaway??'anchorage'!==e?.id,h=e=>!1!==e?.settings.coversCounter,O=e=>!1!==e?.settings.nextTableFree,$=e=>!1!==e?.settings.dogQuestion,w=e=>!1!==e?.settings.dietQuestion,F=e=>!1!==e?.settings.accessQuestion,k=(e,t)=>e?.settings.holidayFullNames?t:t.replace(/\s*\(substitute day\)/gi,'').trim()},789,[793]); +__d(function(_g,r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.MockPay=function({visible:e,onClose:j,amount:p,restaurantId:b,allowGiftCard:m=!0,onPaid:x,title:f="Pay",allowSaveCardOnly:y}){const g=(0,t.useGiftCards)(b).filter(e=>e.balance>0),[w,C]=(0,s.useState)(),[P,v]=(0,s.useState)('Demo card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),S=g.find(e=>e.code===w),_=S?Math.min(S.balance,p):0,R=p-_;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:f,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),m&&g.length>0?(0,h.jsxs)(o.default,{style:{gap:6},children:[(0,h.jsx)(u.T,{weight:"semibold",children:"Use a gift card"}),(0,h.jsxs)(u.Row,{wrap:!0,children:[(0,h.jsx)(u.Chip,{label:"None",selected:!w,onPress:()=>C(void 0)}),g.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:w===e.code,onPress:()=>C(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Demo card \u2022\u2022\u2022\u2022 4242','Apple Pay (demo)','Google Pay (demo)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>v(e)},e))}),(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(u.Muted,{children:"Amount"}),(0,h.jsx)(u.T,{children:(0,n.gbp)(p)})]}),_?(0,h.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(u.Muted,{children:"Gift card"}),(0,h.jsxs)(u.T,{colour:c.colours.green,children:["\u2212",(0,n.gbp)(_)]})]}):null,(0,h.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(u.T,{weight:"semibold",children:"To pay now"}),(0,h.jsx)(u.T,{weight:"bold",size:20,colour:c.colours.gold,children:(0,n.gbp)(R)})]})]}),y?(0,h.jsx)(u.Banner,{kind:"info",children:"A card is saved now (demo). It would only be charged under the stated no-show policy."}):null,T?(0,h.jsx)(l.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:y?'Save card (demo)':`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),x({giftCardCode:w,giftApplied:_,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),l=e(r(d[1])),o=e(r(d[2])),t=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},790,[12,228,109,797,794,799,791,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.T=B,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return w}}),_e.BrandBar=z,_e.Screen=function({children:e,title:o,subtitle:l,back:t=!0,right:n,maxWidth:c=640,footer:u,scroll:b=!0}){const h=(0,C.jsx)(f.default,{style:{width:'100%',maxWidth:c,alignSelf:'center',padding:16,gap:12},children:e});return(0,C.jsxs)(y.SafeAreaView,{style:{flex:1,backgroundColor:p.colours.bg},edges:['top','left','right'],children:[(0,C.jsx)(f.default,{style:{width:'100%',maxWidth:c,alignSelf:'center'},children:(0,C.jsx)(z,{title:o,subtitle:l,back:t,right:n})}),b?(0,C.jsx)(s.default,{contentContainerStyle:{paddingBottom:40},children:h}):(0,C.jsx)(f.default,{style:{flex:1},children:h}),u?(0,C.jsx)(f.default,{style:A.footer,children:(0,C.jsx)(f.default,{style:{width:'100%',maxWidth:c,alignSelf:'center'},children:u})}):null]})},_e.Button=function({label:e,onPress:o,kind:l="primary",disabled:t,small:s,style:c,accessibilityLabel:u,testID:b}){const h={primary:p.colours.gold,secondary:p.colours.tile,danger:p.colours.redSolid,ghost:'transparent',success:p.colours.accentBg}[l],f={primary:p.colours.onGold,secondary:p.colours.text,danger:'#FFFFFF',ghost:p.colours.gold,success:p.colours.goldLight}[l],y={primary:'transparent',secondary:p.colours.hairline,danger:'transparent',ghost:'transparent',success:p.colours.accentBorder}[l];return(0,C.jsx)(n.default,{testID:b,accessibilityRole:"button",accessibilityLabel:u??e,accessibilityState:{disabled:!!t},disabled:t,onPress:o,style:({pressed:e})=>[A.btn,{backgroundColor:e&&'secondary'===l?p.colours.tilePressed:h,borderColor:y,opacity:t?.4:e?.85:1},s&&{paddingVertical:8,paddingHorizontal:14,minHeight:48},c],children:(0,C.jsx)(B,{weight:"semibold",size:s?p.font.small:p.font.body,colour:f,center:!0,children:e})})},_e.Card=function({children:e,style:o,onPress:l,highlight:t}){const s=t===p.colours.gold||t===p.colours.accentBorder,c=(0,C.jsx)(f.default,{style:[A.card,t?{borderColor:s?p.colours.accentBorder:t,borderWidth:s?1:2}:null,o],children:e});return l?(0,C.jsx)(n.default,{accessibilityRole:"button",onPress:l,style:({pressed:e})=>({opacity:e?.85:1}),children:c}):c},_e.Badge=function({label:e,kind:o="neutral"}){const l={neutral:[p.colours.surface2,p.colours.muted,p.colours.border],gold:[p.colours.goldTint,p.colours.goldLight,p.colours.gold],red:[p.colours.redBg,'#FFD9D4',p.colours.red],amber:[p.colours.amberBg,'#FFE2A8',p.colours.amber],green:[p.colours.greenBg,'#CFF3D7',p.colours.green],blue:[p.colours.blueBg,'#D6E9FF',p.colours.blue]}[o];return(0,C.jsx)(f.default,{style:[A.badge,{backgroundColor:l[0],borderColor:l[2]}],children:(0,C.jsx)(B,{size:13,weight:"medium",colour:l[1],children:e})})},_e.Banner=P,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return W}}),_e.Row=S,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return T}}),_e.Field=function({label:e,...o}){return(0,C.jsxs)(f.default,{style:{gap:4},children:[(0,C.jsx)(B,{size:p.font.small,weight:"medium",colour:p.colours.muted,children:e}),(0,C.jsx)(h.default,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...o,style:[A.input,o.multiline&&{minHeight:70,textAlignVertical:'top'},o.style]})]})},_e.Chip=function({label:e,selected:o,onPress:l,disabled:t,sub:s}){return(0,C.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:!!o,disabled:!!t},disabled:t,onPress:l,style:[A.chip,o&&{backgroundColor:p.colours.gold,borderColor:p.colours.gold},t&&{opacity:.35}],children:[(0,C.jsx)(B,{size:p.font.small,weight:"medium",colour:o?p.colours.onGold:p.colours.text,center:!0,children:e}),s?(0,C.jsx)(B,{size:12,colour:o?p.colours.onGold:p.colours.muted,center:!0,children:s}):null]})},_e.Toggle=function({value:e,onChange:o,label:l}){return(0,C.jsxs)(S,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,C.jsx)(B,{style:{flex:1,flexShrink:1},children:l}),(0,C.jsx)(u.default,{accessibilityLabel:l,value:e,onValueChange:o,trackColor:{true:p.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:p.colours.gold})]})},_e.Stepper=function({value:e,onChange:o,min:l=1,max:t=20,label:s}){return(0,C.jsxs)(S,{gap:10,children:[(0,C.jsx)(n.default,{accessibilityLabel:`Decrease ${s??''}`,onPress:()=>o(Math.max(l,e-1)),style:A.stepBtn,children:(0,C.jsx)(B,{size:20,colour:p.colours.gold,children:"\u2212"})}),(0,C.jsx)(B,{weight:"semibold",size:p.font.large,style:{minWidth:28,textAlign:'center'},children:e}),(0,C.jsx)(n.default,{accessibilityLabel:`Increase ${s??''}`,onPress:()=>o(Math.min(t,e+1)),style:A.stepBtn,children:(0,C.jsx)(B,{size:20,colour:p.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:c,maxWidth:u,testID:b}){return(0,C.jsx)(t.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(f.default,{style:A.overlay,children:(0,C.jsxs)(f.default,{style:[A.sheet,u?{maxWidth:u}:null],testID:b,children:[(0,C.jsxs)(S,{style:{justifyContent:'space-between',marginBottom:8},children:[(0,C.jsx)(k,{style:{flex:1},children:l}),(0,C.jsx)(n.default,{accessibilityLabel:"Close",onPress:o,hitSlop:10,children:(0,C.jsx)(B,{size:22,colour:p.colours.muted,children:"\u2715"})})]}),(0,C.jsx)(s.default,{contentContainerStyle:{gap:12},children:c})]})})})},_e.SectionTitle=function({children:e}){return(0,C.jsx)(B,{weight:"semibold",size:12,colour:p.colours.goldMuted,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return A}});var o=r(d[0]),l=e(r(d[1])),t=e(r(d[2])),n=e(r(d[3])),s=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),b=e(r(d[7])),h=e(r(d[8])),f=e(r(d[9])),y=r(d[10]),p=r(d[11]),x=r(d[12]),j=r(d[13]),C=r(d[14]);function B({children:e,style:o,size:l=p.font.body,weight:t="regular",colour:n=p.colours.text,numberOfLines:s,center:c}){return(0,C.jsx)(b.default,{numberOfLines:s,style:[{fontFamily:p.fonts[t],fontSize:l,color:n,lineHeight:Math.round(1.4*l)},c&&{textAlign:'center'},o],children:e})}const F=e=>(0,C.jsx)(B,{size:p.font.title,weight:"semibold",...e}),k=e=>(0,C.jsx)(B,{size:p.font.large,weight:"semibold",...e}),w=e=>(0,C.jsx)(B,{colour:p.colours.muted,size:p.font.small,...e});function z({title:e,back:l=!0,right:t,subtitle:s}){return(0,C.jsxs)(f.default,{style:A.brandBar,children:[(0,C.jsxs)(f.default,{style:A.row,children:[l?(0,C.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>o.router.canGoBack()?o.router.back():o.router.replace(x.ENTRY[x.APP_VARIANT]),style:A.backBtn,hitSlop:10,children:(0,C.jsx)(B,{size:22,colour:p.colours.gold,children:"\u2039"})}):null,(0,C.jsx)(n.default,{onPress:()=>o.router.push(x.ENTRY[x.APP_VARIANT]),accessibilityLabel:"Home",style:[A.row,{gap:8}],children:(0,C.jsx)(j.RestaurantBrand,{size:j.HEADER_LOGO})}),(0,C.jsx)(f.default,{style:{flex:1}}),t]}),e?(0,C.jsx)(F,{style:{marginTop:10},children:e}):null,s?(0,C.jsx)(w,{children:s}):null]})}function P({kind:e="info",title:o,children:t}){const n={info:[p.colours.blueBg,p.colours.blue,'#D6E9FF'],warn:[p.colours.amberBg,p.colours.amber,'#FFE2A8'],danger:[p.colours.redBg,p.colours.red,'#FFE3DF'],success:[p.colours.greenBg,p.colours.green,'#CFF3D7'],example:[p.colours.amberBg,p.colours.amber,'#FFE2A8'],demo:[p.colours.goldTint,p.colours.gold,p.colours.goldLight]}[e];return(0,C.jsxs)(f.default,{accessibilityRole:"alert",style:[A.banner,{backgroundColor:n[0],borderLeftColor:n[1]}],children:[o?(0,C.jsx)(B,{weight:"semibold",colour:n[2],children:o}):null,l.default.Children.toArray(t).every(e=>'string'==typeof e||'number'==typeof e)?(0,C.jsx)(B,{size:p.font.small,colour:n[2],children:t}):t]})}const R=()=>(0,C.jsx)(P,{kind:"example",title:"Example allergen data \u2014 not verified by the kitchen",children:"Allergen information in this prototype is illustrative only. Real data needs head chef sign-off. Always speak to staff about allergies."}),W=()=>(0,C.jsx)(P,{kind:"demo",title:"Demo, no real payment",children:"No card is charged and no payment provider is contacted."});function S({children:e,style:o,gap:l=8,wrap:t}){return(0,C.jsx)(f.default,{style:[A.row,{gap:l},t&&{flexWrap:'wrap'},o],children:e})}const T=()=>(0,C.jsx)(f.default,{style:{height:1,backgroundColor:p.colours.border,marginVertical:4}});const A=c.default.create({row:{flexDirection:'row',alignItems:'center'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:p.colours.border},backBtn:{paddingRight:10,paddingVertical:2},btn:{borderRadius:12,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:48},card:{backgroundColor:p.colours.surface,borderRadius:p.radius.l,padding:16,borderWidth:1,borderColor:p.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:p.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,backgroundColor:p.colours.surface2,borderColor:p.colours.border,borderWidth:1,borderRadius:p.radius.m,paddingHorizontal:12,paddingVertical:10,color:p.colours.text,fontSize:p.font.body,fontFamily:p.fonts.regular},chip:{borderWidth:1,borderColor:p.colours.border,borderRadius:p.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:p.colours.surface2,minWidth:64},stepBtn:{width:40,height:40,borderRadius:20,borderWidth:1.5,borderColor:p.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:p.colours.surface,borderRadius:p.radius.l,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:p.colours.gold},footer:{borderTopWidth:1,borderTopColor:p.colours.border,backgroundColor:p.colours.surface,padding:12}})},791,[785,12,238,245,133,28,253,188,255,109,271,799,787,883,6]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ALLERGENS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"allergenLabel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEVERITIES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"severityLabel",{enumerable:!0,get:function(){return s}}),e.effectiveAllergens=function(l,n=[]){const t={...l.allergens};for(const s of l.optionGroups??[])for(const l of s.choices)if(n.includes(l.id)&&l.allergens)for(const[n,s]of Object.entries(l.allergens))'contains'!==t[n]&&(t[n]=s);return t},e.conflictsFor=function(l,n){const t=[],s=[];for(const a of n)'contains'===l[a.allergen]?t.push(a.allergen):'may'===l[a.allergen]&&s.push(a.allergen);return{contains:t,may:s}},Object.defineProperty(e,"hasConflict",{enumerable:!0,get:function(){return a}});const l=[{id:'gluten',label:'Cereals containing gluten',short:'Gluten'},{id:'crustaceans',label:'Crustaceans',short:'Crustaceans'},{id:'molluscs',label:'Molluscs',short:'Molluscs'},{id:'eggs',label:'Eggs',short:'Eggs'},{id:'fish',label:'Fish',short:'Fish'},{id:'peanuts',label:'Peanuts',short:'Peanuts'},{id:'treenuts',label:'Tree nuts',short:'Tree nuts'},{id:'soya',label:'Soya',short:'Soya'},{id:'milk',label:'Milk',short:'Milk'},{id:'celery',label:'Celery',short:'Celery'},{id:'mustard',label:'Mustard',short:'Mustard'},{id:'sesame',label:'Sesame',short:'Sesame'},{id:'sulphites',label:'Sulphur dioxide / sulphites',short:'Sulphites'},{id:'lupin',label:'Lupin',short:'Lupin'}],n=n=>l.find(l=>l.id===n)?.short??n,t=[{id:'intolerance',label:'Intolerance'},{id:'allergy',label:'Allergy'},{id:'coeliac',label:'Coeliac disease'},{id:'anaphylaxis',label:'Severe \u2014 anaphylaxis risk'}],s=l=>t.find(n=>n.id===l)?.label??l;const a=l=>l.contains.length>0||l.may.length>0},792,[]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ANCHORAGE_SEASONS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"hourSetsOf",{enumerable:!0,get:function(){return n}}),e.seasonOn=s,e.kitchenHoursOn=l,e.hoursFor=function(r,n){const u=l(r,n);return u?{open:(0,t.atTime)(n,u[0]),close:(0,t.atTime)(n,u[1])}:null};var t=_r(_d[0]);const r=[{id:'winter',name:'Winter',hours:{0:['12:30','19:00'],1:null,2:null,3:['12:00','19:00'],4:['12:00','19:00'],5:['12:00','20:00'],6:['12:00','20:00']}},{id:'summer',name:'Summer',hours:null}],n=t=>t.settings.hourSets??('anchorage'===t.id?r:[]),u=t=>`${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,o=t=>`${t.getFullYear()}-${u(t)}`;function s(t,r){const o=n(t).filter(t=>t.hours);if(!o.length)return null;const s=o.filter(t=>t.start).sort((t,r)=>t.start.localeCompare(r.start));if(s.length<2)return s[0]??o[0];const l=u(r);return[...s].reverse().find(t=>t.start<=l)??s[s.length-1]}function l(t,r){const n=(t.settings.hourOverrides??[]).find(t=>t.date===o(r));if(n)return n.hours;const u=s(t,r);return u?.hours?u.hours[r.getDay()]??null:t.kitchenHours[r.getDay()]??null}},793,[796]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"gbp",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return n}});const t=t=>`\xa3${(t/100).toFixed(2)}`,n=t=>Math.round(100*t)},794,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.takeawaySlots=function(s,o,r){const l=(0,t.hoursFor)(s,r);if(!l)return[];const d=s.settings.slotMinutes,u=(0,n.addMins)(r,s.settings.leadMins),c=[];for(let t=new Date(l.open);t<=l.close;t=(0,n.addMins)(t,d)){if(tn.restaurantId===s.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;c.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:s.settings.slotCap,full:r>=s.settings.slotCap})}return c},e.bookingSlots=function(r,l,d,u,c){const f=(0,t.hoursFor)(r,l);if(!f)return[];const p=[],M=(0,n.addMins)(f.close,-60),h=(0,s.lastFoodOn)(r,o(l)),k=h?(0,n.addMins)((0,n.atTime)(l,h.time),-60):M,S='drinks'===(0,s.afterLastFood)(r);for(let t=new Date(f.open);t<=M;t=(0,n.addMins)(t,30)){const s=(0,n.hm)(t),o=t>k;if(o&&!S)continue;const l=r.settings.bookingCoversPerSlot-d(s),f=t.getTime()=u,...o?{drinksOnly:!0}:{}})}return p};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]);const o=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},795,[793,796,789]); +__d(function(g,r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"pad",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseYmd",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toMins",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fromMins",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"atTime",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"addMins",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayShort",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"dayLong",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"monthLong",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"niceDate",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"niceDateYear",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"minsBetween",{enumerable:!0,get:function(){return P}});const t=t=>String(t).padStart(2,'0'),n=n=>`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())}`,u=n=>`${t(n.getHours())}:${t(n.getMinutes())}`,a=t=>{const[n,u,a]=t.split('-').map(Number);return new Date(n,u-1,a)},o=t=>{const[n,u]=t.split(':').map(Number);return 60*n+u},c=n=>`${t(Math.floor(n/60))}:${t(n%60)}`,b=(t,n)=>{const u=new Date(t);return u.setHours(0,0,0,0),u.setMinutes(o(n)),u},d=(t,n)=>new Date(t.getTime()+6e4*n),y=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],f=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],m=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],l=['January','February','March','April','May','June','July','August','September','October','November','December'],p=t=>y[t.getDay()],s=t=>f[t.getDay()],O=t=>l[t],M=t=>`${y[t.getDay()]} ${t.getDate()} ${m[t.getMonth()]}`,j=t=>`${M(t)} ${t.getFullYear()}`,P=(t,n)=>Math.round((n.getTime()-t.getTime())/6e4)},796,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"repo",{enumerable:!0,get:function(){return o}});var t=r(d[0]),n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});const o=t.localRepositories},797,[1004,924]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSync",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"can",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"isLive",{enumerable:!0,get:function(){return A}}),_e.claimInviteForSync=async function(e){if(!(0,a.isSupabaseConfigured)())return null;try{await Ee();const{data:t,error:a}=await R().rpc('claim_invite',{p_token:e,p_app:U});if(a)throw a;const s=t?.[0];if(!s)return null;const r={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key};return await n.kv.set(Te,r),K&&Pe(),r}catch(e){return M({lastError:`Sign-in: ${String(e?.message??e)}`}),null}},_e.pairWithCode=async function(e){if(!(0,a.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ee();const{data:t,error:a}=await R().rpc('claim_pairing_code',{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted.'};const r={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await n.kv.set(Ce,r),Pe(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},_e.unpairDisplay=async function(){await n.kv.remove(Ce),await Ne();try{await R().auth.signOut()}catch{}M({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},_e.disconnectStaff=async function(){await n.kv.remove(Te),await Ne();try{await R().auth.signOut()}catch{}M({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},_e.guestSession=je,Object.defineProperty(_e,"rpc",{enumerable:!0,get:function(){return Ke}}),_e.startAppSync=async function(e=u.VENUE_RID){if(K)return;K=!0,qe=e,'customer'===U&&'live'!==d.useStore.getState().clock.mode&&d.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(T(),!(0,a.isSupabaseConfigured)())return void M({mode:'off'});i.mutationQueue.subscribe(()=>M({pending:i.mutationQueue.pending.length,failed:i.mutationQueue.failed.length})),i.mutationQueue.onFailed(e=>M({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:i.mutationQueue.failed.length})),j.push((0,s.onConnectivity)(e=>M({mode:e?D.getState().venueId?'live':D.getState().mode:D.getState().venueId?'offline':D.getState().mode}))),await Fe()},Object.defineProperty(_e,"syncInternals",{enumerable:!0,get:function(){return He}}),_e.goLive=ze,Object.defineProperty(_e,"usePublicDayStore",{enumerable:!0,get:function(){return lt}}),_e.publicDay=function(e,t){const s=`${e}|${t}`,n=dt.get(s);if('customer'!==U||!(0,a.isSupabaseConfigured)())return null;(!n||Date.now()-n.at>6e4)&&(n?n.at=Date.now():dt.set(s,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ke('public_day',{p_venue_slug:e,p_date:t}).then(a=>{const n=[],r=[];(a??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:P(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:P(a.from_time),to:P(a.to_time),areaId:a.area_id??void 0,by:'',createdAt:''})}),dt.set(s,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),lt.setState(e=>({n:e.n+1}))}).catch(()=>{const e=dt.get(s);e&&!e.ok&&dt.delete(s)}));const r=dt.get(s);return r?.ok?r.v:null};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),g=_r(_d[15]),S=_r(_d[16]),w=_r(_d[17]),y=_r(_d[18]),b=_r(_d[19]),h=_r(_d[20]),_=_r(_d[21]),v=_r(_d[22]),k=_r(_d[23]),I=_r(_d[24]),O=_r(_d[25]);const R=()=>(0,t.getSupabase)();i.mutationQueue.setExecutor(r.executeMutation);const D=(0,e.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),M=e=>D.setState(e),x=e=>{const t=D.getState().perms;return t.includes('*')||t.includes(e)},A=()=>{const e=D.getState().mode;return'live'===e||'offline'===e||'connecting'===e};let U=l.APP_VARIANT,C=!1;const T=()=>{C||((0,n.setSyncNamespace)(U),C=!0)};let E=[],j=[],K=!1;const $=()=>(new Date).toISOString().slice(0,10),N=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),P=e=>e?e.slice(0,5):'',q=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],F=e=>JSON.parse(JSON.stringify(e));function W(e,t){const a=N(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>d.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id),writable:()=>'guest'!==D.getState().kind,filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=F(e);return t?{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:q(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s}:{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,_.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:q(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};return!t&&a.status&&'declined'!==a.status&&(s.status=a.status),t&&(s.walkIn=!0),s},apply:(e,t)=>d.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>d.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()})}}function B(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>d.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id),writable:()=>'guest'!==D.getState().kind,filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,_.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:F(e.lines??[]),allergies:q(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:F(e.allergyChain??{}),readiness:F(e.readiness??{}),allergy_ticks:F(e.allergyTicks??{}),handover_check:e.handoverCheck?F(e.handoverCheck):null,accepted:e.accepted?F(e.accepted):null,doc:F(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>d.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>d.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Q(e){const t=N(60);return{name:'blocks',table:'blocks',list:()=>c.useBlocks.getState().blocks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==D.getState().kind,filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:F(e)}),fromRow:t=>t.doc?{...t.doc,id:String(t.id),rid:e}:{id:String(t.id),rid:e,date:t.block_date,from:P(t.from_time),to:P(t.to_time),reason:t.reason??void 0,note:t.note??void 0,by:t.created_by??'',createdAt:t.created_at,areaId:t.area_id??void 0,areaName:t.area_name??void 0},apply:(e,t)=>c.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.blocks.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{blocks:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>c.useBlocks.subscribe((t,a)=>{t.blocks!==a.blocks&&e()})}}let G=null;function L(e){const t=e=>F({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(f.useFloor.getState().plans[e]??(0,f.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>x('floor.manage'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:G??(0,O.uuidFrom)(`plan:${a}`),venue_id:a,name:'Main',is_active:!0,...t(e),updated_by:D.getState().staffRef??U}),fromRow:e=>(G=String(e.id),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0];a&&f.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>f.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function H(e){return{name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>p.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>x('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,_.isUuid)(e.supplierId)?e.supplierId:(0,O.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...e.supplier_id?{supplierId:(t=String(e.supplier_id),se.get(t)??t)}:{}};var t},apply:(t,a)=>p.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>p.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const J=new Set;function z(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>p.useShellStore.getState().events.filter(t=>t.rid===e&&(0,_.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,_.isUuid)(t.id)&&!!(p.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==D.getState().kind&&('device'!==D.getState().kind||x('device.write')),filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,_.isUuid)(e.undoes)?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(J.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>p.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>p.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function V(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(p.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...p.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;p.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...J]}}}))},afterRead:()=>{p.useShellStore.getState().server[e]||p.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...J]}}}))},subscribe:()=>()=>{}}}const X=new Set;function Y(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=d.useStore.getState().menu;return m.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.card.id),writable:()=>x('recipes.edit'),toRow:(e,t)=>{let a=e.card;if(a.photo?.startsWith('local:')){const e=(0,O.photoPath)(t,a),s=Z(a.photo);s&&((0,m.cachePhotoAs)(e,s),ee(e,s)),a={...a,photo:e}}const{row:s,extra:n}=(0,O.cardToRow)(a,t);return{...s,...n,doc:F({card:a,item:e.item})}},fromRow:t=>{const a=t.doc;if(!a?.card)return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e}:void 0}},apply:(e,t)=>{const a=new Set(t);m.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&d.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&d.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=m.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=d.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const Z=e=>(0,m.readLocalPhoto)(e);async function ee(e,t){if(!X.has(e)){X.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await R().storage.from(O.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){X.delete(e),M({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const te=new Map,ae=(0,e.create)(()=>({n:0}));(0,m.setStoragePhotoResolver)(e=>{const t=te.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,a.isSupabaseConfigured)()&&'off'!==D.getState().mode?(t||(te.set(e,{url:'',at:Date.now()}),R().storage.from(O.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(te.set(e,{url:t.signedUrl,at:Date.now()}),ae.setState(e=>({n:e.n+1})),m.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const se=new Map;const ne=(e,t)=>{const a=(0,_.isUuid)(t)?t:(0,O.uuidFrom)(`sup:${e}:${t}`);return se.set(a,t),a};function re(e){return{name:'order_sheets',table:'suppliers',list:()=>g.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:()=>!0,writable:()=>x('suppliers.manage'),toRow:(e,t)=>({id:ne(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:F(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(se.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>g.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>g.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,_.isUuid)(e)?e:(0,O.uuidFrom)(`sup:${D.getState().venueId}:${e}`)})}}const ie=new Map,oe=new Map,de=new Map,le=new Map,ue=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ce=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},fe=e=>F({id:e.id,name:e.name,role:e.role,job:e.job,active:e.active,level:e.level??ce(ue(e)).level,dept:e.dept??''});const pe=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},me=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`};function ge(){return{name:'rota',table:'rota_shifts',list:()=>h.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id)&&ie.has(e.staffId),writable:()=>x('rota.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ie.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(pe());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:me(e.start),end_time:me(e.end),published:!!e.published,doc:F(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>h.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Se(){const e=N(62),t=e=>x('rota.manage')||e.staffId===D.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>h.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id)&&t(e),writable:()=>'staff'===D.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ie.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:F(e.breaks??[]),break_mins:e.breakMins??0,doc:F(e)}),fromRow:e=>{if(!e.doc)return null;const t={...e.doc,id:String(e.id)};return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>h.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function we(){const e=N(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>h.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id)&&e.staffId===D.getState().staffRef&&'open'===e.status,writable:()=>'staff'===D.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ie.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,_.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:F({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>h.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function ye(e){h.timesheetRemote.send=(t,a)=>{if(!x('rota.manage')||!(0,_.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return i.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:F(s)}}),!0}const s=a;if('attendance_confirm'===t)return i.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:F(s)}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return i.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:F(s.breaks??[]),p_reason:n,p_doc:F(s)}}),!0},j.push(()=>{h.timesheetRemote.send=null})}function be(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>d.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===D.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,_.isUuid)(a)?a:(0,O.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,_.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:F(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>d.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>d.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const he=e=>d.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function ve(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));d.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function ke(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=d.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[F({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:f.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:he(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>x('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Oe??{},app:{...Oe?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Oe?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Ie??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Ie=t.feature_flags??{},Oe=t.settings??{};const a=t.settings?.app?.restaurant;return a?F({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}}):null},apply:t=>{const a=t[0];a&&(d.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?{...a.restaurant,settings:{...a.restaurant.settings,games:a.games}}:t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&f.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&ve(e,a.events))},subscribe:e=>{const t=d.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=f.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Ie=null,Oe=null;const Re=()=>new Date(Date.now()-2592e6).toISOString(),De=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ie.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Me=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>oe.get(e));return 2===t.length&&t[0]&&t[1]?(0,k.dmId)(t[0],t[1]):null},xe=()=>D.getState().perms.includes('*');function Ae(){const e=()=>D.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>h.useOwner.getState().chat.filter(e=>(0,_.isUuid)(e.id)).map(e=>F({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!De(t.ch)&&(t.from===e()||xe()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===D.getState().kind,filter:e=>e.gte('created_at',Re()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Re(),toRow:(e,t)=>{const a=De(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ie.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Me(String(e.channel));if(!t)return null;const a=e.from_staff?oe.get(String(e.from_staff)):'system';return a?F({id:String(e.id),ch:t,from:a,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>h.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),l=t.filter(e=>!d.has(e.id)).map(e=>({...e,reactions:{},seenBy:e.from===i?[e.from]:[]}));return{chat:l.length?[...o,...l].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=t.from_staff?oe.get(String(t.from_staff)):'system',n=Me(String(t.channel)),r=e();if(!n||!r||s===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const i=h.useOwner.getState();if(!(i.chatMuted[r]??[]).includes(n)&&(0,k.inChannel)(n,i.staff.find(e=>e.id===r))&&(0,I.soundAllowed)())try{(0,I.chime)('soft')}catch{}}}}async function Ue(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([R().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&n.kv.get('chat:ok',!1):(n.kv.set('chat:ok',!0),!0)}catch{return n.kv.get('chat:ok',!1)}}const Ce='pair:v1',Te='staff:v1';async function Ee(){T();const{data:e}=await R().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await R().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}M({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function je(){if(!(0,a.isSupabaseConfigured)())return!1;try{return await Ee(),!0}catch{return!1}}const Ke=async(e,t={})=>{const{data:a,error:s}=await R().rpc(e,t);if(s)throw s;return a};let $e=null;async function Ne(){for(const e of j)try{e()}catch{}j=[],E.forEach(e=>e.stop()),E=[],$e&&(clearInterval($e),$e=null)}async function Pe(){await Ne(),await Fe()}let qe=u.VENUE_RID;async function Fe(){const e=qe;try{if(M({mode:'connecting'}),await i.mutationQueue.load(),'customer'===U)return void await Ge(e);const t=await n.kv.get(Ce,null),a=await n.kv.get(Te,null),{data:r}=await R().auth.getSession(),o='display'===U?t:a;if(!r.session||!o)return void M({mode:'display'===U?'unpaired':'signin',perms:[]});let d=[];try{const e=(await Ke('whoami')??[]).filter(e=>e.venue_id===o.venueId);if(!e.length)return'display'===U?await n.kv.remove(Ce):await n.kv.remove(Te),void M({mode:'display'===U?'unpaired':'signin',perms:[],message:'display'===U?'This display was unpaired by a manager.':'Open your invite link again to connect.'});d=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===o.kind&&o.canWrite&&d.push('device.write')}catch(e){(0,s.isOnline)()&&!/fetch|network/i.test(String(e?.message))||M({mode:'offline'}),d=D.getState().perms}M({venueId:o.venueId,venueSlug:o.venueSlug,venueName:o.venueName,kind:o.kind,role:o.role,staffRef:o.staffRef,staffUuid:o.staffUuid,perms:d}),await Be(o.venueId,e,o.kind)}catch(e){M({mode:'local',lastError:String(e?.message??e)})}}const We=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages']);async function Be(e,t,a){await ze(t),j.push(ot(e));try{const{data:t}=await R().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])de.set(e.key,e.id),le.set(e.id,e.key)}catch{}const n=[ke(t),{name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>h.useOwner.getState().staff.map(fe),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>x('staff.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,external_ref:e.id,display_name:e.name,job_title:e.job||null,department:e.dept||null,active:e.active,...de.get(ue(e))?{role_id:de.get(ue(e))}:{}}),fromRow:e=>e.external_ref?(ie.set(String(e.external_ref),String(e.id)),oe.set(String(e.id),String(e.external_ref)),st.set(String(e.external_ref),e.avatar_path??null),F({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',...ce(le.get(String(e.role_id)))})):null,apply:e=>h.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{it()},onRemote:()=>{it()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=h.useOwner.getState(),t=w.useSetup.getState().sites[qe]?.staffGrade??{};return e.staff.filter(e=>ie.has(e.id)).map(a=>F({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>oe.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ie.has(e.id),writable:()=>x('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ie.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=oe.get(String(e.staff_id));return t?F({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>h.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=w.useSetup.getState().sites[qe],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&w.useSetup.getState().patch(qe,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=h.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=w.useSetup.subscribe((t,a)=>{t.sites[qe]?.staffGrade!==a.sites[qe]?.staffGrade&&e()});return()=>{t(),a()}}},W(t,!1),W(t,!0),Q(t),L(t),B(t),H(t),z(t),V(t),re(t),{name:'supplier_directory',table:'suppliers',list:()=>h.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,_.isUuid)(e.id),writable:()=>x('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:F(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>h.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>h.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,_.isUuid)(e.id)&&(0,_.isUuid)(e.supplierId),writable:()=>x('suppliers.order')||x('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:F(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>h.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>h.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},Y(t),et(t)];x('wages.view')&&n.push(tt(t)),'staff'===a&&(n.push(ge(),Se(),we(),be(t)),ye(e));const r='staff'===a&&await Ue();v.useChatSync.setState({synced:r,checked:!0}),j.push(()=>v.useChatSync.setState({synced:!1})),r&&n.push(Ae(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(k.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>oe.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ie.has(e.id),writable:()=>x('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ie.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ie.get(e.id),include:e.include}),fromRow:e=>{const t=oe.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>k.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>k.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),'device'===a&&n.push(ge(),Se());const d={onActivity:()=>M({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>M({lastError:`${e}: ${t}`})};E=n.map(t=>new o.EntityBridge(t,e,d)),await Promise.all(E.map(e=>e.start()));const l=async()=>{let e=0;for(const[t,a]of E.entries()){const s='chat'===n[t]?.name;try{await a.read(),e++,s&&v.useChatSync.getState().error&&v.useChatSync.setState({error:void 0})}catch(e){const t=String(e?.message??e);if((s||/fetch|network|Failed/i.test(t))&&v.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(e?(M({mode:(0,s.isOnline)()?'live':'offline',lastSyncAt:(new Date).toISOString()}),i.mutationQueue.flush()):M({mode:'offline'}),!x('wages.view')){const e=D.getState().staffRef;h.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await l();const u=new Map;for(const e of E)u.set(e.spec.table,[...u.get(e.spec.table)??[],e]);const c=[...u.keys()].filter(e=>We.has(e)).map(e=>({table:e,venueColumn:u.get(e)[0].spec.venueColumn}));let f=!1;const p=(0,o.venueChannel)(e,c,(e,t,a)=>{for(const s of u.get(e)??[])s.remote(t,a);M({lastSyncAt:(new Date).toISOString()})},e=>{M({realtime:e}),'SUBSCRIBED'===e?(f&&l(),f=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(f=!0)});j.push(()=>{R().removeChannel(p)}),$e=setInterval(()=>{l()},6e4),j.push((0,s.onConnectivity)(e=>{e&&l()}))}'undefined'!=typeof window&&(window.__ccSync=()=>({...D.getState(),queue:i.mutationQueue.pending.map(e=>e.table),failedTables:i.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}));const Qe='guest:sent:v1';async function Ge(e){M({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ke('public_venue',{p_venue_slug:e}))?.[0];if(t){M({venueId:t.id,venueName:t.name}),await ze(e);const a=t.app?.restaurant;a&&d.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?{...a,id:e}:t)})),ve(e,t.app?.events)}const a=(await Ke('public_menu',{p_venue_slug:e})??[]).map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&d.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}}),M({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{M({mode:(0,s.isOnline)()?'local':'offline'})}let t=await n.kv.get(Qe,{}),a=!1;const r=new Date(Date.now()-1728e5).toISOString(),i=async()=>{if(!a){a=!0;try{const a=d.useStore.getState(),s=a.bookings.filter(a=>a.restaurantId===e&&(0,_.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=r),i=a.orders.filter(a=>a.restaurantId===e&&(0,_.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=r&&'table'!==a.type);if(s.length||i.length){if(!await je())return;for(const a of s)try{const s=(await Ke('guest_create_booking',{p_venue_slug:e,p_booking:{...F(a),allergies:q(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&d.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},M({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ke('guest_create_takeaway',{p_venue_slug:e,p_order:{...F(a),allergies:q(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},M({lastError:`Order: ${e?.message}`}))}await n.kv.set(Qe,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ke('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await n.kv.set(Qe,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ke('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));d.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=a.doc??{},n={...e,status:a.status??e.status,readyBy:s.readyBy??e.readyBy,accepted:s.accepted??e.accepted};return Le(n)===Le(e)?e:n})})),M({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{M({mode:(0,s.isOnline)()?D.getState().mode:'offline'})}finally{a=!1}}};j.push(d.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{i()},200)})),$e=setInterval(()=>{i()},15e3),i()}const Le=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),He={bridges:()=>E,restart:Pe},Je='golive:v1:';async function ze(e){'live'!==d.useStore.getState().clock.mode&&d.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),await n.kv.get(Je+e,!1)||await Ye(e),await n.kv.get(Ve+e,!1)||(Xe(e),await n.kv.set(Ve+e,!0))}const Ve='golive:v2:';function Xe(e){const t=e=>JSON.stringify(e).includes('(example)');d.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),h.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ye(e){const t=t=>t.restaurantId===e&&!(0,_.isUuid)(t.id),a=e=>JSON.stringify(e).includes('(example)');d.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),c.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,_.isUuid)(t.id))})),f.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),h.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,_.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,_.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,_.isUuid)(e.id)),leave:[],swaps:[]}));try{y.useKitchen.setState(e=>({temps:e.temps.filter(e=>!a(e)),orders:e.orders.filter(e=>!a(e))}))}catch{}try{b.useSafety.setState(e=>({accidents:e.accidents.filter(e=>!String(e.id).startsWith('acc-ex')&&!a(e))}))}catch{}await n.kv.set(Je+e,!0)}const Ze=(e,t)=>F({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function et(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(f.useFloor.getState().live[e]??{}).map(([e,t])=>Ze(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===D.getState().kind||x('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:D.getState().staffRef??U}),fromRow:e=>Ze(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>f.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>f.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function tt(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(w.useSetup.getState().sites[e]?.grades??w.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>x('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=w.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));w.useSetup.getState().patch(e,{grades:r})},subscribe:t=>w.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const at='staff-avatars',st=new Map;let nt=!1;const rt=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function it(){if(!nt){nt=!0;try{for(const[e,t]of st){const a=S.useAvatars.getState().photos[e];if(!t){a?.path&&S.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===D.getState().staffRef)continue;const{data:s,error:n}=await R().storage.from(at).download(t);if(n||!s)continue;const r=await rt(s);r.startsWith('data:image/')&&S.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{nt=!1}}}function ot(e){const t=async()=>{const t=D.getState().staffRef,a=t?ie.get(t)??D.getState().staffUuid:void 0;if(!t||!a||'staff'!==D.getState().kind)return;const s=S.useAvatars.getState().photos[t];try{const n=st.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&R().storage.from(at).remove([t]).catch(()=>{})};if(!s)return void(n&&(await Ke('set_staff_avatar',{p_staff_ref:t,p_path:null}),st.set(t,null),r(n)));if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void M({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:l}=await R().storage.from(at).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(l)throw l;await Ke('set_staff_avatar',{p_staff_ref:t,p_path:d}),st.set(t,d),n!==d&&r(n),S.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){M({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:S.useAvatars.getState().photos},s=S.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),x('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==D.getState().staffRef){const e=s[t].path;st.set(t,null),Ke('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>R().storage.from(at).remove([e])).catch(()=>{})}});return t(),s}const dt=new Map,lt=(0,e.create)(()=>({n:0}))},798,[974,1037,1080,1082,1081,1083,1085,1086,855,787,856,801,802,1034,1023,1087,1089,1090,1091,977,813,920,1092,981,880,1017]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"colours",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"fonts",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"font",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radius",{enumerable:!0,get:function(){return l}});const t={bg:'#0B0B0B',surface:'#141414',surface2:'#1D1C1A',border:'#34302A',gold:'#CFA45F',goldLight:'#E2C489',goldTint:'#2A2216',goldMuted:'#BFA06C',hairline:'rgba(255,255,255,0.09)',tile:'#18171A',tilePressed:'#211F1C',accentBg:'rgba(207,164,95,0.13)',accentBorder:'rgba(207,164,95,0.38)',text:'#F5F1E8',muted:'#B8B0A0',onGold:'#0B0B0B',red:'#FF6B5E',redBg:'#4A1310',redSolid:'#C62F22',amber:'#FFB547',amberBg:'#3F2C05',green:'#7BD88F',greenBg:'#12301A',blue:'#8EC5FF',blueBg:'#12263D'},n={regular:'Poppins_400Regular',medium:'Poppins_500Medium',semibold:'Poppins_600SemiBold',bold:'Poppins_700Bold'},o={small:14,body:16,large:18,title:22,hero:30},l={s:6,m:10,l:16}},799,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.templatesFor=function(t){const n={...r.DEFAULT_TEMPLATES};for(const o of Object.keys(r.DEFAULT_TEMPLATES))n[o]={...r.DEFAULT_TEMPLATES[o],...t?.[o]??{}};return n},e.composeBooking=function(t,n,o,c,u){if(n.walkIn)return[];return s(t,'booking-confirmation'===t?'booking':'booking-request'===t?'request':'declined',(0,r.bookingVars)(n,o),{phone:n.phone,email:n.email,name:n.name},{refType:'booking',refId:n.id,ref:n.ref},o,c,u)},e.composeOrder=function(t,n,o,c){return'takeaway'!==t.type?[]:s('order-confirmation','order',(0,r.orderVars)(t,n),{phone:t.phone,email:t.email,name:t.customerName},{refType:'order',refId:t.id,ref:t.ref},n,o,c)},e.deliverQueued=async function(r,n){if(!(0,t.isLive)())return;const o=(0,t.activeProvider)();for(const t of r){const r=await o.deliver(t);n(t.id,r.ok?{status:'sent'}:{status:'failed',error:r.error})}},e.statusLabel=function(t){const r='sms'===t.channel?'Text':'Email';return'preview'===t.status?`${r}: Ready (preview mode)`:'queued'===t.status?`${r}: Sending\u2026`:'sent'===t.status?`${r} sent`:`${r}: Not sent (failed)`},Object.defineProperty(e,"PREVIEW_BANNER",{enumerable:!0,get:function(){return c}});var t=_r(d[0]);Object.keys(t).forEach(function(r){'default'===r||Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})});var r=_r(d[1]);Object.keys(r).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})});var n=_r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});const o=()=>`msg-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-4)}`;function s(s,c,u,l,f,m,p,b){const y=[],v=(0,t.isLive)()?'queued':'preview',h=(0,t.activeProvider)().id,k=(0,n.ukPhone)(l.phone);if(k.ok&&y.push({id:o(),restaurantId:m.id,at:b,channel:'sms',kind:s,to:k.pretty,toName:l.name,body:(0,r.toGsm)((0,r.fill)(p[c].sms,u.sms)),...f,status:v,provider:h}),l.email?.trim()){const t=(0,r.fillEmailText)(p[c].body,u.email),n=(0,r.fill)(p[c].subject,u.email);y.push({id:o(),restaurantId:m.id,at:b,channel:'email',kind:s,to:l.email.trim(),toName:l.name,subject:n,body:t,html:(0,r.emailHtml)(t,{venue:m.name,preheader:n}),...f,status:v,provider:h})}return y}const c='Preview mode, not sent yet. Connect a text and email service to go live.'},800,[1018,1019,1020]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BLOCK_REASONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return b}}),_e.closedAreasAt=function(e,t,n,o){const s=(0,c.toMins)(o);return new Set(b(e,t,n).filter(e=>s>=(0,c.toMins)(e.from)&&s<(0,c.toMins)(e.to)).map(e=>e.areaId))},_e.blockAt=m,_e.currentBlocks=function(e,t,n,o){return e.filter(e=>e.rid===t&&(e.date>n||e.date===n&&(0,c.toMins)(e.to)>(0,c.toMins)(o))).sort((e,t)=>e.date===t.date?(0,c.toMins)(e.from)-(0,c.toMins)(t.from):e.date({blocks:[],add:t=>{const n={...t,id:(0,o.uuid)(),createdAt:(new Date).toISOString()};return e(e=>({blocks:[...e.blocks,n]})),n},remove:t=>e(e=>({blocks:e.blocks.filter(e=>e.id!==t)}))}),{name:'covercharge-blocks-v1',storage:(0,a.createJSONStorage)(()=>n.default)})),l=(e,t,n)=>e.filter(e=>e.rid===t&&e.date===n&&!e.areaId).sort((e,t)=>(0,c.toMins)(e.from)-(0,c.toMins)(t.from)),b=(e,t,n)=>e.filter(e=>e.rid===t&&e.date===n&&!!e.areaId).sort((e,t)=>(0,c.toMins)(e.from)-(0,c.toMins)(t.from));function m(e,t,n,o){const s=(0,c.toMins)(o);return l(e,t,n).find(e=>s>=(0,c.toMins)(e.from)&&s<(0,c.toMins)(e.to))}const k=(e,t,n,o)=>m(e,t,n,o),M=e=>e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,O=(e,t)=>{const n=f(e=>e.blocks);return l(n,e,t)}},801,[975,920,974,976,796]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_SETTINGS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return O}});var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},a=r(d[1]),s=r(d[2]),l=r(d[3]);Object.keys(l).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return l[e]}})});const o={privacy:!0,idleMins:2,pinOn:!1,pin:'2580',tonightCards:!0},c=e=>'anchorage'===e?(0,l.anchoragePlan)():(0,l.starterPlan)(),u=(0,a.create)()((0,s.persist)((e,n)=>{const t=e=>n().plans[e]??c(e);return{plans:{anchorage:(0,l.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,a,s)=>{const l=t(n);e(e=>({plans:{...e.plans,[n]:{...l,tables:l.tables.map(e=>e.id===a?{...e,...s}:e)}}}))},addTable:(n,a)=>{const s=t(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,a]}}}))},removeTable:(n,a)=>{const s=t(n),l=s.tables.find(e=>e.id===a);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==a),joins:s.joins.filter(e=>!l||!e.tables.includes(l.name))}}}))},setLive:(n,t,a)=>e(e=>({live:{...e.live,[n]:{...e.live[n]??{},[t]:{...e.live[n]?.[t]??{},...a}}}})),setSettings:(n,t)=>e(e=>({settings:{...e.settings,[n]:{...o,...e.settings[n]??{},...t}}})),logSms:(n,t,a)=>e(e=>{return{smsLog:[{id:(s='sms',`${s}-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`),rid:n,at:t,text:a},...e.smsLog].slice(0,50)};var s}),resetPlan:n=>e(e=>({plans:{...e.plans,[n]:c(n)}}))}},{name:'covercharge-floor-v1',version:4,storage:(0,s.createJSONStorage)(()=>t.default),migrate:(e,n)=>{const t=e??{};if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,l.anchoragePlan)():(0,l.normalisePlan)(a);return e.anchorage=(0,l.anchoragePlan)(),{...t,plans:e,live:{}}}if(n<3)return{...t,plans:{...t.plans??{},anchorage:(0,l.anchoragePlan)()}};if(n<4){const e=t.plans?.anchorage;if(e)return{...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}}}return t}})),p=e=>u(n=>n.plans[e])??b(e),f={};function b(e){return f[e]??=c(e)}const P=e=>{const n=u(n=>n.settings[e]);return n?{...o,...n}:o},h=e=>u.getState().plans[e]??b(e),O=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[]},802,[975,974,976,895]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STATUS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return o}}),e.clashes=function(a,s=90){const n=new Set,i=a.filter(t=>d(t)&&t.table);for(let a=0;a(0,t.tablesOf)(u.table).includes(a))&&(l(c)t.date===b(d));for(const s of a.tables){const a=i[s.name]??{},b=y.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),F=b.find(t=>'seated'===t.status),O=b.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>f(d,t)>=-20),T=O?Math.round(f(d,O)):void 0,v=n.find(t=>'table'===t.type&&t.tableNo===s.name&&!['closed','cancelled','collected'].includes(t.status));let S='free';a.blocked?S='blocked':F?S=a.stage??'seated':p?.has(s.areaId)&&!v?S='blocked':a.dirty?S='dirty':v?S=a.stage??'seated':O&&void 0!==T&&T<=45&&(S='soon');const A=F,B=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:O?.tags?.[0]);h[s.name]={table:s,status:S,booking:A,next:O,nextIn:T,covers:A?.partySize??0,orderOnly:!A&&!!v,note:a.note,seatedMins:A?Math.max(0,Math.round((d.getTime()-l(A).getTime())/6e4)):void 0,freeAt:A?o(A,u):void 0,allergy:!!(A?.allergies.length||A?.allergyNote||!A&&(O?.allergies.length||O?.allergyNote)||v?.allergies.length),vip:B,occasion:A?.occasion??(A?void 0:O?.occasion??c(O?.notes))??c(A?.notes)}}return h},Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return p}}),e.suggestTable=function(a,s,n,i,c,u,f=90,b,h){const y=[...a.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...a.joins.map(t=>{const s=a.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:s.reduce((t,a)=>t+a.maxSeats,0),min:s.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>p(a,t,h))),F=c.getTime()+6e4*u;let O=null;for(const a of y){if(a.seats['blocked'].includes(n[t]?.status)))continue;const u=!!n&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(n[t]?.status)),p=s.filter(s=>s.id!==b&&d(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&l(s).getTime()c.getTime()).length,h=(u?1e3:0)+100*p+10*(a.seats-i)+(i({name:t.name,seats:t.maxSeats,parts:[t.name]})),...a.joins.map(t=>({name:t.tables.join('+'),seats:a.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=n&&t.parts.every(t=>p(a,t,f)));return y.filter(a=>!s.some(s=>s.id!==b&&d(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&l(s).getTime()i.getTime())).sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length).map(t=>({table:t.name,seats:t.seats,area:a.areas.find(s=>s.id===a.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]);const a={free:{label:'Free',colour:'#2F7D45',fg:'#E7FBEA'},soon:{label:'Reserved soon',colour:'#3C78B5',fg:'#EAF4FF'},seated:{label:'Seated',colour:'#CFA45F',fg:'#0B0B0B'},mains:{label:'Mains',colour:'#E08A2E',fg:'#0B0B0B'},dessert:{label:'Dessert',colour:'#A77BD0',fg:'#0B0B0B'},bill:{label:'Bill requested',colour:'#D9473A',fg:'#FFFFFF'},dirty:{label:'Needs clearing',colour:'#7A6F5E',fg:'#FFFFFF'},blocked:{label:'Blocked',colour:'#3A3A3A',fg:'#CFCFCF'}},s=['seated','mains','dessert','bill'],n=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),l=t=>'seated'===t.status&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),i=(t,a=90)=>t.durationMins??n(t.partySize,a),o=(t,a=90)=>new Date(l(t).getTime()+6e4*i(t,a)),d=t=>!['cancelled','noshow','finished'].includes(t.status);const c=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,u={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc8d',celebration:'\ud83e\udd42'},f=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,b=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,p=(t,a,s)=>{const n=t.tables.find(t=>t.name===a);if(!n)return!1;const l=t.areas.find(t=>t.id===n.areaId);return!(s?.dog&&!(void 0!==n.dogOk?n.dogOk:l?.dogs))&&!s?.closed?.has(n.areaId)}},803,[802]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"emptyNeeds",{enumerable:!0,get:function(){return j}}),_e.needsMissing=function(e,l=[]){const s=[];null===e.allergy?s.push('Answer the allergy question first'):'yes'!==e.allergy||e.allergens.length||l.length||e.allergyNote.trim()||s.push('Pick the allergens or describe them');null===e.dog&&s.push('Say whether a dog is coming');return s},_e.needsPatch=function(e,l=[]){const s='yes'===e.allergy?e.allergens.filter(e=>!l.some(l=>l.allergen===e)).map(l=>({allergen:l,severity:e.severity})):[],t=Object.entries(e.holds).filter(([,e])=>e>0).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l})),a=e.dog?Math.max(1,e.dogs):0,n={...e.wheelchair?{wheelchair:e.wheelchair}:{},...e.stepFree?{stepFree:!0}:{},...e.toilet?{toilet:!0}:{},...e.assistDog?{assistDog:!0}:{},...e.accessNote.trim()?{note:e.accessNote.trim()}:{}},r={...e.vegan?{vegan:e.vegan}:{},...e.vegetarian?{vegetarian:e.vegetarian}:{}};return{allergies:[...l,...s],allergyNone:'none'===e.allergy&&!l.length||void 0,allergyPeople:'yes'===e.allergy?e.allergyPeople:void 0,allergyNote:'yes'===e.allergy&&e.allergyNote.trim()?e.allergyNote.trim():void 0,dog:a>0,dogs:a||void 0,access:Object.keys(n).length?n:void 0,diet:Object.keys(r).length?r:void 0,holds:t.length?t:void 0,tableReq:e.tableReq.length?e.tableReq:void 0}},_e.FirstQuestions=function({rid:e,value:t,onChange:n,party:r,audience:i,profile:y=[]}){const m=e=>n({...t,...e}),x=(0,u.usePlan)(e),[j,w]=(0,s.useState)(!1),R=(0,l.dogQuestionOn)((0,h.useRestaurant)(e));(0,s.useEffect)(()=>{R||null!==t.dog||n({...t,dog:!1})},[R,t.dog]);const C=j?p.ALLERGENS:p.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||t.allergens.includes(e.id)),M=[...y.map(e=>e.allergen),...t.allergens],q=(0,b.dogSetUp)(x);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(v,{tone:"red",testID:"q-allergens",children:[(0,f.jsx)(k,{sub:'guest'===i?'We ask everyone first, so the kitchen can keep you safe.':'Ask every guest first. It goes to the kitchen in red.',children:"\u26a0\ufe0f Does anyone in the party have a food allergy?"}),y.length?(0,f.jsx)(c.Row,{wrap:!0,gap:6,children:y.map(e=>(0,f.jsx)(c.Badge,{kind:"red",label:`${p.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,f.jsxs)(c.Row,{gap:8,children:[(0,f.jsx)(a.default,{style:{flex:1},children:(0,f.jsx)(c.Chip,{label:"No allergies",selected:'none'===t.allergy,onPress:()=>m({allergy:'none',allergens:[]})})}),(0,f.jsx)(a.default,{style:{flex:1},children:(0,f.jsx)(c.Chip,{label:"Yes, allergies",selected:'yes'===t.allergy,onPress:()=>m({allergy:'yes'})})})]}),'none'===t.allergy&&y.length?(0,f.jsx)(c.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===t.allergy?(0,f.jsxs)(a.default,{style:{gap:10},testID:"allergen-picker",children:[(0,f.jsx)(c.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,f.jsxs)(c.Row,{wrap:!0,gap:6,children:[C.map(e=>(0,f.jsx)(c.Chip,{label:e.short,selected:t.allergens.includes(e.id)||y.some(l=>l.allergen===e.id),disabled:y.some(l=>l.allergen===e.id),onPress:()=>m({allergens:t.allergens.includes(e.id)?t.allergens.filter(l=>l!==e.id):[...t.allergens,e.id]})},e.id)),j?null:(0,f.jsx)(c.Chip,{label:"All 14\u2026",onPress:()=>w(!0)})]}),(0,f.jsx)(c.T,{size:14,weight:"semibold",children:"How serious?"}),(0,f.jsx)(c.Row,{wrap:!0,gap:6,children:p.SEVERITIES.map(e=>(0,f.jsx)(c.Chip,{label:e.label,selected:t.severity===e.id,onPress:()=>m({severity:e.id})},e.id))}),(0,f.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(c.T,{size:14,children:"How many people with allergies?"}),(0,f.jsx)(c.Stepper,{value:Math.min(t.allergyPeople,r),onChange:e=>m({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,f.jsx)(c.Field,{label:"Anything else the kitchen should know? (optional)",value:t.allergyNote,onChangeText:e=>m({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),M.length?(0,f.jsx)(o.MenuAllergyCheck,{rid:e,allergens:M,audience:i}):null]}):null]}),R?(0,f.jsxs)(v,{tone:"gold",testID:"q-dogs",children:[(0,f.jsx)(k,{sub:q?'Well-behaved dogs are welcome at our dog-friendly tables.':'staff'===i?'Dog-friendly tables aren\u2019t marked yet (Managers \u203a Booking options), so any table is offered for now.':void 0,children:"\ud83d\udc15 Are you bringing a dog?"}),(0,f.jsxs)(c.Row,{gap:8,children:[(0,f.jsx)(a.default,{style:{flex:1},children:(0,f.jsx)(c.Chip,{label:"No",selected:!1===t.dog,onPress:()=>m({dog:!1})})}),(0,f.jsx)(a.default,{style:{flex:1},children:(0,f.jsx)(c.Chip,{label:"Yes",selected:!0===t.dog,onPress:()=>m({dog:!0,dogs:Math.max(1,t.dogs)})})})]}),t.dog?(0,f.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(c.T,{size:14,children:"How many dogs?"}),(0,f.jsx)(c.Stepper,{value:t.dogs,onChange:e=>m({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=w,_e.MoreQuestions=function({rid:e,r:t,value:n,onChange:r,party:i,date:o,time:y,today:p,bookings:x,audience:j,showTables:C}){const M=e=>r({...n,...e}),q=t.settings,S=(0,h.useMenu)(e),P=(0,s.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),T=w(e,t,o,p,x,j),D=e=>n.holds[e]??0,N=(0,b.stockNeed)({holds:Object.entries(n.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},T.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(N[e.key]??0)-D(l)*e.qty;return Math.floor(((T.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=D(e),i=t<=0&&0===r;return(0,f.jsxs)(a.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,f.jsxs)(a.default,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(c.T,{weight:"semibold",children:l}),(0,f.jsx)(c.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,f.jsx)(c.Badge,{kind:"neutral",label:"Unavailable"}):(0,f.jsx)(c.Stepper,{value:r,onChange:l=>M({holds:{...n.holds,[e]:Math.max(0,Math.min(l,Math.max(r,t)))}}),min:0,max:Math.max(r,Math.min(10,t)),label:l})]},e)},O=T.items.length>0||!1!==q.reserveStock&&T.stock.length>0,A=(0,u.usePlan)(e);return(0,f.jsxs)(f.Fragment,{children:[(0,l.accessQuestionOn)(t)?(0,f.jsxs)(v,{tone:"plain",testID:"q-access",children:[(0,f.jsx)(k,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,f.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(c.T,{size:14,children:"Wheelchair users"}),(0,f.jsx)(c.Stepper,{value:n.wheelchair,onChange:e=>M({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,f.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(c.Chip,{label:"Step-free access",selected:n.stepFree,onPress:()=>M({stepFree:!n.stepFree})}),(0,f.jsx)(c.Chip,{label:"Accessible toilet",selected:n.toilet,onPress:()=>M({toilet:!n.toilet})}),(0,f.jsx)(c.Chip,{label:"Assistance dog",selected:n.assistDog,onPress:()=>M({assistDog:!n.assistDog})})]}),(0,f.jsx)(c.Field,{label:"Anything else? (optional)",value:n.accessNote,onChangeText:e=>M({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),q.accessStatement?.trim()?(0,f.jsx)(c.Muted,{children:q.accessStatement.trim()}):null]}):null,(0,l.dietQuestionOn)(t)?(0,f.jsxs)(v,{tone:"plain",testID:"q-veg",children:[(0,f.jsx)(k,{sub:"We\u2019d love to look after you. Optional.",children:"\ud83c\udf31 Any vegans or vegetarians?"}),(0,f.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(c.T,{size:14,children:"Vegan"}),(0,f.jsx)(c.Stepper,{value:n.vegan,onChange:e=>M({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,f.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(c.T,{size:14,children:"Vegetarian"}),(0,f.jsx)(c.Stepper,{value:n.vegetarian,onChange:e=>M({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==q.vegTeaser&&P.length&&(n.vegan||n.vegetarian)?(0,f.jsxs)(c.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,O?(0,f.jsxs)(v,{tone:"gold",testID:"q-reserve",children:[(0,f.jsx)(k,{sub:T.known?'Held for you from today\u2019s count.':o>p||'guest'===j?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),T.items.map(e=>I(`item:${e.id}`,`${e.name} \xb7 ${(0,m.gbp)(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${T.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==q.reserveStock?T.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,T.known?`${T.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===j&&T.known?(0,f.jsxs)(c.Muted,{children:["Today: ",T.stock.map(e=>`${T.free[e.key]} ${e.plural.toLowerCase()} free (${T.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,C&&!1!==q.tableRequests&&A.tables.length?(0,f.jsx)(R,{rid:e,value:n,onChange:r,party:i,hide:q.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,b.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return b.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=(e=t)&&e.__esModule?e:{default:e},n=_r(d[3]),r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),y=_r(d[10]),p=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]);const j=()=>({allergy:null,allergens:[],severity:'allergy',allergyPeople:1,allergyNote:'',dog:null,dogs:1,wheelchair:0,stepFree:!1,toilet:!1,assistDog:!1,accessNote:'',vegan:0,vegetarian:0,holds:{},tableReq:[]});const v=({children:e,tone:l,testID:s})=>(0,f.jsx)(a.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?x.colours.red:'gold'===l?x.colours.accentBorder:x.colours.hairline,backgroundColor:'red'===l?'#1E1110':x.colours.surface},children:e}),k=({children:e,sub:l})=>(0,f.jsxs)(a.default,{style:{gap:2},children:[(0,f.jsx)(c.T,{weight:"semibold",size:17,children:e}),l?(0,f.jsx)(c.Muted,{children:l}):null]});function w(e,l,s,t,a,r,i){const o=(0,b.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,n.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,b.reservedOn)(a,s,o,i),m=s===t&&('staff'===r||u),x={};for(const e of c)x[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:x,reserved:p,known:m}}function R({rid:e,value:l,onChange:t,party:n,hide:o}){const h=(0,u.usePlan)(e),y=h.areas.filter(e=>h.tables.some(l=>l.areaId===e.id&&!o.includes(l.name))),[p,m]=(0,s.useState)(y[0]?.id??''),j=l.dog?l.dogs:0,w=e=>o.includes(e)?'Not bookable':(0,b.tableBlockReason)(h,e,n,j,l.wheelchair>0||l.stepFree),R=Object.fromEntries(h.tables.map(e=>[e.name,{table:e,status:w(e.name)?'blocked':'free',covers:0,allergy:!1}])),C=e=>{if(w(e))return;const s=l.tableReq.includes(e)?l.tableReq.filter(l=>l!==e):[...l.tableReq,e].slice(-2);t({...l,tableReq:s})},M=h.tables.filter(e=>e.areaId===p&&!o.includes(e.name));return(0,f.jsxs)(v,{tone:"plain",testID:"q-table",children:[(0,f.jsx)(k,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,f.jsx)(r.AreaTabs,{plan:h,area:p,onPick:m}):null,(0,f.jsx)(a.default,{style:{borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:x.colours.hairline},children:(0,f.jsx)(i.FloorCanvas,{plan:h,areaId:p,mode:"live",view:R,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:l.tableReq,onTap:e=>C(e.name)})}),(0,f.jsx)(c.Row,{wrap:!0,gap:6,children:M.map(e=>{const s=w(e.name),t=l.tableReq.indexOf(e.name);return(0,f.jsx)(c.Chip,{label:`T${e.name}`,sub:s||(0===t?'1st choice':1===t?'2nd choice':`${e.maxSeats} seats`),selected:t>=0,disabled:!!s,onPress:()=>C(e.name)},e.name)})}),l.tableReq.length?(0,f.jsxs)(c.T,{size:14,colour:x.colours.goldLight,children:["Requested: ",l.tableReq.map((e,l)=>`T${e}${l?' (2nd choice)':''}`).join(', ')]}):(0,f.jsx)(c.Muted,{children:"Tap a table; tap another for a second choice."})]})}},804,[789,12,109,857,886,885,1148,791,797,802,1034,792,794,805,799,6]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ACTIVE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ANCHORAGE_RESERVABLES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"reservablesOf",{enumerable:!0,get:function(){return i}}),e.stockNeed=s,e.reservedOn=a,e.usedOn=function(t,r,n){const o={};for(const i of t)if(i.date===r)for(const t of i.holds??[])if(t.served)for(const[r,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},n)))o[r]=(o[r]??0)+a;return o},e.heldSummary=function(t,r,o){const i={},s={};for(const o of t)if(o.date===r&&n(o))for(const t of o.holds??[])t.served||('item'===t.kind?i[t.id]=(i[t.id]??0)+t.qty:s[t.id]=(s[t.id]??0)+t.qty);return{platters:Object.values(i).reduce((t,r)=>t+r,0),byItem:i,single:s,stock:a(t,r,o)}},e.holdsText=function(t,r,n){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?l(r.find(r=>r.id===t.id)?.name??'Reserved item'):n.find(r=>r.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return p}}),e.accessText=function(t){const r=t.access;return r?[r.wheelchair?`${r.wheelchair} wheelchair user${1===r.wheelchair?'':'s'}`:'',r.stepFree?'step-free access':'',r.toilet?'accessible toilet':'',r.assistDog?'assistance dog':'',r.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,n,o,i,s){const a=t.tables.find(t=>t.name===n);return a?a.maxSeats0&&v(t)&&!(0,r.tableDogOk)(t,a)?'No dogs here':s&&O(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return A}}),e.coversToday=function(t,r){const o=t.filter(t=>t.date===r&&n(t)),i=o.filter(t=>'seated'===t.status||'finished'===t.status||!!t.seatedAt),s=o.filter(t=>!i.includes(t)&&('confirmed'===t.status||'pending'===t.status)),a=t=>t.reduce((t,r)=>t+r.partySize,0),l=t=>t.time<'16:00';return{done:a(i),toCome:a(s),total:a(i)+a(s),lunch:{done:a(i.filter(l)),toCome:a(s.filter(l))},dinner:{done:a(i.filter(t=>!l(t))),toCome:a(s.filter(t=>!l(t)))}}};var t=_r(d[0]),r=_r(d[1]);const n=t=>!['cancelled','noshow'].includes(t.status),o=[{id:'seafood-platter-2',name:'Seafood Platter for 2',price:16e3,description:'Whole crab and lobster with all the trimmings, for two to share.',uses:[{key:'crab',qty:1},{key:'lobster',qty:1}],active:!0}],i=t=>(t?.settings.reservables??('anchorage'===t?.id?o:[])).filter(t=>t.active);function s(t,r,n=!1){const o={};for(const i of t.holds??[])if(!i.served||n)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of r.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,r,o,i){const a={};for(const l of t)if(l.date===r&&n(l)&&'finished'!==l.status&&l.id!==i)for(const[t,r]of Object.entries(s(l,o)))a[t]=(a[t]??0)+r;return a}const l=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),c=t=>n(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,f=t=>n(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),b=r=>[r.allergies.map(r=>(0,t.allergenLabel)(r.allergen)).join(', '),r.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(r.allergyPeople?` (${r.allergyPeople} ${1===r.allergyPeople?'person':'people'})`:''),y=t=>t.dogs??(t.dog?1:0),p=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const h=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),O=t=>t.tables.some(t=>t.accessible),v=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),j=(t,r)=>r.split('+').every(r=>!!t.tables.find(t=>t.name===r.trim())?.accessible),P=(t,n)=>n.split('+').every(n=>{const o=t.tables.find(t=>t.name===n.trim());return!!o&&(0,r.tableDogOk)(t,o)}),k=(t,r,o,i)=>t.filter(t=>t.id!==i&&t.date===r&&t.time===o&&n(t)).reduce((t,r)=>t+y(r),0);const A=t=>t.replace(/\s*\(substitute day\)/gi,'').trim()},805,[792,895]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:l,declared:c}){return(0,o.jsxs)(n.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,o.jsx)(s.Badge,{label:"EXAMPLE DATA",kind:"amber"})]}),(0,o.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const d=l[e.id],u=c.find(l=>l.allergen===e.id),f='contains'===d?t.colours.redBg:'may'===d?t.colours.amberBg:t.colours.surface2,h='contains'===d?'#FFD9D4':'may'===d?'#FFE2A8':t.colours.muted;return(0,o.jsxs)(n.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:u?2:1,borderColor:u?t.colours.red:t.colours.border},children:[(0,o.jsx)(s.T,{size:14,weight:"medium",colour:d?h:t.colours.text,children:e.label}),(0,o.jsxs)(s.T,{size:13,colour:h,children:['contains'===d?'Contains':'may'===d?'May contain':'Not listed',u?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(u.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,o.jsxs)(s.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,o.jsx)(n.default,{testID:"allergen-signoff",children:(0,o.jsx)(s.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${d(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,o.jsx)(s.Muted,{children:"Example data in this prototype. Always tell staff about allergies when you order or arrive."})]})},_e.AllergenChips=function({map:e,declared:l}){const n=Object.entries(e);return n.length?(0,o.jsx)(s.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const t=l.some(l=>l.allergen===e);return(0,o.jsx)(s.Badge,{label:`${t?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:t?'contains'===n?'red':'amber':'neutral'},e)})}):(0,o.jsx)(s.Muted,{children:"No listed allergens (example data)"})},r(_d[0]);var e,l=r(_d[1]),n=(e=l)&&e.__esModule?e:{default:e},a=r(_d[2]),t=r(_d[3]),s=r(_d[4]),o=r(_d[5]);const d=e=>{const l=new Date(`${e.slice(0,10)}T12:00:00`);return isNaN(+l)?e:l.toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric'})}},806,[12,109,792,799,791,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BasketButton=function(){const s=(0,l.useBasket)().lines.reduce((e,s)=>e+s.qty,0);return s?(0,c.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Basket, ${s} items`,onPress:()=>e.router.push('/customer/basket'),style:{backgroundColor:u.colours.gold,borderRadius:999,paddingHorizontal:12,paddingVertical:6},children:(0,c.jsxs)(n.T,{weight:"semibold",colour:u.colours.onGold,size:14,children:["Basket \xb7 ",s]})}):null};var e=r(d[0]);r(d[1]);var s,t=r(d[2]),o=(s=t)&&s.__esModule?s:{default:s},l=r(d[3]),u=r(d[4]),n=r(d[5]),c=r(d[6])},807,[785,12,245,797,799,791,6]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setRecipeCardRepository=function(n){t=n,r.forEach(t=>t())},e.recipeCards=function(){if(!t)throw new Error('Recipe card repository not set up');return t},Object.defineProperty(e,"hasRecipeCards",{enumerable:!0,get:function(){return n}}),e.onRepositorySwap=function(t){return r.add(t),()=>{r.delete(t)}};let t=null;const r=new Set;const n=()=>!!t},808,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Stars=function({value:e,onChange:s,size:n=36}){return(0,c.jsx)(t.Row,{gap:6,children:[1,2,3,4,5].map(u=>(0,c.jsx)(l.default,{disabled:!s,accessibilityRole:"button",accessibilityLabel:`${u} star${u>1?'s':''}`,onPress:()=>s?.(u),hitSlop:4,children:(0,c.jsx)(t.T,{size:n,colour:u<=e?o.colours.gold:'#555',children:"\u2605"})},u))})},r(d[0]);var e,s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),c=r(d[4])},809,[12,245,799,791,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"LAUNCHER_LINE",{enumerable:!0,get:function(){return u}}),_e.LauncherLine=function(){return(0,s.jsx)(l.default,{style:{borderTopWidth:1,borderColor:t.colours.border,paddingTop:10,marginTop:4},children:(0,s.jsx)(n.Muted,{center:!0,children:u})})},_e.HubTile=function({icon:e,label:u,sub:c,onPress:b,badge:h}){return(0,s.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:u,onPress:b,style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,maxWidth:'31.5%',minWidth:96,backgroundColor:e?'#1d1a14':t.colours.surface,borderRadius:14,borderWidth:1,borderColor:t.colours.border,padding:10,gap:2,alignItems:'center'}),children:[(0,s.jsx)(n.T,{size:22,children:e}),(0,s.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:u}),c?(0,s.jsx)(n.T,{size:11,colour:t.colours.muted,center:!0,children:c}):null,h?(0,s.jsx)(l.default,{style:{position:'absolute',top:6,right:6,backgroundColor:t.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,s.jsx)(n.T,{size:10,weight:"bold",colour:t.colours.onGold,children:h})}):null]})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),n=r(d[3]),t=r(d[4]),s=r(d[5]);const u='Prototype \xb7 demo data, no real payments'},812,[12,245,109,791,799,6]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"attStatus",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"isConfirmed",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"timesheetRemote",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"weekdayOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"mondayOfDate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"shiftsOn",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"shiftOf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"visibleShifts",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"SUPPLIER_CATS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"NLW_PENCE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"MAX_CUSTOM_LINKS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"WIX_IDS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"isWixLink",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"DEFAULT_QUICK_LINKS",{enumerable:!0,get:function(){return O}}),_e.openShiftOf=S,_e.loggedBreakMins=R,Object.defineProperty(_e,"isOnBreak",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"useOwner",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"wageLabel",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ROLE_LABEL",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return L}});var e,t=_r(_d[0]),a=(e=t)&&e.__esModule?e:{default:e},r=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]);const d=e=>e.out?e.signOff?'confirmed':'awaiting':'open',c=e=>!!e.out&&!!e.signOff,l={send:null},u=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,f=e=>{const[t,a,r]=e.split('-').map(Number);return(new Date(t,a-1,r).getDay()+6)%7},p=(e,t)=>{const[a,r,n]=e.split('-').map(Number);return u(new Date(a,r-1,n+t))},m=e=>p(e,-f(e)),h=(e,t)=>e.filter(e=>e.date===t),g=(e,t,a)=>e.find(e=>e.staffId===t&&e.date===a),y=(e,t)=>t?e:e.filter(e=>e.published),b=['Fish & seafood','Meat','Fruit & veg','Dairy','Dry goods','Drinks/brewery','Cleaning','Packaging','Equipment/maintenance'],k=1271,w=6,v=['ql-wix-view','ql-wix-edit'],x=e=>v.includes(e.id)||'Website (Wix)'===e.group,O=[{id:'ql-gmail',label:'Work email (Gmail)',url:'',icon:'\u2709\ufe0f',kind:'gmail',staff:!1,builtIn:!0},{id:'ql-wix-view',label:'View site',url:'https://www.anchoragedunure.com',icon:'\ud83c\udf10',kind:'link',group:'Website (Wix)',staff:!1,builtIn:!0},{id:'ql-wix-edit',label:'Edit site',url:'https://manage.wix.com',icon:'\u270f\ufe0f',kind:'link',group:'Website (Wix)',staff:!1,builtIn:!0}];function S(e,t,a){const r=new Date(a).getTime();return e.filter(e=>e.staffId===t&&e.in&&!e.out&&r-new Date(e.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0]}function R(e,t=new Date){const a=new Date(t).getTime();return Math.round((e.breaks??[]).reduce((e,t)=>e+Math.max(0,(t.end?new Date(t.end).getTime():a)-new Date(t.start).getTime()),0)/6e4)}const D=e=>!!e?.breaks?.some(e=>!e.end),P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,$=['#2A3B4C','#4A3A22','#26403A','#3E2A2A','#2E2E40'];function A(){return s.ROSTER.map(e=>({id:e.id,name:e.name,role:e.role,job:e.job,active:!0,level:e.level,dept:e.dept,salaried:e.salaried,noTax:e.noTax}))}function M(){return Object.fromEntries(s.ROSTER.filter(e=>null!=e.hourlyPence).map(e=>[e.id,e.hourlyPence]))}const T=()=>({tronc:{method:'hours',points:{FOH:1,Bar:1,Kitchen:.8,KP:.6,Manager:1},includeManagers:!0,includeOwner:!1,custom:{},text:'The Anchorage tipping policy (template)\n\n1. 100% of tips paid by card and cash tips put in the tip jar go to staff. Nothing is deducted.\n2. Tips are pooled and shared by paid hours worked in each pay period (breaks excluded).\n3. The owner does not take a share. Managers share only for hours worked on the floor or in the kitchen.\n4. Tips are paid with wages, no later than the end of the month after the tip was paid.\n5. Tip records are kept for 3 years. Ask a manager for your records at any time.'},troncCash:{},troncHistory:[],troncLog:[],chat:[],chatMuted:{},referral:{giverReward:'Free dessert',friendReward:'\xa35 off first order',active:!0},referrals:[{id:'rf-1',referrer:'Fiona Campbell (example)',friend:'Ailsa Ross (example)',at:'2026-10-21',status:'rewarded'},{id:'rf-2',referrer:'Iain Fraser (example)',friend:'Neil Grant (example)',at:'2026-10-23',status:'first order'},{id:'rf-3',referrer:'Alex Morgan',friend:'Jamie (example)',at:'2026-10-25',status:'signed up'},{id:'rf-4',referrer:'Kirsty Hamilton (example)',friend:'Craig Reid (example)',at:'2026-10-26',status:'signed up'}],reminders:{h24:!0,h2:!0,confirmText:!0},coats:[{id:'ct-1',ticket:14,desc:'Black wool coat',at:'17:05',status:'in'},{id:'ct-2',ticket:15,desc:'Green Barbour jacket + umbrella',at:'17:20',status:'in'}],merch:[{id:'mc-1',name:'Anchorage tote bag',price:1200,stock:18,live:!0},{id:'mc-2',name:'House tartare sauce jar',price:650,stock:6,live:!0},{id:'mc-3',name:'Harbour View mug',price:1e3,stock:0,live:!1}],merchOrders:[{id:'mo-1',productId:'mc-2',qty:2,customer:'Morag (example)',at:'2026-10-26',status:'new'},{id:'mo-2',productId:'mc-1',qty:1,customer:'Callum (example)',at:'2026-10-24',status:'collected'}],marketingDraft:void 0,socialAccounts:{facebook:!0,instagram:!0,tiktok:!0,youtube:!0},socialPosts:[],socialDraft:void 0,quickLinks:O.map(e=>({...e})),workEmail:'',staff:A(),rosterVersion:s.ROSTER_VERSION,previewRole:'owner',staffAs:s.ROSTER.find(e=>'staff'===e.app)?.id??s.ROSTER[0].id,offers:[{id:'of-1',title:'Catch of the day: Dunure lobster (example)',body:'Half or whole, garlic butter or thermidor. Ask your server \u2014 board price.',kind:'special',live:!0},{id:'of-2',title:'Midweek fish supper deal (example)',body:'Two fish suppers for \xa330, Wed\u2013Thu takeaway.',kind:'offer',until:'2026-11-30',live:!0}],photos:[{id:'ph-1',caption:'Harbour view from the terrace (placeholder)',tone:$[0]},{id:'ph-2',caption:'Fish supper (placeholder)',tone:$[1]},{id:'ph-3',caption:'Dining room (placeholder)',tone:$[2]}],changeRequests:[{id:'cr-1',text:'Add the Christmas party menu page (example)',at:'2026-10-05',status:'done'},{id:'cr-2',text:'New header photo for the app (example)',at:'2026-10-19',status:'in progress'}],changesUsed:2,site:o.VENUE_RID,branding:{},checks:{},lost:[{id:'lp-1',item:'Navy umbrella',where:'Table 7',foundAt:'2026-10-24 19:40',foundBy:'Server (example)',status:'held'},{id:'lp-2',item:'Child\u2019s blue cardigan',where:'Terrace',foundAt:'2026-10-18 14:10',foundBy:'Bar (example)',status:'held'},{id:'lp-3',item:'Car keys (Ford)',where:'Bar',foundAt:'2026-10-11 21:05',foundBy:'Duty Manager (example)',status:'returned',contact:'Collected by owner'}],lostReports:[],campaigns:[{id:'cp-1',title:'Halloween weekend (example)',body:'Spooky specials all weekend at The Anchorage. Book now!',segment:'All opted-in',sendAt:'2026-10-29 10:00',status:'scheduled',reach:412},{id:'cp-2',title:'Fish supper Friday (example)',body:'2 fish suppers for \xa330 tonight, order ahead in the app.',segment:'Takeaway regulars',sendAt:'2026-10-23 15:00',status:'sent (demo)',reach:188}],shifts:[],rotaPublished:void 0,leave:[],swaps:[],availability:{},attendance:[],attLog:[],timeRequests:[],geofence:{lat:55.4047,lng:-4.7606,radius:100},simLocation:'venue',consent:{},hourly:M(),payPeriod:'weekly',suppliers:[{id:'sup-1',name:'Example Fish Co.',category:'Fish & seafood',contact:'Alex Sample',phones:['01632 960001','07700 900001'],email:'orders@example.com',website:'https://example.com/fish',account:'ANC-0001',cutoff:'14:00',orderDays:[0,1,2,3,4],deliveryDays:[1,2,3,4,5],minOrder:7500,terms:'30 days',notes:'Day boat landings. Ask for the langoustine grade before ordering.',fav:!0,archived:!1},{id:'sup-2',name:'Example Butchers Ltd',category:'Meat',contact:'Sam Example',phones:['01632 960002'],email:'butcher@example.com',website:'https://example.com/meat',account:'ANC-0002',cutoff:'12:00',orderDays:[0,2,4],deliveryDays:[1,3,5],minOrder:5e3,terms:'14 days',notes:'Burger patties made to our spec (6 oz).',fav:!1,archived:!1},{id:'sup-3',name:'Sample Fruit & Veg',category:'Fruit & veg',contact:'Jo Placeholder',phones:['01632 960003'],email:'veg@example.com',website:'https://example.com/veg',account:'ANC-0003',cutoff:'20:00',orderDays:[0,1,2,3,4,5],deliveryDays:[1,2,3,4,5,6],minOrder:4e3,terms:'7 days',notes:'Chipping potatoes: ask for Maris Piper.',fav:!0,archived:!1},{id:'sup-4',name:'Sample Dairy Ltd',category:'Dairy',contact:'Chris Example',phones:['01632 960004'],email:'dairy@example.com',website:'https://example.com/dairy',account:'ANC-0004',cutoff:'16:00',orderDays:[0,3],deliveryDays:[1,4],minOrder:3e3,terms:'14 days',notes:'',fav:!1,archived:!1},{id:'sup-5',name:'Example Dry Goods Wholesale',category:'Dry goods',contact:'Pat Sample',phones:['01632 960005'],email:'drygoods@example.com',website:'https://example.com/drygoods',account:'ANC-0005',cutoff:'15:00',orderDays:[1],deliveryDays:[3],minOrder:15e3,terms:'30 days',notes:'Weekly order. Oil, flour, sauces, tins.',fav:!1,archived:!1},{id:'sup-6',name:'Sample Brewing Co.',category:'Drinks/brewery',contact:'Robin Example',phones:['01632 960006','07700 900006'],email:'trade@example.com',website:'https://example.com/brewery',account:'ANC-0006',cutoff:'11:00',orderDays:[2],deliveryDays:[4],minOrder:2e4,terms:'30 days',notes:'Cask returns collected on delivery.',fav:!0,archived:!1},{id:'sup-7',name:'Example Cleaning Supplies',category:'Cleaning',contact:'Lee Placeholder',phones:['01632 960007'],email:'clean@example.com',website:'https://example.com/cleaning',account:'ANC-0007',cutoff:'17:00',orderDays:[3],deliveryDays:[5],minOrder:6e3,terms:'30 days',notes:'',fav:!1,archived:!1},{id:'sup-8',name:'Sample Packaging Ltd',category:'Packaging',contact:'Morgan Sample',phones:['01632 960008'],email:'packaging@example.com',website:'https://example.com/packaging',account:'ANC-0008',cutoff:'13:00',orderDays:[0],deliveryDays:[2],minOrder:1e4,terms:'30 days',notes:'Compostable takeaway boxes and paper bags.',fav:!1,archived:!1},{id:'sup-9',name:'Example Kitchen Repairs',category:'Equipment/maintenance',contact:'Taylor Example',phones:['01632 960009','07700 900009'],email:'repairs@example.com',website:'https://example.com/repairs',account:'ANC-0009',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'On invoice',notes:'Fryer and fridge servicing. Emergency call-out line is the mobile.',fav:!1,archived:!1}],supplierOrders:[{id:'so-1',supplierId:'sup-1',date:'',items:'Haddock 40 portions, langoustines 4 kg',amount:21450,by:'Head Chef (example)',at:''},{id:'so-2',supplierId:'sup-6',date:'',items:'6 casks, 4 kegs',amount:64800,by:'Manager (example)',at:''}],staffCanViewSuppliers:!1,readNotes:{},customerTags:{'cust-demo':['Allergy','Regular'],'cr-2':['VIP'],'cr-5':['Takeaway']}}),C=(0,r.create)()((0,n.persist)((e,t)=>({...T(),setPreviewRole:t=>e({previewRole:t}),addStaff:(t,a,r)=>e(e=>({staff:[...e.staff,{id:P('st'),name:t,role:a,job:r,active:!0,level:j[a]}]})),saveSupplier:t=>e(e=>({suppliers:e.suppliers.some(e=>e.id===t.id)?e.suppliers.map(e=>e.id===t.id?t:e):[...e.suppliers,t]})),setRate:(t,a)=>e(e=>({hourly:{...e.hourly,[t]:Math.max(0,Math.round(a))}})),clearRate:t=>e(e=>{const a={...e.hourly};return delete a[t],{hourly:a}}),updateStaff:(t,a)=>e(e=>({staff:e.staff.map(e=>e.id===t?{...e,...a}:e)})),addOffer:t=>e(e=>({offers:[{...t,id:P('of')},...e.offers]})),updateOffer:(t,a)=>e(e=>({offers:e.offers.map(e=>e.id===t?{...e,...a}:e)})),addPhoto:t=>e(e=>({photos:[...e.photos,{id:P('ph'),caption:t,tone:$[e.photos.length%$.length]}]})),removePhoto:t=>e(e=>({photos:e.photos.filter(e=>e.id!==t)})),requestChange:(t,a)=>e(e=>e.changesUsed>=5?e:{changesUsed:e.changesUsed+1,changeRequests:[{id:P('cr'),text:t,at:a,status:'requested'},...e.changeRequests]}),setSite:t=>e({site:t}),setBranding:(t,a)=>e(e=>{const r={...e.branding};return a?r[t]={...r[t],...a}:delete r[t],{branding:r}}),setOwner:t=>e(t),addSocialPost:t=>e(e=>({socialPosts:[{...t,id:P('sp')},...e.socialPosts]})),setSocialPost:(t,a)=>e(e=>({socialPosts:e.socialPosts.map(e=>e.id===t?{...e,...a}:e)})),chatSend:t=>e(e=>({chat:[...e.chat,{...t,id:(0,i.uuid)(),reactions:{},seenBy:t.seenBy??('system'===t.from?[]:[t.from])}]})),chatReact:(t,a,r)=>e(e=>({chat:e.chat.map(e=>{if(e.id!==t)return e;const n=e.reactions[a]??[];return{...e,reactions:{...e.reactions,[a]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}}})})),chatSeen:(t,a)=>e(e=>e.chat.some(e=>e.ch===t&&!e.seenBy.includes(a))?{chat:e.chat.map(e=>e.ch!==t||e.seenBy.includes(a)?e:{...e,seenBy:[...e.seenBy,a]})}:e),chatPatch:(t,a)=>e(e=>({chat:e.chat.map(e=>e.id===t?{...e,...a}:e)})),chatMute:(t,a)=>e(e=>{const r=e.chatMuted[t]??[];return{chatMuted:{...e.chatMuted,[t]:r.includes(a)?r.filter(e=>e!==a):[...r,a]}}}),sys:(t,a,r)=>e(e=>({chat:[...e.chat,{id:P('m'),ch:t,from:'system',text:a,at:r,reactions:{},seenBy:[]}]})),tick:(t,a,r,n)=>e(e=>({checks:{...e.checks,[t]:{by:a,at:r,value:n}}})),untick:t=>e(e=>{const a={...e.checks};return delete a[t],{checks:a}}),addLost:t=>e(e=>({lost:[{...t,id:P('lp'),status:'held'},...e.lost]})),setLost:(t,a)=>e(e=>({lost:e.lost.map(e=>e.id===t?{...e,...a}:e)})),addCampaign:t=>e(e=>({campaigns:[{...t,id:P('cp')},...e.campaigns]})),setCampaign:(t,a)=>e(e=>({campaigns:e.campaigns.map(e=>e.id===t?{...e,...a}:e)})),setShifts:t=>e({shifts:t.map(e=>e.date?{...e,day:f(e.date)}:e)}),addShift:t=>e(e=>({shifts:[...e.shifts,{...t,day:f(t.date),published:!1,id:(0,i.uuid)()}]})),copyWeek:(a,r)=>{const n=t(),s=new Set(n.staff.filter(e=>e.active).map(e=>e.id)),o=[];for(let e=0;e<7;e++){const t=p(a,e),d=p(r,e);n.shifts.filter(e=>e.date===t&&s.has(e.staffId)&&!n.shifts.some(t=>t.staffId===e.staffId&&t.date===d)&&!o.some(t=>t.staffId===e.staffId&&t.date===d)).forEach(e=>o.push({id:(0,i.uuid)(),staffId:e.staffId,date:d,day:f(d),start:e.start,end:e.end,note:e.note,published:!1}))}return o.length&&e({shifts:[...n.shifts,...o]}),o.length},publishWeek:t=>{const a=p(t,6);let r=0;return e(e=>({shifts:e.shifts.map(e=>e.datea||e.published&&!e.changed?e:(r++,{...e,published:!0,changed:!1})),rotaPublished:(new Date).toISOString()})),r},removeShift:t=>e(e=>({shifts:e.shifts.filter(e=>e.id!==t)})),markRead:t=>e(e=>({readNotes:{...e.readNotes,...Object.fromEntries(t.map(e=>[e,!0]))}})),toggleTag:(t,a)=>e(e=>{const r=e.customerTags[t]??[];return{customerTags:{...e.customerTags,[t]:r.includes(a)?r.filter(e=>e!==a):[...r,a]}}}),publishRota:t=>e({rotaPublished:t}),addLeave:t=>e(e=>({leave:[{...t,id:P('lv'),status:'pending'},...e.leave]})),setLeave:(t,a)=>e(e=>({leave:e.leave.map(e=>e.id===t?{...e,status:a}:e)})),addSwap:t=>e(e=>({swaps:[{...t,id:P('sw'),status:'open'},...e.swaps]})),setSwap:(t,a)=>e(e=>{const r=e.swaps.find(e=>e.id===t);return{shifts:'approved'===a&&r?.toId?e.shifts.map(e=>e.id===r.shiftId?{...e,staffId:r.toId}:e):e.shifts,swaps:e.swaps.map(e=>e.id===t?{...e,status:a}:e)}}),toggleAvail:(t,a)=>e(e=>{const r=e.availability[t]??[];return{availability:{...e.availability,[t]:r.includes(a)?r.filter(e=>e!==a):[...r,a]}}}),clock:(t,a,r,n,s,o)=>e(e=>{const d=e.attendance.filter(e=>e.staffId===t&&e.in&&!e.out&&new Date(n).getTime()-new Date(e.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0];if('in'===r)return d?e:{attendance:[...e.attendance,{id:(0,i.uuid)(),staffId:t,date:a,in:n,inSite:s}]};const c=e=>e?.map(e=>e.end?e:{...e,end:n});return d?{attendance:e.attendance.map(e=>e.id===d.id?{...e,out:n,outSite:s,breakMins:o??R({...e,breaks:c(e.breaks)}),breaks:c(e.breaks)}:e)}:e}),adjustClock:(t,a,r,n,s,i)=>e(e=>{const o=e.attendance.find(e=>e.id===t),d=e.staff.find(e=>e.id===o?.staffId),c=o?.[a]?new Date(o[a]).toTimeString().slice(0,5):'none';return{attendance:e.attendance.map(e=>e.id===t?{...e,[a]:r,adjusted:{by:n,at:i,reason:s}}:e),attLog:[{id:P('al'),at:i,text:`${n} changed ${d?.name??'staff'} clock-${a} from ${c} to ${new Date(r).toTimeString().slice(0,5)}: ${s}`},...e.attLog]}}),breakToggle:(a,r,n)=>{const s=t(),i=S(s.attendance,a,n);if(!i)return!1;const o=i.breaks??[],d=o.some(e=>!e.end);if('start'===r?d:!d)return!1;const c='start'===r?[...o,{start:n}]:o.map(e=>e.end?e:{...e,end:n});return e({attendance:s.attendance.map(e=>e.id===i.id?{...e,breaks:c,breakMins:R({breaks:c})}:e)}),!0},adjustBreak:(t,a,r,n,s)=>e(e=>{const i=e.attendance.find(e=>e.id===t),o=e.staff.find(e=>e.id===i?.staffId);return{attendance:e.attendance.map(e=>e.id===t?{...e,breakMins:a,adjusted:{by:r,at:s,reason:n}}:e),attLog:[{id:P('al'),at:s,text:`${r} changed ${o?.name??'staff'} break from ${i?.breakMins??0}m to ${a}m: ${n}`},...e.attLog]}}),overrideEntry:a=>{const r=t(),n=a.id?r.attendance.find(e=>e.id===a.id):void 0,s=a.reason.trim();if(s.length<3)return null;if(a.out&&a.out<=a.in)return null;const o=e=>e?new Date(e).toTimeString().slice(0,5):'none',d=(e,t,r)=>({at:a.now,by:a.by,byId:a.byId,action:e,from:t,to:r,reason:s}),c=r.staff.find(e=>e.id===a.staffId)?.name??'staff';let u;const f=[];if(n){const e=[...n.audit??[]];if(n.signOff&&(e.push(d('reopened','Confirmed','Awaiting sign-off')),f.push(`${a.by} reopened ${c}'s confirmed ${n.date} entry`)),n.in!==a.in&&(e.push(d('clock_in',o(n.in),o(a.in))),f.push(`${a.by} changed ${c} clock-in from ${o(n.in)} to ${o(a.in)}: ${s}`)),(n.out??'')!==(a.out??'')&&(e.push(d('clock_out',o(n.out),o(a.out))),f.push(`${a.by} changed ${c} clock-out from ${o(n.out)} to ${o(a.out)}: ${s}`)),(n.breakMins??0)!==a.breakMins&&(e.push(d('break',`${n.breakMins??0}m`,`${a.breakMins}m`)),f.push(`${a.by} changed ${c} break from ${n.breakMins??0}m to ${a.breakMins}m: ${s}`)),e.length===(n.audit??[]).length)return n;const t=a.out?n.breaks?.map(e=>e.end?e:{...e,end:a.out}):n.breaks;u={...n,in:a.in,out:a.out,breakMins:a.breakMins,breaks:t,signOff:void 0,adjusted:{by:a.by,at:a.now,reason:s},audit:e}}else u={id:a.id??(0,i.uuid)(),staffId:a.staffId,date:a.date,in:a.in,out:a.out,breakMins:a.breakMins,added:!0,adjusted:{by:a.by,at:a.now,reason:s},audit:[d('added',void 0,`${o(a.in)}\u2013${a.out?o(a.out):'open'}, break ${a.breakMins}m`)]},f.push(`${a.by} added ${c}'s ${a.date} entry ${o(a.in)}\u2013${a.out?o(a.out):'open'} (break ${a.breakMins}m): ${s}`);return a.request&&(u={...u,audit:[...u.audit??[],d('request_applied')]}),l.send?.('attendance_override',u,{reason:s}),e(e=>({attendance:n?e.attendance.map(e=>e.id===n.id?u:e):[...e.attendance,u],attLog:[...f.reverse().map(e=>({id:P('al'),at:a.now,text:e})),...e.attLog]})),u},confirmEntries:(a,r,n,s)=>{const i=t(),o=new Set(a),d=[],c=i.attendance.map(e=>{if(!o.has(e.id)||!e.out||e.signOff)return e;const t={...e,signOff:{by:r,byId:n,at:s},audit:[...e.audit??[],{at:s,by:r,byId:n,action:'confirmed',from:'Awaiting sign-off',to:'Confirmed'}]};return d.push(t),t});return d.length?(d.forEach(e=>l.send?.('attendance_confirm',e)),e({attendance:c,attLog:[{id:P('al'),at:s,text:`${r} confirmed ${d.length} ${1===d.length?'entry':'entries'} (${[...new Set(d.map(e=>e.date))].join(', ')})`},...i.attLog]}),d.length):0},addTimeRequest:t=>e(e=>({timeRequests:[{...t,id:(0,i.uuid)(),status:'open'},...e.timeRequests]})),resolveTimeRequest:(a,r,n,s)=>{const i=t().timeRequests.find(e=>e.id===a);if(!i||'open'!==i.status)return;const o={...i,status:r,resolvedBy:n,resolvedAt:s};l.send?.('time_request_resolve',o),e(e=>({timeRequests:e.timeRequests.map(e=>e.id===a?o:e)}))},setGeofence:t=>e(e=>({geofence:{...e.geofence,...t}})),setSimLocation:t=>e({simLocation:t}),giveConsent:(t,a)=>e(e=>({consent:{...e.consent,[t]:a}})),resetOwner:()=>e(T()),syncRoster:()=>e(e=>{if(e.rosterVersion===s.ROSTER_VERSION)return e;const t=new Map(e.staff.map(e=>[e.id,e]));return{staff:[...A().map(e=>({...e,active:t.get(e.id)?.active??!0})),...e.staff.filter(e=>!s.ROSTER.some(t=>t.id===e.id)&&!E.includes(e.id))],hourly:{...e.hourly,...M()},rosterVersion:s.ROSTER_VERSION}})}),{name:'covercharge-owner-v1',version:4,storage:(0,n.createJSONStorage)(()=>a.default),migrate:(e,t)=>{if(e&&t<2&&Array.isArray(e.quickLinks)&&(e.quickLinks=e.quickLinks.map(e=>v.includes(e.id)||'Website (Wix)'===e.group?{...e,staff:!1}:e)),e&&t<3){const t=T();Object.assign(e,{staff:t.staff,hourly:t.hourly,shifts:t.shifts,leave:t.leave,swaps:t.swaps,availability:t.availability,attendance:[],attLog:[],consent:{},chat:[],chatMuted:{},troncHistory:[],staffAs:t.staffAs,previewRole:'owner',rosterVersion:s.ROSTER_VERSION,rotaPublished:void 0})}if(e&&t<4){const t=m(u(new Date));e.shifts=(e.shifts??[]).map(e=>e.date?e:{...e,date:p(t,e.day??0),published:!0}),e.timeRequests=e.timeRequests??[]}return e}})),I=(e,t,a)=>e?.salaried&&null==t?'Owner, no hourly wage':null==t?'Not set':`${a(t)}/h`,E=['st-2','st-3','st-4','st-5'],j={owner:'Owner',manager:'Manager',staff:'Staff'},L={forecasts:e=>'staff'!==e,manage:e=>'staff'!==e,staffAdmin:e=>'owner'===e,billing:e=>'owner'===e,takings:e=>'staff'!==e,publishSocial:e=>'staff'!==e}},813,[975,974,976,916,920,856]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSpecials",{enumerable:!0,get:function(){return y}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),n=r(_d[2]),l=r(_d[3]),c=r(_d[4]);const d=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}};let u=0;const p=()=>`sb-${Date.now().toString(36)}${(u++).toString(36)}`,S=(e,t)=>c.useStore.setState(s=>({audit:[{id:`au-${p()}`,restaurantId:e,at:d().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),y=(0,o.create)()((0,n.persist)((e,t)=>({...(0,l.seedSpecials)(d()),post:(t,s,o,n)=>{e(e=>(0,l.postBoard)(e,t,s,o,n,d(),p())),s.items.length&&S(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${o}`)},clear:(t,s)=>{e(e=>(0,l.clearBoard)(e,t)),S(t,`Specials board cleared by ${s}`)},reuse:(s,o,n,c)=>{const u=t().history.find(e=>e.id===o);e(e=>(0,l.reuseBoard)(e,s,o,n,c,d(),p())),u?.items.length&&S(s,`Specials board re-used: ${u.items.length} typed special${1===u.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,l.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({current:e.current,history:e.history})}))},814,[975,974,976,815,855]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAMPLE_PHOTO",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_MAX",{enumerable:!0,get:function(){return n}}),e.parsePrice=function(t){const n=t.trim().replace(/^\xa3\s*/,'');return n?/^\d{1,3}(\.\d{1,2})?$/.test(n)?Math.round(100*parseFloat(n)):NaN:null},Object.defineProperty(e,"priceText",{enumerable:!0,get:function(){return s}}),e.itemProblems=a,e.draftProblems=i,e.cycleAllergen=function(t,n){const s={...t};s[n]?'contains'===s[n]?s[n]='may':delete s[n]:s[n]='contains';return s},e.postBoard=function(t,n,s,a,l,c,d){const u=i(s);if(u.length)throw new Error(u[0]);const p={id:d,restaurantId:n,photo:s.photo,app:l,postedBy:a,postedAt:c.toISOString(),items:s.items.map(t=>({...t,name:t.name.trim(),description:t.description.trim()})),allergenCheck:s.items.length?{by:a,at:c.toISOString()}:null};return{current:{...t.current,[n]:p},history:o(t.history,t.current[n],n)}},e.clearBoard=function(t,n){return{current:{...t.current,[n]:null},history:o(t.history,t.current[n],n)}},e.reuseBoard=function(t,n,s,a,i,l,c){const d=t.history.find(t=>t.id===s&&t.restaurantId===n);if(!d)return t;const u={...d,id:c,app:i,postedBy:a,postedAt:l.toISOString(),reusedFrom:d.id,allergenCheck:d.items.length?{by:a,at:l.toISOString()}:null},p={...t,history:t.history.filter(t=>t.id!==s)};return{current:{...t.current,[n]:u},history:o(p.history,t.current[n],n)}},e.deleteFromHistory=function(t,n){return{...t,history:t.history.filter(t=>t.id!==n)}},Object.defineProperty(e,"historyFor",{enumerable:!0,get:function(){return l}}),e.whenText=h,Object.defineProperty(e,"isToday",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"freshness",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"lastUpdated",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"boardSummary",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"SAMPLE_ITEMS",{enumerable:!0,get:function(){return k}}),e.seedSpecials=function(n){const s=60*n.getHours()+n.getMinutes()>=702?S(n,0,11,42):new Date(n.getTime()-6e5),a=S(n,1,11,20),i=S(n,3,12,5);return{current:{anchorage:{id:'sb-seed-today',restaurantId:'anchorage',photo:null,items:k,postedAt:s.toISOString(),postedBy:'Head Chef (example)',app:'chef',allergenCheck:{by:'Head Chef (example)',at:s.toISOString()}}},history:[{id:'sb-seed-yday',restaurantId:'anchorage',photo:null,postedAt:a.toISOString(),postedBy:'Duty Manager (example)',app:'managers',allergenCheck:{by:'Duty Manager (example)',at:a.toISOString()},items:[{id:'sp-y1',name:'Pan-fried sea bass, samphire, brown shrimp butter (sample)',description:'Sample dish.',price:2100,allergens:{fish:'contains',crustaceans:'contains',milk:'contains'}},{id:'sp-y2',name:'Smoked haddock fishcake, poached egg (sample)',description:'Sample dish: with wholegrain mustard sauce.',price:1250,allergens:{fish:'contains',eggs:'contains',gluten:'contains',milk:'contains',mustard:'contains'}},{id:'sp-y3',name:'Lemon posset, shortbread (sample)',description:'Sample pudding.',price:750,allergens:{milk:'contains',gluten:'contains'}}]},{id:'sb-seed-photo',restaurantId:'anchorage',photo:t,items:[],postedAt:i.toISOString(),postedBy:'Head Chef (example)',app:'chef',allergenCheck:null}]}};const t='sample:chalkboard',n=8;const s=t=>null===t?'Ask your server':`\xa3${(t/100).toFixed(2)}`;function a(t){const n=[];t.name.trim().length<3&&n.push('Add a dish name'),null!==t.price&&(!Number.isFinite(t.price)||t.price<=0||t.price>5e4)&&n.push('Check the price');const s=Object.keys(t.allergens).length;return s||t.noAllergens||n.push('Choose its allergens, or tick \u201cNone of the 14\u201d'),s&&t.noAllergens&&n.push('Allergens chosen and \u201cNone of the 14\u201d both ticked'),n}function i(t){const n=[];return t.photo||t.items.length||n.push('Add a photo of the board or type at least one special'),t.items.forEach((t,s)=>a(t).forEach(t=>n.push(`Special ${s+1}: ${t}`))),t.items.length&&!t.allergensChecked&&n.push('Confirm you have checked the allergens'),n}const o=(t,s,a)=>{if(!s)return t;return[...[s,...t.filter(t=>t.restaurantId===a&&t.id!==s.id)].slice(0,n),...t.filter(t=>t.restaurantId!==a)]};const l=(t,n)=>t.history.filter(t=>t.restaurantId===n),c=t=>String(t).padStart(2,'0'),d=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],p=(t,n)=>t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();function h(t,n){const s=new Date(t),a=`${c(s.getHours())}:${c(s.getMinutes())}`;if(p(s,n))return`today at ${a}`;const i=new Date(n);return i.setDate(i.getDate()-1),p(s,i)?`yesterday at ${a}`:`${d[s.getDay()]} ${s.getDate()} ${u[s.getMonth()]} at ${a}`}const m=(t,n)=>p(new Date(t),n),y=(t,n)=>`Updated ${h(t.postedAt,n)}`,f=(t,n)=>`Last updated ${h(t.postedAt,n)} by ${t.postedBy}`,b=t=>[t.photo?'Photo':'',t.items.length?`${t.items.length} typed special${1===t.items.length?'':'s'}`:''].filter(Boolean).join(' + '),S=(t,n,s,a)=>{const i=new Date(t);return i.setDate(i.getDate()-n),i.setHours(s,a,0,0),i},k=[{id:'sp-hake',name:'Grilled hake, crushed new potatoes, salsa verde (sample)',description:'Sample dish: day-boat hake, lemon and caper salsa verde.',price:1950,allergens:{fish:'contains',mustard:'contains',sulphites:'may'}},{id:'sp-scallops',name:'Half-shell scallops, garlic and herb butter (sample)',description:'Sample dish: three scallops grilled in the shell, crusty bread.',price:1400,allergens:{molluscs:'contains',milk:'contains',gluten:'contains'}},{id:'sp-crab',name:'Crab and chilli linguine (sample)',description:'Sample dish: brown and white crab meat, chilli, parsley, lemon.',price:1850,allergens:{crustaceans:'contains',gluten:'contains',eggs:'contains',molluscs:'may'}},{id:'sp-mussels',name:'Mussels in cider and leek cream (sample)',description:'Sample dish: rope-grown mussels, dry cider, leeks, cream. Main with chips.',price:1300,allergens:{molluscs:'contains',milk:'contains',sulphites:'contains',celery:'may'}}]},815,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return f}}),_e.sha256Hex=w,_e.inviteFromText=function(e){const n=e.trim(),t=n.match(/[?&#]invite=([A-Za-z0-9_-]{10,})/);return t?t[1]:/^[A-Za-z0-9_-]{10,}$/.test(n)?n:null},_e.personForInvite=async function(e){const n=await w(e);return n?u.ROSTER.find(e=>e.tokenHash===n):void 0},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return p}}),_e.appUrl=function(e,n){if('undefined'==typeof window||!window.location)return null;const{origin:t,pathname:o}=window.location,c=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),u=c?c[1]:'/';return`${t}${u}${e}-app/index.html${n?`?invite=${encodeURIComponent(n)}`:''}`},_e.levelJob=function(e,n){const t=(e??'').trim(),o=(n??'').trim();return t?!o||o.toLowerCase().startsWith(t.toLowerCase())?o||t:`${t} \xb7 ${o}`:o};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[1]),c=r(d[2]),u=r(d[3]);const s=(0,o.create)()((0,c.persist)(e=>({meId:null,welcomed:{},signIn:n=>e({meId:n,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:n=>e(e=>({welcomed:{...e.welcomed,[n]:(new Date).toISOString()}}))}),{name:'covercharge-session-v1',storage:(0,c.createJSONStorage)(()=>t.default),version:1})),l=e=>e?u.ROSTER.find(n=>n.id===e):void 0,f={owner:'Cover Charge for Managers',staff:'Cover Charge for Staff',chef:'Cover Charge for Head Chef'};async function w(e){const n=globalThis.crypto?.subtle;if(!n)return null;const t=await n.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,'0')).join('')}const m=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('invite'):null}catch{return null}})(),p=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})()},816,[975,974,976,916]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n.default}});var e=r(d[0]);Object.keys(e).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(_e,t)||Object.defineProperty(_e,t,{enumerable:!0,get:function(){return e[t]}})});var t,n=(t=e)&&t.__esModule?t:{default:t}},852,[1100]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(o,r,n,u,c){const l=(0,a.hoursFor)(o,c),h=[],y=(0,s.ymd)(c);let p=1;for(const e of u.filter(e=>e.date===y&&(null===e.restaurantId||e.restaurantId===o.id)))h.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(p*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!l)return{open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:h,suggestions:['Kitchen closed today (per listed hours).'],multiplier:p};const f=t.EXAMPLE_HISTORY[o.id]??t.EXAMPLE_HISTORY.default,k=c.getDay(),v=l.open.getHours();let w=l.close.getMinutes()>0?l.close.getHours():l.close.getHours()-1;const M=(0,e.lastFoodOn)(o,y);if(M){const[e,t]=M.time.split(':').map(Number);w=Math.min(w,t>0?e:e-1),'kitchen closes'!==M.reason&&h.push(`Last food orders ${M.time} (${M.reason})`)}const b=[];for(let e=v;e<=w;e++){const t=f.covers[k]?.[e]??0,a=f.takeaway[k]?.[e]??0,u=r.filter(t=>t.restaurantId===o.id&&t.date===y&&!t.walkIn&&['confirmed','seated'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),c=r.filter(t=>t.restaurantId===o.id&&t.date===y&&t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),l=Math.max(c,Math.round(t*o.settings.walkInShare*p)),h=u+l,v=n.filter(t=>t.restaurantId===o.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===y).length,w=Math.max(v,Math.round(a*p));b.push({hour:e,booked:u,walkIns:l,covers:h,coversLow:Math.round(.8*h),coversHigh:Math.round(1.2*h),takeawayPlaced:v,takeaway:w,historicalCovers:t})}const H=c.getHours()+(c.getMinutes()>=30?1:0),I=b.filter(e=>e.hour>=H),S=I[0],T=e=>I.reduce((t,a)=>t+e(a),0),$={covers:T(e=>e.covers),low:T(e=>e.coversLow),high:T(e=>e.coversHigh),takeaway:T(e=>e.takeaway),booked:T(e=>e.booked)},D=[],L=o.settings.capacityPerHour,O=I.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);O&&O.covers>=.85*L&&D.push(`Dining room near capacity around ${String(O.hour).padStart(2,'0')}:00 (~${O.covers} of ${L} covers) \u2014 consider pausing or capping takeaway slots then.`);const _=I.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);_&&D.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][k]} from ${String(_.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);$.takeaway>=10&&D.push(`~${$.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);D.length||D.push('Looks like a normal service \u2014 no action suggested.');return{open:!0,nextHour:S,hours:b,restOfDay:$,flags:h,suggestions:D,multiplier:p}};var e=_r(d[0]),t=_r(d[1]),a=_r(d[2]),s=_r(d[3])},853,[789,1095,793,796]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.estimateWait=function(t,n,u){const o=Math.max(6,Math.round(n/6*u));return t*o}},854,[]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"uuid",{enumerable:!0,get:function(){return m.uuid}}),_e.nowFrom=b,_e.linesFromBasket=y,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return s.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),n=_r(d[2]),s=_r(d[3]),i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]);const p=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,f=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function b(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function k(){const e=(0,s.defaultSimStart)();return{clock:{mode:'simulated',simStartMs:e.getTime(),anchorRealMs:Date.now()},...(0,s.buildSeed)(e),outbox:[],msgTemplates:{}}}function y(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,c.resolveItem)(r),s=(n.optionGroups??[]).flatMap(t=>t.choices.filter(t=>e.choiceIds.includes(t.id))),i=(n.price??0)+s.reduce((e,t)=>e+t.priceDelta,0),o=(0,l.conflictsFor)((0,l.effectiveAllergens)(n,e.choiceIds),a);return[{itemId:n.id,name:n.name,qty:e.qty,unitPrice:i,choices:s.map(e=>e.label),notes:e.notes,contains:o.contains,may:o.may,overridden:!!e.override&&o.contains.every(t=>e.override.allergens.includes(t)),prepMins:n.prepMins}]})}const $=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},I=(0,r.create)()((0,n.persist)((e,t)=>{const a=()=>b(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:f('au'),restaurantId:t,at:a().toISOString(),kind:r,text:n},...e.audit].slice(0,300)})),n=(a,n,s)=>{if(!a||s<=0)return 0;const i=t().giftCards.find(e=>e.code===a&&e.restaurantId===n);if(!i||i.balance<=0)return 0;const o=Math.min(i.balance,s);return e(e=>({giftCards:e.giftCards.map(e=>e.id===i.id?{...e,balance:e.balance-o}:e)})),r(n,'giftcard',`Gift card ${a.slice(0,8)}\u2026 redeemed \xa3${(o/100).toFixed(2)} (balance \xa3${((i.balance-o)/100).toFixed(2)})`),o},i=e=>{const a=t().restaurants.find(t=>t.id===e.restaurantId);a&&e.customerId===t().customer.id&&e.subtotal>=a.settings.stampMinSpend&&t().addStamp(e.restaurantId,e.customerId,'takeaway'===e.type?'Takeaway (auto on collection)':'Table QR bill (auto on payment)')},o=e=>(0,u.templatesFor)(t().msgTemplates[e]),I=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,u.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},S=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&I((0,u.composeBooking)(e,r,n,o(n.id),a().toISOString()))},h=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&I((0,u.composeOrder)(e,r,o(r.id),a().toISOString()))};return{...k(),resetDemo:()=>e(k()),setClockMode:t=>{const a=(0,s.defaultSimStart)();e({clock:{mode:t,simStartMs:a.getTime(),anchorRealMs:Date.now()}})},skipMinutes:t=>e(e=>({clock:{...e.clock,simStartMs:e.clock.simStartMs+6e4*t}})),updateCustomer:t=>e(e=>({customer:{...e.customer,...t}})),setAllergy:(t,a)=>e(e=>{const r=e.customer.allergies.filter(e=>e.allergen!==t);return{customer:{...e.customer,allergies:a?[...r,{allergen:t,severity:a}]:r}}}),startBasket:(t,a,r)=>e(e=>{const n=e.basket.restaurantId===t&&e.basket.mode===a&&e.basket.tableNo===r;return{basket:{restaurantId:t,mode:a,tableNo:r,lines:n?e.basket.lines:[]}}}),addLine:t=>e(e=>({basket:{...e.basket,lines:[...e.basket.lines,{...t,key:f('ln')}]}})),setLineQty:(t,a)=>e(e=>({basket:{...e.basket,lines:a<=0?e.basket.lines.filter(e=>e.key!==t):e.basket.lines.map(e=>e.key===t?{...e,qty:a}:e)}})),overrideLine:(t,r)=>e(e=>({basket:{...e.basket,lines:e.basket.lines.map(e=>e.key===t?{...e,override:{allergens:r,at:a().toISOString()}}:e)}})),clearBasket:()=>e(e=>({basket:{...e.basket,lines:[]}})),placeOrder:({slotTime:s,tip:i,giftCardCode:o,notes:l,paidNow:c,phone:u,email:g})=>{const f=t(),b=f.basket,k=b.restaurantId,$=y(b,f.menu,f.customer.allergies),I=$.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,w=p(f.orders.filter(e=>e.restaurantId===k).map(e=>e.ref),S?'Q-':'T-',S?f.counters.table:f.counters.order),O=c?n(o,k,I+i):0,C=I+i,A={id:(0,m.uuid)(),ref:`${S?'Q':'T'}-${w}`,restaurantId:k,customerId:f.customer.id,customerName:f.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:$,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:c?C:0,status:'new',createdAt:a().toISOString(),allergies:f.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:u??f.customer.phone,email:g??f.customer.email}:{}};e(e=>({orders:[A,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:w}:{...e.counters,order:w}}));const v=$.filter(e=>e.overridden);return r(k,'order',`Order ${A.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),A.allergies.length&&r(k,'allergy',`Allergies declared and confirmed by customer on ${A.ref}: ${A.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),h(A),A},setOrderStatus:(a,n,s)=>{const o=t().orders.find(e=>e.id===a);o&&((0,g.statusBlock)(o,n,(0,g.linkedBooking)(o,t().bookings))||(e(e=>({orders:e.orders.map(e=>e.id===a?{...e,status:n}:e)})),r(o.restaurantId,'order',`${o.ref} \u2192 ${n}${s?` by ${s}`:''}`),'collected'===n&&'takeaway'===o.type&&i(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,g.canSign)(i,'kitchen',(0,g.linkedBooking)(i,t().bookings)))return;const o={by:s,at:a().toISOString()};e(e=>({orders:e.orders.map(e=>e.id===n?{...e,allergyAck:o,status:'new'===e.status?'acknowledged':e.status}:e)})),r(i.restaurantId,'allergy',`Allergen sign-off 3/5 Kitchen on ${i.ref}: ${s} (chef signed off before cooking)`)},tickOrderAllergy:(n,s,i,o=!0)=>{const l=t().orders.find(e=>e.id===n);if(!l)return;const c={...l.allergyTicks??{}};o?c[s]={by:i,at:a().toISOString()}:delete c[s],e(e=>({orders:e.orders.map(e=>e.id===n?{...e,allergyTicks:c}:e)})),r(l.restaurantId,'allergy',`${l.ref}: kitchen ${o?'confirmed':'unticked'} ${s} (${i})`)},ackReadiness:(n,s,i)=>{const o=t().orders.find(e=>e.id===n);o&&('cook'===s&&(0,g.statusBlock)(o,'preparing',(0,g.linkedBooking)(o,t().bookings))||(e(e=>({orders:e.orders.map(e=>e.id===n?{...e,readiness:{...e.readiness,[s]:{by:i,at:a().toISOString()}},status:'cook'===s&&['new','acknowledged'].includes(e.status)?'preparing':e.status}:e)})),r(o.restaurantId,'order',`${o.ref}: ${'cook'===s?'started cooking':'bagged'} (${i})`)))},handoverCheck:(n,s)=>{const i=t().orders.find(e=>e.id===n);i&&(0,g.canSign)(i,'table',(0,g.linkedBooking)(i,t().bookings))&&(e(e=>({orders:e.orders.map(e=>e.id===n?{...e,handoverCheck:{by:s,at:a().toISOString()}}:e)})),r(i.restaurantId,'allergy',`Allergen sign-off 5/5 Table on ${i.ref}: ${s} (served and checked with the guest; chain complete)`))},signAllergyStep:(n,s,i)=>{const o=t().orders.find(e=>e.id===n);if(!o||!i.trim())return!1;const l=(0,g.linkedBooking)(o,t().bookings);if(!(0,g.canSign)(o,s,l))return!1;if('kitchen'===s)return t().ackOrderAllergy(n,i),!0;if('table'===s)return t().handoverCheck(n,i),!0;const c={by:i,at:a().toISOString()};'booked'===s&&l&&l.allergies.length&&!l.allergyAck?e(e=>({bookings:e.bookings.map(e=>e.id===l.id?{...e,allergyAck:c}:e)})):e(e=>({orders:e.orders.map(e=>e.id===n?{...e,allergyChain:{...e.allergyChain,[s]:c}}:e)}));const u=(0,g.stepInfo)(s);return r(o.restaurantId,'allergy',`Allergen sign-off ${u.n}/5 ${u.label} on ${o.ref}: ${i} (${u.what.toLowerCase()})`),!0},customerSignal:(t,a)=>e(e=>({orders:e.orders.map(e=>e.id===t?{...e,customerSignal:a}:e)})),setSplit:(t,a,r)=>e(e=>({orders:e.orders.map(e=>e.id===t?{...e,tip:r,total:e.subtotal+r,split:{ways:a,paidShares:e.split?.paidShares??0}}:e)})),payTable:(a,{shares:s,giftCardCode:o})=>{const l=t().orders.find(e=>e.id===a);if(!l)return;const c=l.split?.ways??1,u=Math.ceil(l.total/c),g=Math.min(c,(l.split?.paidShares??0)+s),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*s),f=n(o,l.restaurantId,p),b={...l,giftCardApplied:l.giftCardApplied+f,giftCardCode:f?o:l.giftCardCode,paid:l.paid+p,split:{ways:c,paidShares:g},status:m?'closed':l.status};e(e=>({orders:e.orders.map(e=>e.id===a?b:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (demo payment)`),m&&i(b)},createBooking:n=>{const s=p(t().bookings.filter(e=>e.restaurantId===n.restaurantId).map(e=>e.ref),'BK-',t().counters.booking),i=t().restaurants.find(e=>e.id===n.restaurantId)?.settings,o='online'===n.source&&!!i&&(n.partySize>(i.autoAcceptUpTo??7)||!!i.reviewRequests&&!!n.notes.trim()),l={...n,id:(0,m.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,l],counters:{...e.counters,booking:s}})),r(l.restaurantId,'booking',`Booking ${o?'request ':''}${l.ref}: ${l.name}, ${l.partySize} on ${l.date} ${l.time}${l.source?` (${l.source})`:''}${l.allergies.length?' \u2014 allergies declared':''}`),S(o?'booking-request':'booking-confirmation',l),l},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const l={by:i,at:a().toISOString(),outcome:s},c='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:c,decided:l}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),S('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:c})},addOutbox:t=>e(e=>({outbox:[...t,...e.outbox].slice(0,300)})),updateOutbox:(t,a)=>e(e=>({outbox:e.outbox.map(e=>e.id===t?{...e,...a}:e)})),clearOutbox:t=>e(e=>({outbox:e.outbox.filter(e=>e.restaurantId!==t)})),setTemplate:(t,a,r)=>e(e=>{const n={...e.msgTemplates[t]??{}};return null===r?delete n[a]:n[a]={...n[a]??{},...r},{msgTemplates:{...e.msgTemplates,[t]:n}}}),acceptOrder:(n,s,i)=>{const o=t().orders.find(e=>e.id===n);if(!o)return!1;const l='new'===o.status&&!!(0,g.statusBlock)(o,'acknowledged',(0,g.linkedBooking)(o,t().bookings)),c=a(),u=i?new Date(c.getTime()+6e4*i).toISOString():o.readyBy;return e(e=>({orders:e.orders.map(e=>e.id===n?{...e,status:'new'!==e.status||l?e.status:'acknowledged',accepted:e.accepted??{by:s,at:c.toISOString()},readyBy:u}:e)})),r(o.restaurantId,'order',`${o.ref} accepted by ${s}${i?`, ready by ${String(new Date(u).getHours()).padStart(2,'0')}:${String(new Date(u).getMinutes()).padStart(2,'0')}`:''}`),!l},setBookingStatus:(n,s)=>{const i=t().bookings.find(e=>e.id===n),o=a().toISOString();e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:s,...'seated'===s?{seatedAt:o}:'finished'===s?{finishedAt:o}:{}}:e)})),i&&r(i.restaurantId,'booking',`${i.ref} ${i.name} \u2192 ${s}`)},seatWalkIn:(n,s,i,o)=>{const l=a(),c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,u=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,g=t().bookings.filter(e=>e.restaurantId===n&&e.walkIn&&e.date===c).reduce((e,t)=>Math.max(e,Number(t.ref.slice(2))||0),0)+1,p={id:(0,m.uuid)(),ref:`W-${g}`,restaurantId:n,customerId:null,name:'Walk-in',partySize:s,date:c,time:u,table:i||void 0,allergies:[],notes:(o??'').trim(),status:'seated',security:'none',depositPaid:0,createdAt:l.toISOString(),seatedAt:l.toISOString(),walkIn:!0,source:'walk-in'};return e(e=>({bookings:[...e.bookings,p]})),r(n,'walkin',`Walk-in ${p.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),p},setBookingTable:(a,n)=>{const s=t().bookings.find(e=>e.id===a);e(e=>({bookings:e.bookings.map(e=>e.id===a?{...e,table:n}:e)})),s&&r(s.restaurantId,'booking',`${s.ref} ${s.name} \u2192 Table ${n}`)},updateBooking:(a,n)=>{const s=t().bookings.find(e=>e.id===a);e(e=>({bookings:e.bookings.map(e=>e.id===a?{...e,...n}:e)})),s&&r(s.restaurantId,'booking',`${s.ref} ${s.walkIn?'Walk-in':s.name} moved/updated${n.table?` \u2192 Table ${n.table}`:''}${n.time?` at ${n.time}`:''}${n.durationMins?` for ${n.durationMins} min`:''}`)},undoWalkIn:a=>{const n=t().bookings.find(e=>e.id===a);n&&n.walkIn&&(e(e=>({bookings:e.bookings.filter(e=>e.id!==a)})),r(n.restaurantId,'walkin',`Walk-in ${n.ref} undone`))},ackBookingAllergy:(n,s)=>{const i=t().bookings.find(e=>e.id===n);i&&!i.allergyAck&&(e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,allergyAck:{by:s,at:a().toISOString()}}:e)})),r(i.restaurantId,'allergy',`Allergen sign-off 1/5 Booked on ${i.ref} (${i.name}): ${s} (allergy recorded)`))},joinWaitlist:(n,s,i,o)=>{const l=t().waitlist.filter(e=>e.restaurantId===n).reduce((e,t)=>Math.max(e,t.number),0)+1,c={id:f('wl'),restaurantId:n,number:l,name:s,partySize:i,joinedAt:a().toISOString(),status:'waiting',customerId:o};return e(e=>({waitlist:[...e.waitlist,c]})),r(n,'waitlist',`${s} (${i}) joined the waitlist as #${l}`),c},setWaitlistStatus:(a,n)=>{const s=t().waitlist.find(e=>e.id===a);e(e=>({waitlist:e.waitlist.map(e=>e.id===a?{...e,status:n}:e)})),s&&(r(s.restaurantId,'waitlist',`Waitlist #${s.number} ${s.name} \u2192 ${n}`),'seated'===n&&t().addWalkIn(s.restaurantId,s.partySize))},addWalkIn:(t,a)=>{e(e=>({walkIns:{...e.walkIns,[t]:(e.walkIns[t]??0)+a}})),r(t,'walkin',`Walk-in seated: ${a} cover(s)`)},addStamp:(n,s,i)=>{const o=t().restaurants.find(e=>e.id===n);o&&(e(e=>{const t=e.stampCards.find(e=>e.restaurantId===n&&e.customerId===s),r=t??{restaurantId:n,customerId:s,stamps:0,rewardsAvailable:0,history:[]};let l=r.stamps+1,c=r.rewardsAvailable;l>=o.settings.stampTarget&&(l=0,c+=1);const u={...r,stamps:l,rewardsAvailable:c,history:[{at:a().toISOString(),source:i},...r.history]};return{stampCards:t?e.stampCards.map(e=>e===t?u:e):[...e.stampCards,u]}}),r(n,'stamp',`Stamp added (${i})`))},redeemReward:(t,a)=>{e(e=>({stampCards:e.stampCards.map(e=>e.restaurantId===t&&e.customerId===a&&e.rewardsAvailable>0?{...e,rewardsAvailable:e.rewardsAvailable-1}:e)})),r(t,'stamp','Loyalty reward redeemed')},buyGiftCard:(n,s,i,o)=>{const l=n.slice(0,3).toUpperCase(),c={id:f('gc'),code:$(l),restaurantId:n,initial:s,balance:s,ownerId:t().customer.id,recipientName:i,message:o,createdAt:a().toISOString()};return e(e=>({giftCards:[c,...e.giftCards]})),r(n,'giftcard',`Gift card sold \xa3${(s/100).toFixed(2)} (demo payment)`),c},redeemGiftCard:(a,n,s)=>{const i=t().giftCards.find(e=>e.code.toUpperCase()===a.trim().toUpperCase());return!(!i||n<=0||n>i.balance)&&(e(e=>({giftCards:e.giftCards.map(e=>e.id===i.id?{...e,balance:e.balance-n}:e)})),r(i.restaurantId,'giftcard',`Gift card ${i.code} redeemed \xa3${(n/100).toFixed(2)} by ${s}`),!0)},honourLegacyCard:(t,n,s,i)=>{const o={id:f('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy Wix gift card',message:`Honoured by ${i}`,createdAt:a().toISOString().slice(0,10),legacy:!0};return e(e=>({giftCards:[o,...e.giftCards]})),r(t,'giftcard',`Legacy Wix gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:f('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:f('rt'),createdAt:a().toISOString()},...e.ratings],orders:t.orderId?e.orders.map(e=>e.id===t.orderId?{...e,rated:!0}:e):e.orders})),r(t.restaurantId,'rating',`Private rating ${t.stars}/5 from ${t.customerName}`)},updateMenuItem:(a,n)=>{const{name:s,section:i,price:o,allergens:l,allergenNotes:u,...g}=n,m={};void 0!==s&&(m.dish=s),void 0!==i&&(m.section=i),'price'in n&&(m.price=o??null),void 0!==l&&(m.allergens=l),'allergenNotes'in n&&(m.allergenNotes=u);const p='optionGroups'in n,f=(0,c.menuCardBridge)();f&&(Object.keys(m).length||p)&&f.menuEdited(a,m,'Cover Charge for Managers',p);const b=f?g:n;Object.keys(b).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...b}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(b).length&&r(k.restaurantId,'menu',`Menu: ${(0,c.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,c.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'Cover Charge for Managers',!0):e(e=>({menu:e.menu.map(e=>e.id===t?{...e,signOff:r?{by:r,at:a().toISOString().slice(0,10)}:null}:e)}))},addAudit:(e,t,a)=>r(e,t,a),updateSettings:(t,a)=>{e(e=>({restaurants:e.restaurants.map(e=>e.id===t?{...e,settings:{...e.settings,...a}}:e)})),'takeawayPaused'in a&&r(t,'order',"Takeaway slots "+(a.takeawayPaused?'PAUSED':'resumed'))},addMenuItem:t=>{const a=f('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,c.menuCardBridge)()?.menuItemAdded({...t,id:a}),r(t.restaurantId,'menu',`Menu: ${t.name} added (recipe card awaiting head chef sign-off)`),a},updateRestaurant:(t,a)=>{e(e=>({restaurants:e.restaurants.map(e=>e.id===t?{...e,...a}:e)})),r(t,'menu',`Restaurant info updated (${Object.keys(a).join(', ')})`)},placeManualOrder:({restaurantId:n,type:s,channel:i,customerName:o,phone:u,email:g,tableNo:f,slotTime:b,lines:k,allergies:y,notes:$,by:I})=>{const S=t(),w=k.flatMap(({itemId:e,qty:t})=>{const a=S.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,c.resolveItem)(a),n=(0,l.conflictsFor)((0,l.effectiveAllergens)(r),y);return[{itemId:e,name:r.name,qty:t,unitPrice:r.price??0,choices:[],notes:'',contains:n.contains,may:n.may,overridden:!1,prepMins:r.prepMins}]}),O=w.reduce((e,t)=>e+t.unitPrice*t.qty,0),C='table'===s,A=p(S.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?S.counters.table:S.counters.order),v={id:(0,m.uuid)(),ref:`${C?'Q':'T'}-${A}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${f}`:'Walk-in'),type:s,tableNo:f,slotTime:b,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:y,readiness:{},notes:$,channel:i,...u?{phone:u}:{},...g?{email:g}:{},...y.length?{allergyChain:{booked:{by:I,at:a().toISOString()}}}:{}};return e(e=>({orders:[v,...e.orders],counters:C?{...e.counters,table:A}:{...e.counters,order:A}})),r(n,'order',`Order ${v.ref} taken by ${I} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${f}`})`),y.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${v.ref}: ${I} recorded ${y.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(u||g)&&h(v),v},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:6,migrate:(e,t)=>{if(!e)return e;if(t<6){try{e.restaurants=(e.restaurants??[]).map(e=>'saltmarsh'===e?.id?{...e,name:'The Venue'}:e)}catch{}try{e.restaurants=(e.restaurants??[]).map(e=>'anchorage'===e?.id&&JSON.stringify(e.kitchenHours)===JSON.stringify(i.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:i.ANCHORAGE_KITCHEN,hoursNote:'Kitchen (food) hours from Gordon, 30 Oct 2026: closed Mon\u2013Tue. The closing time is last food orders. Bar hours not set.'}:e)}catch{}}if(t<5)try{e.events=(e.events??[]).map(e=>'string'==typeof e?.title&&/\(substitute day\)/i.test(e.title)?{...e,title:e.title.replace(/\s*\(substitute day\)/gi,'').trim()}:e)}catch{}if(t<4)try{e.restaurants=(e.restaurants??[]).map(e=>'anchorage'===e.id&&e.settings&&!e.settings.pay?{...e,settings:{...e.settings,pay:i.ANCHORAGE_PAY}}:e)}catch{}if(t<3)try{e.restaurants=(e.restaurants??[]).map(e=>'anchorage'===e.id?{...e,settings:{...e.settings,orderAtTable:!1}}:e),e.orders=(e.orders??[]).filter(e=>'ord-seed-3'!==e.id&&'Q-2018'!==e.ref),e.audit=(e.audit??[]).filter(e=>!String(e.text??'').includes('Q-2018'))}catch{}if(t>=2)return e;try{const t=(0,s.buildSeed)((0,s.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,o.anchoragePlan)().tables.map(e=>e.name)),n=e=>!e||e.split('+').every(e=>r.has(e));e.bookings=(e.bookings??[]).map(e=>{const t=a.get(e.id);return t?{...e,table:t.table,dog:t.dog,notes:t.notes}:'anchorage'!==e.restaurantId||n(e.table)?e:{...e,table:void 0}})}catch{}return e},storage:(0,n.createJSONStorage)(()=>a.default)}))},855,[975,974,976,1012,1015,895,792,978,800,893,920]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VENUE_RID",{enumerable:!0,get:function(){return t}});const t='anchorage'.toLowerCase().replace(/[^a-z0-9-]/g,'')||'anchorage'},856,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShallow",{enumerable:!0,get:function(){return o}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]);function o(e){const t=u.default.useRef(void 0);return u=>{const o=e(u);return(0,n.shallow)(t.current,o)?t.current:t.current=o}}},857,[12,1021]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CoversToday=function({rid:e,onPress:y,big:f,sound:x,testID:C="covers-today"}){const j=(0,n.useBookings)(e),p=(0,n.useNow)(3e4),v=(0,c.coversToday)(j,(0,u.ymd)(p)),T=f?64:44,w=v.total?Math.min(1,v.done/v.total):0,D=(e,o,n,c)=>(0,b.jsxs)(t.default,{style:{flex:1,alignItems:'center',gap:6,minWidth:0},children:[(0,b.jsx)(s.SplitFlap,{value:o,height:T,colour:n,testID:`covers-${c}`,sound:x}),(0,b.jsx)(l.T,{size:f?14:12,weight:"semibold",colour:h.colours.muted,numberOfLines:1,style:{letterSpacing:.4},children:e})]}),k=v.lunch.done+v.lunch.toCome>0&&v.dinner.done+v.dinner.toCome>0;return(0,b.jsxs)(o.default,{testID:C,accessibilityRole:"button",disabled:!y,onPress:y,accessibilityLabel:`Covers today: ${v.done} done, ${v.toCome} to come, ${v.total} in total.${y?' Opens today\u2019s bookings.':''}`,style:({pressed:e})=>({backgroundColor:e?h.colours.tilePressed:h.colours.surface,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,padding:16,gap:12}),children:[(0,b.jsxs)(t.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,b.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,style:{letterSpacing:1.6},children:"COVERS TODAY"}),y?(0,b.jsx)(l.T,{size:12,colour:h.colours.muted,children:"Today\u2019s bookings \u203a"}):null]}),(0,b.jsxs)(t.default,{style:{flexDirection:'row',gap:8},children:[D('Covers done',v.done,h.colours.text,'done'),D('Covers to come',v.toCome,h.colours.text,'tocome'),D('Total covers today',v.total,h.colours.goldLight,'total')]}),(0,b.jsx)(t.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,b.jsx)(t.default,{style:{width:`${Math.round(100*w)}%`,height:4,backgroundColor:h.colours.gold,borderRadius:2}})}),k?(0,b.jsxs)(l.T,{size:12,colour:h.colours.muted,center:!0,children:["Lunch ",v.lunch.done," done \xb7 ",v.lunch.toCome," to come \xb7 Dinner ",v.dinner.done," done \xb7 ",v.dinner.toCome," to come"]}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),s=r(d[3]),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),b=r(d[9])},876,[12,245,109,1003,791,797,805,796,799,6]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LastFoodBanner=function({rid:e,now:o,big:c}){const f=(0,l.useRestaurant)(e),h=u(o),$=(0,l.useEvents)(e).filter(e=>e.date===h&&'regular'===e.source),b=f?(0,s.lastFoodOn)(f,h):null;if(!b)return null;const p=new Date(`${h}T${b.time}:00`),T=Math.round((p.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(T>90&&!_)return null;if(T<-60)return null;const v=T>=0&&T<=15,w=T<0,x=v?n.colours.redBg:w?n.colours.surface2:n.colours.goldTint,y=v?n.colours.red:w?n.colours.hairline:n.colours.accentBorder,D=v?'#FFD9D4':w?n.colours.muted:n.colours.goldLight,F=c?1.3:1,L=w?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:v?`Last food orders in ${Math.max(0,T)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:v?'last-food-warning':'last-food-banner',accessibilityRole:v?'alert':'text',accessibilityLiveRegion:v?'assertive':'polite',style:{borderRadius:14,borderWidth:v?2:1,borderColor:y,backgroundColor:x,paddingVertical:10*F,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*F,weight:"bold",colour:D,children:[v?'\u23f0 ':'\ud83c\udf7d ',L]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*F,colour:n.colours.muted,children:[j?`Tonight: ${j}`:'','kitchen closes'!==b.reason&&b.reason!==_?.title?`Early last orders (${b.reason})`:''].filter(Boolean).join(' \xb7 ')}):null]})},_r(_d[0]);var e,o=_r(_d[1]),t=(e=o)&&e.__esModule?e:{default:e},r=_r(_d[2]),l=_r(_d[3]),s=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]);const u=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},877,[12,109,791,797,789,799,6]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=x,_e.NextTableFreeCard=function({rid:e,now:t,big:s,always:n}){const d=(0,o.useRestaurant)(e),u=x(e,t);if(!d||!u||!(0,h.nextTableOn)(d))return null;if(!u.full&&!n)return null;const T=u.list.slice(0,3),j=u.waitFor(2),w=u.waitFor(4),p=(0,h.lastFoodOn)(d,g(t)),y=s?1.25:1,M=(e,s)=>(0,f.jsxs)(r.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,f.jsxs)(l.Muted,{children:["Wait for ",e]}),(0,f.jsx)(l.T,{size:20*y,weight:"bold",colour:b.colours.goldLight,children:s?`~${Math.max(5,Math.round((s.at.getTime()-t.getTime())/6e4))} min`:'\u2014'}),(0,f.jsx)(l.Muted,{children:s?`T${s.table} \xb7 ${s.confidence}`:'nothing due yet'})]});return(0,f.jsxs)(r.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:b.colours.accentBorder,backgroundColor:b.colours.surface,padding:14,gap:8},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.4},children:u.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,f.jsx)(l.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,f.jsxs)(l.T,{size:22*y,weight:"bold",children:["~",(0,c.hhmm)(T[0].at)," ",(0,f.jsxs)(l.T,{size:16*y,colour:b.colours.muted,children:["(T",T[0].table,", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,f.jsx)(l.T,{size:18*y,weight:"semibold",children:u.freeNow.length?`Free now: ${u.freeNow.map(e=>`T${e}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,f.jsxs)(l.Muted,{children:["Then ~",(0,c.hhmm)(e.at)," \xb7 T",e.table," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,f.jsxs)(l.Muted,{children:["T",T[0].table,": ",T[0].why,"."]}):null,(0,f.jsxs)(l.Row,{gap:8,children:[M(2,j),M(4,w)]}),T.some(e=>e.drinksOnly)&&p?(0,f.jsxs)(l.T,{size:13,colour:b.colours.amber,children:["After last food orders (",(0,h.fmt12)(p.time),") a table is for drinks only."]}):null,(0,f.jsx)(l.Muted,{children:"Tap Bill requested or Table finished on the plan and this updates straight away."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),r=(e=s)&&e.__esModule?e:{default:e},l=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),f=_r(_d[10]);const g=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,c.hhmm)(e);function x(e,s){const r=(0,o.useRestaurant)(e),l=(0,d.usePlan)(e),h=(0,o.useBookings)(e),b=(0,o.useOrders)(e),f=(0,d.useFloor)(t=>t.live[e]),x=(0,n.useBlocks)(e=>e.blocks),j=s.getTime()/6e4|0;return(0,t.useMemo)(()=>{if(!r)return null;const t=g(s),o=(0,n.closedAreasAt)(x,e,t,T(s)),d=(0,u.floorView)(l,h,b,f??{},s,r.settings.turnMins,o);return(0,c.nextTablesFree)(r,d,h.filter(e=>e.date===t),s,h)},[r,l,h,b,f,x,j])}},878,[12,109,791,797,801,802,803,979,789,799,6]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=j,_e.DayBar=function({app:e,today:r}){const n=j(e,r),d=p(e=>e.set),a=n??r,c=Math.round(((0,h.parseYmd)(a).getTime()-(0,h.parseYmd)(r).getTime())/864e5),[u,m]=f[e],x=s=>{const t=(0,h.ymd)((0,h.addMins)((0,h.parseYmd)(a),1440*s+120));d(e,t===r?null:t)};(0,s.useEffect)(()=>{if('display'!==e||!n)return;const s=setTimeout(()=>d(e,null),12e4);return()=>clearTimeout(s)},[e,n,d]);const T=0===c?`Today \xb7 ${(0,h.niceDate)((0,h.parseYmd)(r))}`:-1===c?`Yesterday \xb7 ${(0,h.niceDate)((0,h.parseYmd)(a))}`:1===c?`Tomorrow \xb7 ${(0,h.niceDate)((0,h.parseYmd)(a))}`:(0,h.niceDate)((0,h.parseYmd)(a)),w=(e,s,o,r,n)=>(0,b.jsx)(t.default,{testID:n,accessibilityRole:"button",accessibilityLabel:s,disabled:r,onPress:o,hitSlop:8,style:({pressed:e})=>({width:40,height:40,borderRadius:20,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:y.colours.hairline,opacity:r?.35:1,backgroundColor:e?y.colours.tilePressed:'transparent'}),children:(0,b.jsx)(l.T,{size:20,colour:y.colours.goldLight,children:e})});return(0,b.jsxs)(o.default,{testID:"day-bar",style:{flexDirection:'row',alignItems:'center',gap:8},children:[w('\u2039','Previous day',()=>x(-1),c<=u,'day-prev'),(0,b.jsxs)(o.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,b.jsx)(l.T,{size:14,weight:"semibold",colour:n?y.colours.goldLight:y.colours.text,numberOfLines:1,children:T}),n?(0,b.jsxs)(l.T,{size:11,colour:y.colours.goldMuted,style:{letterSpacing:1.4},children:["TIME TRAVEL \xb7 ",c<0?'PAST':'AHEAD']}):null]}),w('\u203a','Next day',()=>x(1),c>=m,'day-next'),n?(0,b.jsx)(t.default,{testID:"day-today",accessibilityRole:"button",accessibilityLabel:"Back to today",onPress:()=>d(e,null),style:({pressed:e})=>({paddingHorizontal:12,height:40,borderRadius:20,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:y.colours.gold,backgroundColor:e?y.colours.tilePressed:'transparent'}),children:(0,b.jsx)(l.T,{size:13,weight:"semibold",colour:y.colours.goldLight,children:"Today"})}):null]})},_e.DayView=function({rid:e,day:t,today:r,app:p}){const f=(0,n.useRestaurant)(e),j=(0,n.useBookings)(e),T=(0,n.useOrders)(e),w=(0,n.useEvents)(e),C=(0,h.parseYmd)(t),D=tf&&!D?(0,a.forecastToday)(f,j,T,w,C):null,[f,j,T,w,t]);if(!f)return null;const k=(0,c.kitchenHoursOn)(f,C),O=(0,c.seasonOn)(f,C),M=(0,u.lastFoodOn)(f,t),v=w.filter(e=>e.date===t),z=(0,u.regularEventsOf)(f).filter(e=>(0,u.occursOn)(e,t)),I=(0,d.coversToday)(j,t),L=j.filter(e=>e.date===t).sort((e,s)=>e.time.localeCompare(s.time)),R=L.filter(d.ACTIVE),E=L.length-R.length,A=L.filter(e=>'noshow'===e.status).length,P='display'===p;return(0,b.jsxs)(o.default,{testID:"day-view",style:{gap:12},children:[(0,b.jsxs)(l.Card,{children:[(0,b.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(l.T,{weight:"semibold",colour:y.colours.gold,children:[(0,h.niceDate)(C),O?` \xb7 ${O.name} hours`:'']}),(0,b.jsx)(l.Badge,{kind:"gold",label:D?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,b.jsxs)(l.T,{size:P?18:15,children:[k?`Kitchen ${x(k[0])}\u2013${x(k[1])}`:'Kitchen closed',k&&M&&'kitchen closes'!==M.reason?` \xb7 last food orders ${x(M.time)} (${M.reason})`:'']}),z.map(e=>(0,b.jsxs)(l.T,{size:14,colour:y.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${x(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),v.map(e=>(0,b.jsxs)(l.T,{size:14,colour:y.colours.goldLight,children:["\u2605 ",(0,d.holidayName)(e.title)]},e.id)),(0,b.jsx)(l.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,b.jsxs)(l.Card,{children:[(0,b.jsx)(l.T,{size:12,weight:"semibold",colour:y.colours.goldMuted,style:{letterSpacing:1.6},children:D?'COVERS THAT DAY':'COVERS BOOKED'}),(0,b.jsxs)(l.Row,{gap:18,wrap:!0,children:[(0,b.jsxs)(o.default,{children:[(0,b.jsx)(l.T,{size:P?44:32,weight:"semibold",colour:y.colours.goldLight,children:D&&I.done||I.total}),(0,b.jsx)(l.Muted,{children:D?'covers':'booked so far'})]}),$?(0,b.jsxs)(o.default,{children:[(0,b.jsx)(l.T,{size:P?44:32,weight:"semibold",children:$.open?`${$.restOfDay.low}\u2013${$.restOfDay.high}`:'\u2013'}),(0,b.jsx)(l.Muted,{children:$.open?'expected in total (estimate)':'closed'})]}):null,(0,b.jsxs)(o.default,{children:[(0,b.jsx)(l.T,{size:P?44:32,weight:"semibold",children:R.length}),(0,b.jsx)(l.Muted,{children:1===R.length?'booking':'bookings'})]})]}),I.lunch.done+I.lunch.toCome>0&&I.dinner.done+I.dinner.toCome>0?(0,b.jsxs)(l.Muted,{children:["Lunch ",I.lunch.done+I.lunch.toCome," \xb7 Dinner ",I.dinner.done+I.dinner.toCome," covers"]}):null,E?(0,b.jsxs)(l.Muted,{children:[E," cancelled",A?`, including ${A} no-show${1===A?'':'s'}`:'',"."]}):null]}),(0,b.jsx)(m.PlattersBooked,{rid:e,date:t,label:D?'Platters that day':'Platters booked'}),R.length?R.map(e=>(0,b.jsxs)(o.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:y.colours.hairline,backgroundColor:y.colours.surface},children:[(0,b.jsxs)(l.T,{weight:"semibold",children:[e.time," \xb7 ",e.walkIn?`Walk-in ${e.ref}`:e.name," \xb7 ",e.partySize," covers",e.table?` \xb7 T${e.table}`:'']}),(0,b.jsx)(m.BookingNeeds,{b:e})]},e.id)):(0,b.jsx)(l.Muted,{children:D?'No bookings that day.':'No bookings yet for this day.'})]})};var s=_r(_d[0]),t=e(_r(_d[1])),o=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),a=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),b=_r(_d[13]);const p=(0,r.create)(e=>({day:{},set:(s,t)=>e(e=>({day:{...e.day,[s]:t??void 0}}))})),f={owner:[-365,365],chef:[-365,365],display:[-30,60],staff:[-7,14]},x=e=>{const[s,t]=e.split(':').map(Number);return`${s%12||12}${t?`:${String(t).padStart(2,'0')}`:''}${s<12?'am':'pm'}`};function j(e,s){const t=p(s=>s.day[e]);return t&&t!==s?t:null}},879,[12,245,109,974,791,797,805,853,793,789,796,799,894,6]); +__d(function(_g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"setDisplaySilent",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"soundAllowed",{enumerable:!0,get:function(){return u}}),e.chime=function(t="bright"){if(!u())return void l('__ccChimesBlocked');try{const n=o();if(!n)return;('bright'===t?[880,1318.5]:[659.3]).forEach((o,c)=>{const i=n.currentTime+.16*c,u=n.createOscillator(),l=n.createGain();u.type='sine',u.frequency.value=o,l.gain.setValueAtTime(1e-4,i),l.gain.exponentialRampToValueAtTime('bright'===t?.12:.07,i+.02),l.gain.exponentialRampToValueAtTime(1e-4,i+.9),u.connect(l).connect(n.destination),u.start(i),u.stop(i+.95)}),l('__ccChimes')}catch{}},Object.defineProperty(e,"LOW_CHIME_MIN",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"LOW_CHIME_MAX",{enumerable:!0,get:function(){return d}}),e.lowChime=function(t=0){if(!u())return void l('__ccChimesBlocked');const n=s+.095*Math.max(0,Math.min(1,t));'undefined'!=typeof window&&(window.__ccLowChimeLevels=[...window.__ccLowChimeLevels??[],Math.round(1e3*n)/1e3].slice(-40));try{const t=o();if(!t)return;[220,164.8].forEach((o,c)=>{const i=t.currentTime+.42*c,u=t.createOscillator(),l=t.createGain(),s=t.createBiquadFilter?.();u.type='triangle',u.frequency.value=o,l.gain.setValueAtTime(1e-4,i),l.gain.exponentialRampToValueAtTime(n,i+.12),l.gain.exponentialRampToValueAtTime(1e-4,i+1.6),s?(s.type='lowpass',s.frequency.value=900,u.connect(s).connect(l).connect(t.destination)):u.connect(l).connect(t.destination),u.start(i),u.stop(i+1.7)}),l('__ccLowChimes')}catch{}},Object.defineProperty(e,"flapSoundOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setFlapSound",{enumerable:!0,get:function(){return w}}),e.flapClick=function(){if('display'!==t.APP_VARIANT&&!c)return;if(!p())return;try{const t=o();if(!t)return;const n=t.currentTime,c=Math.floor(.03*t.sampleRate),i=t.createBuffer(1,c,t.sampleRate),u=i.getChannelData(0);for(let t=0;t{if('undefined'==typeof window)return null;const t=window.AudioContext||window.webkitAudioContext;return t?(n||(n=new t),'suspended'===n.state&&n.resume?.().catch?.(()=>{}),n):null};if('undefined'!=typeof window){const t=()=>{try{o()}catch{}window.removeEventListener('pointerdown',t)};window.addEventListener('pointerdown',t)}let c=!1;const i=t=>{c=t},u=()=>'display'!==t.APP_VARIANT&&!c,l=t=>{'undefined'!=typeof window&&(window[t]=(window[t]??0)+1)};const s=.015,d=.11;const f='cc-flap-sound',p=()=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(f)}catch{return!1}},w=t=>{try{localStorage.setItem(f,t?'1':'0')}catch{}}},880,[104,787]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SeatAllergenReminder=function({rid:e}){const[n,c]=(0,t.useState)(null),b=(0,t.useRef)(new Set);return(0,t.useEffect)(()=>o.useStore.subscribe((t,n)=>{if(t.bookings===n.bookings)return;const s=new Map(n.bookings.map(e=>[e.id,e.status]));for(const n of t.bookings){if(n.restaurantId!==e||'seated'!==n.status||!(0,u.hasAllergens)(n)||b.current.has(n.id))continue;const t=s.get(n.id);t&&'seated'!==t&&(b.current.add(n.id),c(n))}}),[e]),n?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>c(null),title:"Re-confirm allergens at the table",testID:"seat-allergen-reminder",children:[(0,f.jsxs)(s.default,{style:{backgroundColor:h.colours.redSolid,borderRadius:12,padding:12,gap:4},children:[(0,f.jsxs)(l.T,{weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ",n.name," \xb7 ",n.partySize," covers",n.table?` \xb7 T${n.table}`:'']}),(0,f.jsx)(l.T,{colour:"#FFFFFF",children:(0,u.allergenText)(n)})]}),(0,f.jsx)(l.Muted,{children:"Before taking the order, check the allergens with the guests again and tell the kitchen about any change."}),(0,f.jsx)(l.Button,{kind:"success",label:"Done, re-confirmed with the guests",testID:"seat-allergen-ok",onPress:()=>c(null)})]}):null},_e.useKitchenTodoChime=function(e,n){const s=(0,o.useStore)(t=>t.bookings.filter(t=>t.restaurantId===e&&t.date>=n&&!t.walkIn&&((0,u.needsAllergenSeen)(t)||(0,u.needsHoldOk)(t))).length),l=(0,t.useRef)(null);return(0,t.useEffect)(()=>{null!==l.current&&s>l.current&&(0,c.soundAllowed)()&&(0,c.chime)('bright'),l.current=s},[s]),s};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),f=r(d[7])},881,[12,109,791,797,805,880,799,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceSlot",{enumerable:!0,get:function(){return w}}),_e.voiceAppFor=S,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56}){const t=p(),u=(0,n.useRef)(null),c=(0,n.useRef)(y++).current,{width:l,height:f}=(0,o.default)(),S=()=>u.current?.measureInWindow((e,t,n)=>{n&&w.setState({rect:{x:e,y:t,size:n},owner:c})});return(0,n.useEffect)(()=>{const e=setTimeout(S,50);return()=>clearTimeout(e)},[l,f,t?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===c&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{t?.on||w.getState().owner!==c||w.setState({rect:null,owner:0})},[t?.on]),t?.on?(0,h.jsx)(s.default,{ref:u,testID:"voice-slot",onLayout:S,style:{width:e,height:e,flexShrink:0}}):null};var t=r(d[0]),n=r(d[1]),o=e(r(d[2])),s=e(r(d[3])),u=r(d[4]),c=r(d[5]),l=r(d[6]),f=r(d[7]),h=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function S(e){return'customer'===c.APP_VARIANT||/^\/(customer|table|demo)/.test(e)?null:e.startsWith('/owner')||e.startsWith('/admin')?'owner':e.startsWith('/team')?'staff':e.startsWith('/kitchen')?'chef':e.startsWith('/display')?'display':null}function p(){const e=(0,t.usePathname)()||'/',n=(0,l.useCtx)(6e4),o=(0,f.useVoiceSettings)(e=>e.enabled),s=S(e);if(!s)return null;const u='owner'===s?'owner'===n.role?'owner':'manager'===n.role?'manager':'staff':s;return{app:s,role:u,actions:'staff'===u?'staff':s,on:(0,f.voiceOn)(o,n.rid,u)}}let y=1},882,[785,12,269,109,974,787,884,973,6]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BUILTIN_LOGOS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"HERO_LOGOS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"HEADER_LOGO",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"ACCENTS",{enumerable:!0,get:function(){return x}}),_e.useBrandRid=j,_e.useBrand=p,_e.PoweredBy=O,_e.RestaurantLogo=F,_e.RestaurantHero=function({rid:e,size:t=200,showPlace:l=!0}){const s=p(e),u=s.custom?s.logo:y[s.rid]??s.logo;return(0,f.jsxs)(o.default,{testID:"restaurant-hero",style:{alignItems:'center',gap:6},children:[u?(0,f.jsx)(n.default,{source:u,accessibilityLabel:`${s.name} logo`,style:{width:t,height:t,borderRadius:s.custom?t/2:0},resizeMode:"contain"}):(0,f.jsx)(F,{rid:s.rid,size:t}),(0,f.jsx)(r.default,{style:{fontFamily:c.fonts.semibold,fontSize:26,lineHeight:34,color:c.colours.text,textAlign:'center'},children:s.name}),l&&s.place?(0,f.jsx)(r.default,{style:{fontFamily:c.fonts.regular,fontSize:14,lineHeight:20,color:s.accent,textAlign:'center'},children:s.place}):null]})},_e.RestaurantBrand=function({rid:e,sub:t,size:n=b,nameSuffix:l}){const s=p(e);return(0,f.jsxs)(o.default,{style:{gap:2,flexShrink:1},children:[(0,f.jsx)(O,{}),(0,f.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,f.jsx)(F,{rid:s.rid,size:n}),(0,f.jsxs)(o.default,{style:{flexShrink:1},children:[(0,f.jsxs)(r.default,{numberOfLines:1,style:{fontFamily:c.fonts.semibold,fontSize:17,lineHeight:22,color:c.colours.text},children:[s.name,l??'']}),t?(0,f.jsx)(r.default,{numberOfLines:1,style:{fontFamily:c.fonts.regular,fontSize:12,lineHeight:16,color:s.accent},children:t}):null]})]})]})};var t=_r(d[0]);_r(d[1]);var n=e(_r(d[2])),r=e(_r(d[3])),o=e(_r(d[4])),l=_r(d[5]),s=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]);const h={anchorage:_r(d[10]),saltmarsh:_r(d[11]),brae:_r(d[12])},y={anchorage:_r(d[13])},b=48,x=['#CFA45F','#D4AF61','#C9A24A','#E2C489','#F2EDE4','#5FA8CF','#7FB069','#D9774B'];function j(e){const n=(0,t.useGlobalSearchParams)(),r=(0,s.useOwner)(e=>e.site),o='string'==typeof n.rid?n.rid:void 0;return e??o??r??u.VENUE_RID}function p(e){const t=j(e),n=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===t)),r=(0,s.useOwner)(e=>e.branding[t]),o=r?.logoUri?{uri:r.logoUri}:h[t];return{rid:t,name:n?.name??'Restaurant',place:n?.location??'',logo:o,accent:r?.accent??c.colours.gold,custom:!!r?.logoUri}}function O({size:e=10}){return(0,f.jsxs)(r.default,{accessibilityLabel:"powered by CoverCharge",style:{fontFamily:c.fonts.regular,fontSize:e,lineHeight:Math.round(1.35*e),color:c.colours.muted},children:["powered by ",(0,f.jsx)(r.default,{style:{fontFamily:c.fonts.semibold,color:c.colours.text},children:"Cover"}),(0,f.jsx)(r.default,{style:{fontFamily:c.fonts.semibold,color:c.colours.gold},children:"Charge"})]})}function F({rid:e,size:t=b}){const l=p(e);if(l.logo)return(0,f.jsx)(n.default,{source:l.logo,accessibilityLabel:`${l.name} logo`,style:{width:t,height:t,borderRadius:l.custom?t/2:0},resizeMode:"contain"});const s=l.name.replace(/^The /,'').split(/\s+/).map(e=>e[0]).join('').slice(0,2).toUpperCase();return(0,f.jsx)(o.default,{accessibilityLabel:`${l.name} logo`,style:{width:t,height:t,borderRadius:t/2,borderWidth:2,borderColor:l.accent,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(r.default,{style:{fontFamily:c.fonts.bold,color:l.accent,fontSize:.36*t},children:s})})}},883,[785,12,178,188,109,797,813,799,856,6,1030,1031,1032,1033]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return l}}),_e.useSignedIn=m,_e.useCtx=function(o=1e4){const s=(0,e.useContext)(c),i=(0,n.useOwner)(e=>e.site),f=(0,n.useOwner)(e=>e.previewRole),l=(0,n.useOwner)(e=>e.staffAs),w=m(),D=s||'staff'===a.APP_VARIANT,y=D?'staff':w?d(f,w.role):f,h=(0,n.useOwner)(e=>e.staff),p=(0,t.useRestaurant)(i),b=(0,t.useNow)(o),O=w?w.id:D&&l?l:u[y],S=h.find(e=>e.id===O)?.name??'Team member';return{rid:i,r:p,now:b,role:y,me:S,meId:O,today:(0,r.ymd)(b),signedIn:!!w}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return y}}),_e.ensureAttendance=function(e,t){if((0,o.isLive)())return;const a=n.useOwner.getState(),s=[],i=a.staff.find(e=>e.active&&'manager'===e.role)??a.staff.find(e=>e.active&&'owner'===e.role),u=new Date(t);u.setDate(t.getDate()-w(t));const f=(0,r.ymd)(u),d=(0,r.ymd)(new Date(u.getFullYear(),u.getMonth(),u.getDate()+6)),c=(e,t,n)=>{const r=new Date(e);return r.setHours(0,0,0,0),r.setMinutes(Math.round(60*t)+n),r.toISOString()};for(let e=42;e>=1;e--){const n=new Date(t);n.setDate(n.getDate()-e);const o=(0,r.ymd)(n);if(a.attendance.some(e=>e.date===o))continue;const u=a.shifts.filter(e=>e.date===o&&!1!==e.published);(u.length?u:a.shifts.filter(e=>e.day===w(n)&&e.date>=f&&e.date<=d&&!1!==e.published)).forEach((t,r)=>{const a=e=>Math.round((7*o.charCodeAt(9)+13*r+e)%17-5),u=t.end-t.start,f=u>8?30:u>6?20:0,d=e>2&&i?{signOff:{by:i.name,byId:i.id,at:c(n,34,r)}}:{};s.push({id:`at-${o}-${t.staffId}`,staffId:t.staffId,date:o,in:c(n,t.start,a(1)),out:c(n,t.end,a(2)),inSite:!0,outSite:!0,breakMins:f,...d})})}s.length&&n.useOwner.setState({attendance:[...n.useOwner.getState().attendance,...s]})},_e.paidMins=function(e,t){if(!e.in)return{worked:0,brk:0,paid:0};const n=Math.max(0,Math.round(((e.out?new Date(e.out):t).getTime()-new Date(e.in).getTime())/6e4)),r=e.breakMins??0;return{worked:n,brk:r,paid:Math.max(0,n-r)}},Object.defineProperty(_e,"hmDur",{enumerable:!0,get:function(){return h}}),_e.payRange=function(e,t,n){const a=new Date(n);if(a.setHours(0,0,0,0),'monthly'===e){const e=new Date(a.getFullYear(),a.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,r.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(a);s.setDate(a.getDate()-w(a));let i=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&i.setDate(i.getDate()-7)}i.setDate(i.getDate()+t*o);const u=new Date(i);return u.setDate(i.getDate()+o-1),{s:i,e:u,key:`${e[0]}-${(0,r.ymd)(i)}`}},_e.useHourly=function(){const e=m(),t=(0,n.useOwner)(e=>e.hourly);return e?t:p};var e=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),r=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]),i=_r(_d[7]);const u={owner:i.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:i.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:i.ROSTER.find(e=>'staff'===e.app)?.id??''},f={staff:0,manager:1,owner:2},d=(e,t)=>f[e]>f[t]?t:e,c=(0,e.createContext)(!1),l=()=>(0,e.useContext)(c);function m(){const e=(0,s.useSession)(e=>e.meId),t=(0,n.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const w=e=>(e.getDay()+6)%7,D=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const h=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const p={}},884,[12,797,813,796,787,798,816,916]); +__d(function(_g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"snap",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return g}}),_e.areaBounds=p,_e.minReadableScale=function(e,t){return Math.max(0,...e.tables.filter(e=>e.areaId===t).map(e=>{const t='round'===e.shape?.85:1,o=(7.4399999999999995*Math.max(1,(0,r.tableLabel)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=y,_e.FixtureShape=v,_e.FloorCanvas=function(e){const[f,w]=(0,t.useState)({w:0,h:0}),M=e.plan.tables.filter(t=>t.areaId===e.areaId),j=e.crop&&M.length?p(e.plan,e.areaId):{x:0,y:0,w:r.PLAN_W,h:r.PLAN_H},C={x:j.x,y:j.y,r:j.x+j.w,b:j.y+j.h},I=f.w?'width'===e.fit?Math.min(f.w/r.PLAN_W,e.maxH?e.maxH/r.PLAN_H:9):Math.min(f.w/j.w,f.h/j.h):0,k=e.fill&&'contain'===e.fit&&I>0&&f.h>0,R=k?(f.w/I-j.w)/2:0,F=k?(f.h/I-j.h)/2:0,z={x:C.x-R,y:C.y-F,r:C.r+R,b:C.b+F},A=z.r-z.x,T=z.b-z.y,[L,S]=(0,t.useState)(null),$=(0,t.useRef)(null),E=t=>e.plan.sections.find(e=>e.id===t.sectionId),_=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),P=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{$.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=$.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(s)<6&&!L||('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&S({id:t.id,dx:i,dy:s,kind:o})},onResponderRelease:n=>{const i=$.current;$.current=null;const s=n.nativeEvent.pageX-(i?.x??0),l=n.nativeEvent.pageY-(i?.y??0);if(S(null),Math.abs(s)+Math.abs(l)<6||!I)return void('move'===o&&e.onTap?.(t));const a=s/I,h=l/I;if('edit'===e.mode&&'move'===o)e.onMove?.(t,b(c(t.x+a,e.snapOn),0,r.PLAN_W-t.w),b(c(t.y+h,e.snapOn),0,r.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,b(c(t.w+a,e.snapOn),50,400),b(c(t.h+h,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+a,n=t.y+t.h/2+h,r=M.find(e=>e.id!==t.id&&o>=e.x-10&&o<=e.x+e.w+10&&n>=e.y-10&&n<=e.y+e.h+10);r&&e.onDrop(t,r)}}}),N=e=>e*I,D='width'===e.fit?r.PLAN_H*I||200:void 0;return(0,h.jsx)(n.default,{testID:"floor-canvas",onLayout:e=>w({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:D}],children:I?(0,h.jsx)(n.default,{style:{width:N(A),height:N(T),alignSelf:'center',backgroundColor:'#0F0E0C',borderRadius:16,borderWidth:1,borderColor:s.colours.border,overflow:'hidden'},children:(0,h.jsxs)(n.default,{style:{position:'absolute',left:-N(z.x),top:-N(z.y),width:N(r.PLAN_W),height:N(r.PLAN_H)},children:['edit'===e.mode?Array.from({length:r.PLAN_W/(2*r.GRID)},(e,t)=>(0,h.jsx)(n.default,{style:{position:'absolute',left:N(t*r.GRID*2),top:0,bottom:0,width:1,backgroundColor:'#1E1B16'}},`v${t}`)):null,'edit'===e.mode?Array.from({length:r.PLAN_H/(2*r.GRID)},(e,t)=>(0,h.jsx)(n.default,{style:{position:'absolute',top:N(t*r.GRID*2),left:0,right:0,height:1,backgroundColor:'#1E1B16'}},`h${t}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,h.jsx)(v,{f:t,S:N,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=M.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,r]=t,i=o.x+o.w/2,s=o.y+o.h/2,l=r.x+r.w/2,a=r.y+r.h/2,u=Math.hypot(l-i,a-s),c=Math.atan2(a-s,l-i);return(0,h.jsx)(n.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:N((i+l)/2-u/2),top:N((s+a)/2)-3,width:N(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${c}rad`}]}},e.id)}),M.map(t=>{const c=e.view?.[t.name],b=c?i.STATUS[c.status]:i.STATUS.free,f=L?.id===t.id,p=f&&'resize'===L.kind?Math.max(50,t.w+L.dx/I):t.w,v=f&&'resize'===L.kind?Math.max(50,t.h+L.dy/I):t.h,w=f&&'move'===L.kind?t.x+L.dx/I:t.x,M=f&&'move'===L.kind?t.y+L.dy/I:t.y,j=e.selected===t.id||e.highlight?.includes(t.name),C=E(t),k='edit'===e.mode?'#2A2419':b.colour,R='edit'===e.mode?s.colours.text:b.fg,F='round'===t.shape?N(Math.min(p,v))/2:N(10),z=(0,r.tableLabel)(t),A=N(Math.min(p,v))<64,T=x(e.big?Math.max(13,Math.min(34,N(Math.min(p,v))/3)):Math.max(11,Math.min(22,N(Math.min(p,v))/4)),z,N(p)*('round'===t.shape?.85:1),e.big?g:9),S=Math.max(e.big?11:12,Math.round(.62*T)),$=(N(v)-6-1.4*T)/(1.4*S),D=$>=2&&N(p)>=5*S?2:$>=1?1:0,W=c?c.booking&&void 0!==c.seatedMins?c.booking.time:c.next?.time:void 0,O='edit'===e.mode?`Table ${z}, ${(0,r.shapeLabel)(t.shape).toLowerCase()}, ${t.minSeats}\u2013${t.maxSeats} seats${t.online?', bookable online':''}`:`Table ${z}, ${b.label}${void 0!==c?.seatedMins?`, seated ${c.seatedMins} min`:''}${c?.covers?`, ${c.covers} covers`:''}${void 0!==c?.nextIn&&'seated'!==c.status?`, next booking ${c.next?.time}`:''}`,B=void 0!==c?.seatedMins&&c.booking?Math.min(1.2,c.seatedMins/(c.booking.durationMins??(0,i.turnFor)(c.booking.partySize,e.turnBase))):null;return(0,h.jsxs)(o.default.Fragment,{children:[y({...t,w:p,h:v}).map((t,o)=>(0,h.jsx)(n.default,{pointerEvents:"none",style:[{position:'absolute',left:N(w+t.x)-Math.max(4,N(8)),top:N(M+t.y)-Math.max(4,N(8)),width:Math.max(8,N(16)),height:Math.max(8,N(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?s.colours.gold:'rgba(255,255,255,0.25)'},u()]},o)),(0,h.jsxs)(n.default,{testID:`table-${t.name}`,accessibilityRole:"button",accessibilityLabel:O,...P(t,'move'),style:[{position:'absolute',left:N(w),top:N(M),width:N(p),height:N(v),borderRadius:F,backgroundColor:k,alignItems:'center',justifyContent:'center',padding:2,borderWidth:j?3:e.sectionColours&&C?2.5:1.5,borderColor:j?'#FFFFFF':e.sectionColours&&C?C.colour:'edit'===e.mode?s.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:f?1.06:1}],zIndex:f?50:1,opacity:f&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:f?.6:.3,shadowRadius:f?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},f?null:u()],children:[(0,h.jsxs)(n.default,{style:{alignItems:'center'},pointerEvents:"none",children:[(0,h.jsx)(l.T,{weight:"bold",size:T,colour:R,center:!0,numberOfLines:1,children:z}),e.big&&'live'===e.mode&&c&&1===D?c.covers||W?(0,h.jsx)(l.T,{size:S,weight:"bold",colour:R,center:!0,numberOfLines:1,children:'free'===c.status||'soon'===c.status?W?`Next ${W}`:'':[c.covers?`${c.covers}`:'',W??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&c&&2===D?(0,h.jsxs)(h.Fragment,{children:[c.covers?(0,h.jsxs)(l.T,{size:S,weight:"semibold",colour:R,center:!0,children:[c.covers," cover",1===c.covers?'':'s']}):'free'!==c.status||A?null:(0,h.jsxs)(l.T,{size:S,colour:R,center:!0,children:[t.minSeats,"\u2013",t.maxSeats]}),W?(0,h.jsx)(l.T,{size:S,weight:"bold",colour:R,center:!0,children:'free'===c.status||'soon'===c.status?`Next ${W}`:W}):'dirty'===c.status?(0,h.jsx)(l.T,{size:S,colour:R,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?A?null:(0,h.jsxs)(l.T,{size:11,colour:s.colours.muted,center:!0,children:[t.minSeats,"\u2013",t.maxSeats,t.online?' \xb7 online':'']}):c?(0,h.jsxs)(h.Fragment,{children:['free'!==c.status||A?null:(0,h.jsxs)(l.T,{size:11,colour:R,center:!0,children:[t.minSeats,"\u2013",t.maxSeats," seats"]}),void 0!==c.seatedMins?(0,h.jsxs)(l.T,{size:12,weight:"semibold",colour:R,center:!0,children:[c.seatedMins,"m \xb7 ",c.covers,"\ud83d\udc65"]}):c.orderOnly?(0,h.jsx)(l.T,{size:11,colour:R,center:!0,children:"Open order"}):null,'soon'===c.status&&c.next?(0,h.jsxs)(l.T,{size:11,weight:"semibold",colour:R,center:!0,children:[c.next.time," \xb7 ",c.nextIn<=0?'due':`${c.nextIn}m`]}):null,'dirty'!==c.status||A?null:(0,h.jsx)(l.T,{size:11,colour:R,center:!0,children:"Clear"}),!A||c.allergy||c.vip?(0,h.jsxs)(l.T,{size:11,colour:R,center:!0,children:[c.allergy?'\u26a0':'',c.vip?'VIP'===c.vip?'\u2605':'\u2665':'',c.occasion?i.OCCASION_ICON[c.occasion]:'',c.note?'\u270e':'']}):null]}):null]}),e.big&&c?.allergy?(0,h.jsx)(n.default,{pointerEvents:"none",testID:`allergy-${t.name}`,style:{position:'absolute',top:-Math.max(10,.6*S),left:-Math.max(10,.6*S),backgroundColor:'#C62F22',borderRadius:99,borderWidth:2,borderColor:'#FFFFFF',minWidth:1.9*S,height:1.9*S,alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:S,weight:"bold",colour:"#FFFFFF",children:"\u26a0"})}):null,'live'===e.mode&&c&&!A&&(c.booking??c.next)&&(0,a.needsIcons)(c.booking??c.next).replace('\u26a0\ufe0f','').trim()?(0,h.jsx)(n.default,{pointerEvents:"none",testID:`needs-${t.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*S):2,right:e.big?-6:4,backgroundColor:'rgba(11,11,11,0.85)',borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,h.jsx)(l.T,{size:e.big?Math.max(11,.75*S):10,children:(0,a.needsIcons)(c.booking??c.next).replace('\u26a0\ufe0f','').trim()})}):null,C&&'live'===e.mode&&e.sectionColours&&!A&&!e.big?(0,h.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:C.colour,borderRadius:6,paddingHorizontal:3},children:(0,h.jsx)(l.T,{size:9,weight:"bold",colour:"#0B0B0B",children:C.server})}):null,null===B||A?null:(0,h.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:'15%',right:'15%',bottom:5,height:4,borderRadius:2,backgroundColor:'rgba(0,0,0,0.25)'},children:(0,h.jsx)(n.default,{style:{width:`${Math.min(100,100*B)}%`,height:4,borderRadius:2,backgroundColor:B>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),_(t)&&'edit'===e.mode?(0,h.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,h.jsx)(l.T,{size:10,colour:s.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===t.id?(0,h.jsx)(n.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...P(t,'resize'),style:{position:'absolute',left:N(w+p)-14,top:N(M+v)-14,width:28,height:28,borderRadius:14,backgroundColor:s.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},t.id)}),0===M.length?(0,h.jsx)(n.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,h.jsxs)(l.T,{center:!0,colour:s.colours.muted,children:["No tables in this area yet",'edit'===e.mode?' \u2014 add some in Tables':'',"."]})}):null]})}):null})};var t=_r(d[0]),o=e(t);_r(d[1]);var n=e(_r(d[2])),r=_r(d[3]),i=_r(d[4]),s=_r(d[5]),l=_r(d[6]),a=_r(d[7]),h=_r(d[8]);const u=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),c=(e,t=!0)=>t?Math.round(e/r.GRID)*r.GRID:Math.round(e),b=(e,t,o)=>Math.max(t,Math.min(o,e)),x=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),g=12,f=46;function p(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:r.PLAN_W,h:r.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-f),i=Math.max(0,Math.min(...o.map(e=>e.y))-f);return{x:n,y:i,w:Math.min(r.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+f)-n,h:Math.min(r.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+f)-i}}function y(e){const t=Math.max(1,e.maxSeats),o=[];if('round'===e.shape){const n=e.w/2+9.6,r=e.h/2+9.6;for(let i=0;ie.w,r=Math.ceil(t/2),i=t-r;if(n){for(let t=0;te.w,u=r?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,h.jsx)(n.default,{pointerEvents:"none",style:[i,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':s.colours.gold},u],children:(0,h.jsx)(l.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:s.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,h.jsx)(n.default,{pointerEvents:"none",style:[i,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},u]}):'window'===e.kind?(0,h.jsx)(n.default,{pointerEvents:"none",style:[i,{backgroundColor:'rgba(142,197,255,0.16)',borderColor:'rgba(142,197,255,0.6)',borderWidth:1,borderRadius:2},u],children:!o&&t(a?e.h:e.w)>60?(0,h.jsx)(l.T,{size:9,colour:"#BFDDFF",style:a?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,h.jsx)(n.default,{pointerEvents:"none",style:[i,{borderColor:o?'#7A6440':s.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},u],children:t(a?e.h:e.w)>40?(0,h.jsx)(l.T,{size:9,colour:s.colours.goldLight,style:a?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}},885,[12,104,109,802,803,799,791,894,6]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"areaMarks",{enumerable:!0,get:function(){return u}}),_e.AreaTabs=function({plan:o,area:e,onPick:n,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const f=o.id===e,h=b?.has(o.id);return(0,c.jsx)(l.default,{testID:`area-${o.id}`,accessibilityRole:"tab",accessibilityLabel:`Area ${o.name}${o.dogs?', dogs allowed':''}${o.outdoor?', outdoor':''}${h?', closed for weather':''}`,accessibilityState:{selected:f},onPress:()=>n(o.id),style:{minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:f?s.colours.gold:h?s.colours.blue:s.colours.border,backgroundColor:f?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:f?s.colours.onGold:s.colours.text,children:[o.name,u(o),h?(0,c.jsx)(t.T,{size:12,colour:f?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:f?s.colours.onGold:s.colours.muted,children:[" ",a[o.id]]}):null]})},o.id)})})},r(d[0]);var o,e=r(d[1]),l=(o=e)&&o.__esModule?o:{default:o},s=r(d[2]),t=r(d[3]),c=r(d[4]);const u=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},886,[12,245,799,791,6]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ds",{enumerable:!0,get:function(){return b}}),_e.useCss=m,_e.KindIcon=k,_e.SoundToggle=S,_e.AlertHost=function({variant:e,rid:t,me:l,onOpen:s,skipTakeaway:d}){m();const h=(0,f.useAlerts)(e=>e.live).filter(a=>!(a.rid!==t||'chef'===e&&'takeaway'!==a.kind||d&&'takeaway'===a.kind&&!a.test)),{width:y}=(0,o.default)(),j=x?'fixed':'absolute';if('display'===e){if(!h.length)return null;const[t,...n]=h;return(0,p.jsxs)(r.default,{testID:"display-alerts",...b('fade'),style:{position:j,left:0,right:0,top:0,bottom:0,zIndex:2e5,backgroundColor:'rgba(0,0,0,0.82)',alignItems:'center',justifyContent:'center',padding:24},children:[(0,p.jsx)(r.default,{...b('stars')}),(0,p.jsx)(a.default,{accessibilityLabel:"Close all alerts",onPress:()=>h.forEach(e=>f.useAlerts.getState().dismiss(e.id)),style:{position:'absolute',left:0,right:0,top:0,bottom:0}}),(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:Math.min(980,.92*y),gap:14},children:[(0,p.jsx)(I,{a:t,variant:e,big:!0},t.id+t.at),n.slice(0,3).map(t=>(0,p.jsx)(I,{a:t,variant:e},t.id+t.at)),n.length>3?(0,p.jsxs)(u.T,{center:!0,colour:c.colours.muted,children:["+",n.length-3," more"]}):null]})]})}return(0,p.jsxs)(p.Fragment,{children:['managers'===e?(0,p.jsx)(D,{}):null,h.length?(0,p.jsx)(r.default,{testID:"alert-stack",pointerEvents:"box-none",style:{position:j,left:0,right:0,top:10,zIndex:15e4,alignItems:'center',paddingHorizontal:10},children:(0,p.jsxs)(r.default,{pointerEvents:"box-none",style:{width:'100%',maxWidth:560,gap:8},children:[(0,p.jsx)(S,{}),(0,p.jsx)(n.default,{style:{maxHeight:640},contentContainerStyle:{gap:8},children:h.slice(0,3).map(t=>(0,p.jsx)(I,{a:t,variant:e,me:l,onOpen:s},t.id+t.at))}),h.length>3?(0,p.jsx)(a.default,{onPress:()=>s?.(h[3]),style:{alignSelf:'center',paddingHorizontal:12,paddingVertical:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.8)',borderWidth:1,borderColor:c.colours.gold},children:(0,p.jsxs)(u.T,{size:12,colour:c.colours.gold,children:["+",h.length-3," more alerts"]})}):null]})}):null]})};var t=_r(_d[0]);_r(_d[1]);var a=e(_r(_d[2])),n=e(_r(_d[3])),r=e(_r(_d[4])),o=e(_r(_d[5])),l=_r(_d[6]),s=e(l),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),f=_r(_d[10]),p=_r(_d[11]);const x='undefined'!=typeof document,b=e=>({dataSet:{ccal:e}}),h="\n[data-ccal=\"drop\"]{animation:ccal-drop .62s cubic-bezier(.16,1.1,.3,1) both}\n@keyframes ccal-drop{0%{opacity:0;transform:translate3d(0,-70px,0) scale(.94)}60%{opacity:1}100%{opacity:1;transform:none}}\n[data-ccal=\"big\"]{animation:ccal-big .8s cubic-bezier(.16,1.05,.3,1) both}\n@keyframes ccal-big{0%{opacity:0;transform:translate3d(0,-120px,0) scale(.86)}100%{opacity:1;transform:none}}\n[data-ccal=\"fade\"]{animation:ccal-fade .5s ease both}\n@keyframes ccal-fade{from{opacity:0}to{opacity:1}}\n[data-ccal=\"glow-gold\"]{animation:ccal-glow-gold 2.4s ease-in-out infinite}\n[data-ccal=\"glow-amber\"]{animation:ccal-glow-amber 1.6s ease-in-out infinite}\n[data-ccal=\"glow-green\"]{animation:ccal-glow-green 2.4s ease-in-out infinite}\n[data-ccal=\"glow-blue\"]{animation:ccal-glow-blue 2.4s ease-in-out infinite}\n@keyframes ccal-glow-gold{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.6)}}\n@keyframes ccal-glow-amber{0%,100%{box-shadow:0 0 0 1.5px rgba(255,181,71,.9),0 10px 40px rgba(255,181,71,.25)}50%{box-shadow:0 0 0 1.5px #FFB547,0 10px 70px rgba(255,181,71,.6)}}\n@keyframes ccal-glow-green{0%,100%{box-shadow:0 0 0 1.5px rgba(123,216,143,.9),0 10px 40px rgba(123,216,143,.22)}50%{box-shadow:0 0 0 1.5px #7BD88F,0 10px 70px rgba(123,216,143,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(142,197,255,.9),0 10px 40px rgba(142,197,255,.22)}50%{box-shadow:0 0 0 1.5px #8EC5FF,0 10px 70px rgba(142,197,255,.5)}}\n[data-ccal=\"stars\"]{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;background-image:radial-gradient(1.2px 1.2px at 23px 41px,#fff,transparent),radial-gradient(1px 1px at 97px 13px,#fff9,transparent),radial-gradient(1.4px 1.4px at 151px 120px,#f5e6c8,transparent),radial-gradient(1px 1px at 61px 163px,#fffa,transparent),radial-gradient(1.6px 1.6px at 183px 77px,#CFA45F,transparent);background-size:211px 199px;opacity:.55;animation:ccal-drift 50s linear infinite}\n@keyframes ccal-drift{to{background-position:-211px 199px}}\n[data-ccal=\"space\"]{background:radial-gradient(ellipse at 50% 120%,#2a1f0c 0%,#0a0805 40%,#000 72%)}\n[data-ccal=\"sheen\"]{position:absolute;top:0;bottom:0;width:35%;left:-50%;pointer-events:none;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);animation:ccal-sheen 3.6s ease-in-out .5s infinite}\n@keyframes ccal-sheen{0%{left:-50%}40%,100%{left:130%}}\n[data-ccal=\"dot\"]{animation:ccal-dot 1s ease-in-out infinite alternate}\n@keyframes ccal-dot{from{opacity:.25}to{opacity:1}}\n[data-ccal=\"bar\"]{animation-name:ccal-bar;animation-timing-function:linear;animation-fill-mode:both}\n@keyframes ccal-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}\n[data-ccal=\"ring\"]{animation:ccal-ring 1.4s ease-out infinite}\n@keyframes ccal-ring{0%{transform:scale(1);opacity:.7}100%{transform:scale(1.9);opacity:0}}\n[data-ccal=\"phase-gold\"]{animation:ccal-phase 1.8s ease-in-out infinite}\n@keyframes ccal-phase{0%,100%{background-color:rgba(40,28,6,.92)}50%{background-color:rgba(255,181,71,.55)}}\n[data-ccal=\"flash-red\"]{animation:ccal-red 1s steps(2,jump-none) infinite}\n@keyframes ccal-red{0%{background-color:#5A0E08}100%{background-color:#D9302A}}\n[data-ccal=\"pulse-btn\"]{animation:ccal-pulse 1.2s ease-in-out infinite}\n@keyframes ccal-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}\n@media (prefers-reduced-motion: reduce){[data-ccal]{animation:none !important;transition:none !important}}\n";function m(){(0,t.useEffect)(()=>{if(!x||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=h,document.head.appendChild(e)},[])}const y=e=>'pending'===e?'glow-amber':'takeaway'===e?'glow-green':'email'===e?'glow-blue':'glow-gold',j=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function k({kind:e,size:t=22,colour:a}){const n={stroke:a??f.KIND_META[e].colour,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,p.jsxs)(s.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,p.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...n})]}):null,'pending'===e?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...n}),(0,p.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...n})]}):null,'takeaway'===e?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...n}),(0,p.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...n})]}):null,'email'===e?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...n}),(0,p.jsx)(l.Path,{d:"M3 7l9 6 9-6",...n})]}):null,'test'===e?(0,p.jsx)(l.Path,{d:"M12 2l2.4 6.6L21 9l-5.2 4.3L17.5 20 12 16.3 6.5 20l1.7-6.7L3 9l6.6-.4z",...n}):null]})}function w({label:e,value:t,big:a}){return(0,p.jsxs)(r.default,{style:{minWidth:a?130:66,flexGrow:1,paddingVertical:a?12:7,paddingHorizontal:a?16:10,borderRadius:12,backgroundColor:'rgba(255,255,255,0.05)',borderWidth:1,borderColor:'rgba(207,164,95,0.25)'},children:[(0,p.jsx)(u.T,{size:a?13:10,weight:"semibold",colour:c.colours.muted,style:{letterSpacing:1.6},children:e}),(0,p.jsx)(u.T,{size:a?30:17,weight:"bold",numberOfLines:1,children:t})]})}function C({label:e,onPress:t,kind:n="primary",colour:r=c.colours.gold,testID:o,big:l}){const s='primary'===n?r:'danger'===n?c.colours.redSolid:'rgba(255,255,255,0.05)';return(0,p.jsx)(a.default,{testID:o,accessibilityRole:"button",accessibilityLabel:e,onPress:t,style:({pressed:e})=>({minHeight:l?56:42,paddingHorizontal:l?22:14,borderRadius:999,alignItems:'center',justifyContent:'center',backgroundColor:s,borderWidth:'ghost'===n?1.2:0,borderColor:r,transform:[{scale:e?.96:1}]}),children:(0,p.jsx)(u.T,{size:l?18:14,weight:"semibold",colour:'primary'===n?'#0B0B0B':'danger'===n?'#fff':r,children:e})})}const T=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4;function I({a:e,variant:n,big:o,me:l,onOpen:s}){const x=f.KIND_META[e.kind],h=()=>f.useAlerts.getState().dismiss(e.id),[m,I]=(0,t.useState)(!1),[S,D]=(0,t.useState)(null),z=T(e,n);(0,t.useEffect)(()=>{if(!z)return;const e=setTimeout(h,z);return()=>clearTimeout(e)},[e.id,e.at]);const v=e=>{D(e),setTimeout(h,1800)},A='managers'===n,P=l??'Manager',E='takeaway'===e.kind?[['ORDER',e.orderNo??''],['ITEMS',String(e.items??'')],['TOTAL',e.total??''],['COLLECT',e.collect??'']]:'email'===e.kind?[]:[['TIME',e.when??''],['COVERS',String(e.covers??'')],...e.table?[['TABLE',e.table]]:[],['SOURCE',e.source??'']],R=o?1.9:1;return(0,p.jsx)(r.default,{testID:`alert-${e.kind}`,accessibilityRole:"alert",accessibilityLabel:`${x.kicker}: ${e.name}`,...b(o?'big':'drop'),style:{width:'100%',borderRadius:o?28:18,overflow:'hidden'},children:(0,p.jsxs)(r.default,{...b(y(e.kind)),style:{borderRadius:o?28:18,overflow:'hidden',backgroundColor:'#070605'},children:[(0,p.jsx)(r.default,{...b('space'),style:{position:'absolute',left:0,right:0,top:0,bottom:0}}),(0,p.jsx)(r.default,{...b('stars')}),(0,p.jsx)(r.default,{...b('sheen')}),(0,p.jsxs)(r.default,{style:{padding:o?34:14,gap:o?18:10},children:[(0,p.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10*R},children:[(0,p.jsxs)(r.default,{style:{width:38*R,height:38*R,alignItems:'center',justifyContent:'center'},children:[(0,p.jsx)(r.default,{...b('ring'),style:{position:'absolute',width:38*R,height:38*R,borderRadius:99,borderWidth:1.5,borderColor:x.colour}}),(0,p.jsx)(r.default,{style:{width:38*R,height:38*R,borderRadius:99,borderWidth:1.5,borderColor:x.colour,alignItems:'center',justifyContent:'center',backgroundColor:'rgba(0,0,0,0.6)'},children:(0,p.jsx)(k,{kind:e.kind,size:20*R})})]}),(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(u.T,{size:o?20:12,weight:"bold",colour:x.colour,style:{letterSpacing:o?5:2.6},numberOfLines:1,children:x.kicker}),(0,p.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,p.jsx)(r.default,{...b('dot'),style:{width:7*R,height:7*R,borderRadius:9,backgroundColor:x.colour}}),(0,p.jsxs)(u.T,{size:o?16:11,colour:c.colours.muted,style:{letterSpacing:1.5},children:[e.test?'TEST \xb7 ':'LIVE \xb7 ',j(e.at),e.nag?` \xb7 REMINDER ${e.nag}`:'']})]})]}),(0,p.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:"Close alert",hitSlop:10,onPress:h,style:{width:30*R,height:30*R,borderRadius:99,alignItems:'center',justifyContent:'center',backgroundColor:'rgba(255,255,255,0.06)'},children:(0,p.jsx)(u.T,{size:16*R,colour:c.colours.muted,children:"\xd7"})})]}),(0,p.jsxs)(r.default,{children:[(0,p.jsx)(u.T,{size:o?72:26,weight:"bold",numberOfLines:1,style:{letterSpacing:o?-1:0},children:e.name}),'email'===e.kind?(0,p.jsx)(u.T,{size:o?24:15,colour:c.colours.text,numberOfLines:2,children:e.subject}):null]}),E.length?(0,p.jsx)(r.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:o?12:6},children:E.map(([e,t])=>(0,p.jsx)(w,{label:e,value:t,big:o},e))}):null,e.allergy?(0,p.jsxs)(r.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',backgroundColor:'rgba(198,47,34,0.22)',borderWidth:1.2,borderColor:c.colours.red,borderRadius:12,padding:o?14:8},children:[(0,p.jsx)(u.T,{size:o?16:11,weight:"bold",colour:c.colours.red,style:{letterSpacing:1.8},children:"ALLERGY"}),(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(u.T,{size:o?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,p.jsx)(u.T,{size:o?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,p.jsx)(u.T,{size:o?18:13,colour:c.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,p.jsx)(u.T,{size:12,colour:c.colours.muted,children:"Test only. No venue email is connected yet."}):null,S?(0,p.jsx)(u.T,{size:14,weight:"semibold",colour:c.colours.goldLight,children:S}):null,A&&!S?'pending'===e.kind?m?(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsxs)(u.T,{size:14,colour:"#FFE1DC",children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,p.jsxs)(r.default,{style:{flexDirection:'row',gap:8,flexWrap:'wrap'},children:[(0,p.jsx)(C,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',P),v('Declined. The guest\u2019s message is in the Outbox.')}}),(0,p.jsx)(C,{kind:"ghost",label:"Keep it",onPress:()=>I(!1)})]})]}):(0,p.jsxs)(r.default,{style:{flexDirection:'row',gap:8,flexWrap:'wrap'},children:[(0,p.jsx)(C,{label:"Confirm",colour:c.colours.amber,testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',P),v(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,p.jsx)(C,{kind:"ghost",colour:c.colours.red,label:"Decline",testID:"alert-decline",onPress:()=>I(!0)}),(0,p.jsx)(C,{kind:"ghost",colour:c.colours.muted,label:"Later",onPress:h})]}):'takeaway'===e.kind?(0,p.jsxs)(r.default,{style:{flexDirection:'row',gap:8,flexWrap:'wrap'},children:[(0,p.jsx)(C,{label:"Accept",colour:c.colours.gold,testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,P);v(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,p.jsx)(C,{kind:"ghost",colour:c.colours.gold,label:`Ready in ${t}`,onPress:async()=>{const a=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,P,t);v(`Accepted, ready in ${t} minutes.${a?'':' Allergy sign-off still needed.'}`)}},t)),(0,p.jsx)(C,{kind:"ghost",colour:c.colours.muted,label:"Later",onPress:h})]}):'booking'===e.kind&&s?(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:8},children:(0,p.jsx)(C,{kind:"ghost",label:"View bookings",onPress:()=>{h(),s(e)}})}):null:null]}),z?(0,p.jsx)(r.default,{...b('bar'),style:{height:3,backgroundColor:x.colour,opacity:.8,transformOrigin:'left',animationDuration:`${z}ms`}}):null]})})}function S({big:e}){const t=(0,f.useAlerts)(e=>e.prefs.muted);return(0,p.jsx)(a.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>f.useAlerts.getState().setPrefs({muted:!t}),style:{alignSelf:'flex-end',paddingHorizontal:12,paddingVertical:e?8:5,borderRadius:999,backgroundColor:'rgba(0,0,0,0.75)',borderWidth:1,borderColor:c.colours.border},children:(0,p.jsx)(u.T,{size:e?15:12,colour:t?c.colours.muted:c.colours.gold,children:t?'Sound off':'Sound on'})})}function D(){const e=(0,f.useAlerts)(e=>e.askedSystem),[a,n]=(0,t.useState)((0,f.systemSupport)()),[o,l]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>l(!0),2500);return()=>clearTimeout(e)},[]),e||'default'!==a||!o?null:(0,p.jsx)(r.default,{testID:"notify-prompt",...b('drop'),style:{position:x?'fixed':'absolute',left:12,right:12,bottom:78,zIndex:15e4,alignItems:'center'},children:(0,p.jsxs)(r.default,{...b('glow-gold'),style:{width:'100%',maxWidth:520,borderRadius:18,overflow:'hidden',backgroundColor:'#070605'},children:[(0,p.jsx)(r.default,{...b('stars')}),(0,p.jsxs)(r.default,{style:{padding:14,gap:8},children:[(0,p.jsxs)(r.default,{style:{flexDirection:'row',gap:10,alignItems:'center'},children:[(0,p.jsx)(k,{kind:"booking"}),(0,p.jsx)(u.T,{weight:"semibold",style:{flex:1},children:"Get booking alerts on this device?"})]}),(0,p.jsx)(u.T,{size:14,colour:c.colours.muted,children:"We\u2019ll let you know about new bookings, requests to confirm and takeaway orders, even when the app is in the background. You can change this any time in More, Alerts and sounds."}),(0,p.jsxs)(r.default,{style:{flexDirection:'row',gap:8},children:[(0,p.jsx)(C,{label:"Turn on alerts",testID:"notify-allow",onPress:async()=>{const e=await(0,f.requestSystemPermission)();n(e),f.useAlerts.getState().setAsked()}}),(0,p.jsx)(C,{kind:"ghost",label:"Not now",onPress:()=>f.useAlerts.getState().setAsked()})]})]})]})})}},887,[12,104,245,133,109,269,852,797,799,791,889,6]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"unconfirmedTakeaways",{enumerable:!0,get:function(){return p}}),_e.useBuildingChime=function(e,o=4e3,s=6e4){const l=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||l)return;const t=Date.now(),i=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/s));i();const n=setInterval(i,o);return()=>clearInterval(n)},[e,l,o,s])},_e.TakeawayFacts=y,_e.TakeawayTakeover=function({rid:e,me:t}){(0,f.useCss)();const n=(0,i.useOrders)(e),a=p(n),c=a[0],{width:j}=(0,l.default)();return c?(0,x.jsx)(s.default,{testID:"takeaway-takeover",accessibilityRole:"alert",accessibilityLabel:`New takeaway order ${c.ref}. Read and confirm.`,...(0,f.ds)('phase-gold'),style:{position:b?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:25e4,backgroundColor:'rgba(120,80,10,0.94)',borderWidth:10,borderColor:u.colours.amber,alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(s.default,{style:{width:'100%',maxWidth:Math.min(1100,.95*j),maxHeight:'100%',backgroundColor:'#0B0B0B',borderRadius:24,borderWidth:3,borderColor:u.colours.gold,padding:22,gap:14},children:[(0,x.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[(0,x.jsx)(h.T,{size:40,children:"\ud83e\udd61"}),(0,x.jsxs)(s.default,{style:{flex:1},children:[(0,x.jsx)(h.T,{size:j<700?26:38,weight:"bold",colour:u.colours.amber,children:"NEW TAKEAWAY ORDER"}),(0,x.jsxs)(h.T,{size:16,colour:u.colours.muted,children:["Read it, then tap Confirm. This stays on screen until someone confirms.",a.length>1?` ${a.length-1} more waiting.`:'']})]})]}),(0,x.jsx)(o.default,{style:{flexGrow:0},contentContainerStyle:{gap:10},children:(0,x.jsx)(y,{o:c,big:j>=700})}),(0,x.jsx)(s.default,{...(0,f.ds)('pulse-btn'),children:(0,x.jsx)(h.Button,{label:`Confirm order ${c.ref}`,testID:"takeover-confirm",onPress:()=>{i.repo.orders.accept(c.id,t)},style:{minHeight:84,borderRadius:20}})})]})}):null};var t=r(d[0]);r(d[1]);var o=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),n=r(d[6]),a=r(d[7]),c=r(d[8]),u=r(d[9]),h=r(d[10]),f=r(d[11]),x=r(d[12]);const b='undefined'!=typeof document,j=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',p=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function y({o:e,big:t,personal:o=!0}){const l=t?1:.8;return(0,x.jsxs)(s.default,{style:{gap:10},children:[(0,x.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,x.jsxs)(s.default,{children:[(0,x.jsx)(h.T,{size:13*l+2,colour:u.colours.muted,children:"Collection"}),(0,x.jsx)(h.T,{size:34*l,weight:"bold",colour:u.colours.goldLight,children:j(e.slotTime)})]}),o?(0,x.jsxs)(s.default,{children:[(0,x.jsx)(h.T,{size:13*l+2,colour:u.colours.muted,children:"Customer"}),(0,x.jsx)(h.T,{size:26*l,weight:"semibold",children:e.customerName})]}):null,o?(0,x.jsxs)(s.default,{children:[(0,x.jsx)(h.T,{size:13*l+2,colour:u.colours.muted,children:"Phone"}),(0,x.jsx)(h.T,{size:26*l,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,x.jsxs)(s.default,{children:[(0,x.jsx)(h.T,{size:13*l+2,colour:u.colours.muted,children:"Order"}),(0,x.jsx)(h.T,{size:26*l,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,x.jsxs)(s.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,x.jsxs)(h.T,{size:22*l,weight:"bold",colour:"#FFFFFF",children:["\u26a0 ALLERGY: ",e.allergies.map(e=>`${(0,n.allergenLabel)(e.allergen)} (${(0,n.severityLabel)(e.severity)})`).join(', ')]}),e.lines.filter(e=>e.overridden).map((e,t)=>(0,x.jsxs)(h.T,{size:16*l,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,x.jsx)(h.T,{size:16*l,colour:u.colours.green,children:"No allergies declared"}),(0,x.jsx)(s.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,x.jsxs)(h.T,{size:22*l,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}},888,[12,104,133,109,269,797,792,889,880,799,791,887,6]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"chime",{enumerable:!0,get:function(){return l.chime}}),e.sendTestAlert=function(t,a){const o={rid:t,at:Date.now(),test:!0},c='pending'===a?{...o,id:`test-pending:${Date.now()}`,kind:'pending',name:'Test guest',when:'Today 19:30',covers:10,source:'Online'}:'takeaway'===a?{...o,id:`test-takeaway:${Date.now()}`,kind:'takeaway',name:'Test guest',orderNo:'T-TEST',items:3,total:'\xa324.50',collect:'18:45',source:'Online',allergy:'Milk (allergy)',allergyStep:'Test only: no sign-off needed'}:'email'===a?{...o,id:`test-email:${Date.now()}`,kind:'email',name:'Cover Charge test',subject:'This is a test alert. No real email was received.'}:{...o,id:`test-booking:${Date.now()}`,kind:'test'===a?'test':'booking',name:'Test guest',when:'Today 19:30',covers:4,table:'7',source:'Phone',allergy:'Peanuts (allergy)',allergyStep:'Test only: no sign-off needed'};n.useAlerts.getState().raise(c)};var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var a=r(d[2]);Object.keys(a).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})});var o=r(d[3]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})});var c=r(d[4]);Object.keys(c).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})});var l=r(d[5])},889,[1137,1138,1140,1139,1141,880]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"look",{enumerable:!0,get:function(){return b}}),r(d[0]);const o=o=>o,b={panel:{backgroundColor:'#121110',borderRadius:18,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',boxShadow:'0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 28px rgba(0,0,0,0.45)'},quiet:(o,b="gold")=>({minHeight:50,borderRadius:14,borderWidth:1,borderColor:'blue'===b?'rgba(142,197,255,0.55)':'rgba(207,164,95,0.38)',backgroundColor:o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(142,197,255,0.10)':'rgba(255,255,255,0.035)',paddingHorizontal:14,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,boxShadow:'0 1px 0 rgba(255,255,255,0.05) inset',transition:'background-color 120ms ease'}),green:o=>({backgroundColor:o?'#B8904F':'#CFA45F',borderWidth:1,borderColor:'rgba(255,226,170,0.55)',backgroundImage:o?'linear-gradient(180deg, #BE9552 0%, #A88143 100%)':'linear-gradient(180deg, #E0BA77 0%, #C69A55 100%)',boxShadow:o?'0 2px 8px rgba(0,0,0,0.4)':'0 1px 0 rgba(255,255,255,0.28) inset, 0 10px 24px rgba(207,164,95,0.22), 0 4px 10px rgba(0,0,0,0.45)',transition:'box-shadow 120ms ease'}),onPrimary:'#17130D',web:o}},890,[104]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useReservedToday=p,_e.ShellfishTile=function({rid:e,by:t,app:d,big:u,onOrder:c,style:h}){const y=(0,n.useShellfish)(e,t,d),j=p(e),[k,w]=(0,s.useState)(!1),C=x(e,y.items.find(e=>e.supplierId)?.supplierId);if(!y.items.length)return null;const T=y.items.filter(e=>y.isLow(e.key)),L=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,b.jsxs)(o.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:T.length?a.colours.amber:a.colours.border,backgroundColor:a.colours.surface,padding:u?10:12,gap:6},h],children:[(0,b.jsxs)(l.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(e=>`${e.plural} ${(0,i.fmtCount)(y.counts[e.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>w(!0),style:{gap:4,flex:u?1:void 0},children:[(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(r.T,{size:12,weight:"semibold",colour:a.colours.gold,children:["LIVE \xb7 ",L]}),(0,b.jsx)(r.T,{size:12,colour:a.colours.muted,children:"Tap to update \u203a"})]}),(0,b.jsx)(r.Row,{gap:u?14:18,style:{flex:u?1:void 0,alignItems:'center'},children:y.items.map(e=>{const s=y.counts[e.key]??0,t=y.isLow(e.key);return(0,b.jsxs)(o.default,{testID:`count-${e.key}`,style:{flex:1,alignItems:'center'},children:[(0,b.jsx)(r.T,{size:u?42:34,weight:"bold",colour:s<=0?a.colours.red:t?a.colours.amber:a.colours.text,style:{lineHeight:u?50:42},children:(0,i.fmtCount)(s)}),(0,b.jsxs)(r.T,{size:13,colour:t?a.colours.amber:a.colours.muted,children:[e.icon," ",e.plural,s<=0?' \xb7 out':t?' \xb7 low':'']}),j[e.key]?(0,b.jsxs)(r.T,{size:12,weight:"semibold",colour:a.colours.goldLight,children:["Reserved: ",(0,i.fmtCount)(j[e.key])," \xb7 free ",(0,i.fmtCount)(Math.max(0,s-j[e.key]))]}):null]},e.key)})})]}),!u&&T.length?(0,b.jsxs)(o.default,{testID:"shellfish-low",style:{backgroundColor:a.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,b.jsxs)(r.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",T.map(e=>`${(0,i.fmtCount)(y.counts[e.key]??0)} ${e.plural.toLowerCase()} (warns at ${e.lowAt})`).join(', ')]}),c?(0,b.jsx)(r.Button,{small:!0,label:C?`Order from ${C} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:c}):null]}):null,u||T.length||!c?null:(0,b.jsx)(l.default,{accessibilityRole:"button",onPress:c,children:(0,b.jsx)(r.T,{size:13,colour:a.colours.gold,children:C?`${C} order sheet \u203a`:'Order sheets \u203a'})}),k?(0,b.jsx)(f,{rid:e,by:t,app:d,onClose:()=>w(!1),onOrder:c?()=>{w(!1),c()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:d,app:u,height:c=76}){const h=(0,n.useShellfish)(e,d,u),y=p(e),[x,j]=(0,s.useState)(!1);if(!h.items.length)return null;const k=c>=80,w=Math.max(28,Math.min(52,Math.round(.6*c))),C=Math.max(22,Math.min(34,Math.round(.42*c)));return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(l.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${h.items.map(e=>`${e.plural} ${(0,i.fmtCount)(h.counts[e.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>j(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:c,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...t.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:h.items.map((e,s)=>{const l=h.counts[e.key]??0,n=y[e.key]??0,d=Math.max(0,l-n),u=d<=0,p=u||h.isLow(e.key);return(0,b.jsxs)(o.default,{testID:`count-${e.key}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:k?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:p?'rgba(255,107,94,0.07)':'transparent',...t.look.web(p?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[(0,b.jsx)(r.T,{size:C,children:e.icon}),(0,b.jsx)(r.T,{size:w,weight:"bold",colour:p?'#FF8E82':a.colours.text,style:{lineHeight:Math.round(1.15*w),letterSpacing:-.5,minWidth:Math.round(.85*w),textAlign:'center'},children:(0,i.fmtCount)(d)}),(0,b.jsxs)(o.default,{style:{gap:0},children:[(0,b.jsx)(r.T,{size:k?15:13,weight:"semibold",colour:p?'#FFB3AA':a.colours.goldLight,style:{letterSpacing:2},children:e.plural.toUpperCase()}),p&&c>=60?(0,b.jsx)(r.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:u?'NONE LEFT':`LOW \xb7 WARNS AT ${e.lowAt}`}):null,(0,b.jsxs)(r.T,{size:k?14:12,weight:"semibold",colour:n?a.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,i.fmtCount)(n)]})]})]},e.key)})}),x?(0,b.jsx)(f,{rid:e,by:d,app:u,onClose:()=>j(!1)}):null]})},_e.ShellfishPanel=f;var s=_r(_d[0]),t=_r(_d[1]),l=e(_r(_d[2])),o=e(_r(_d[3])),r=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]);const y=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function p(e){const s=(0,u.useBookings)(e),t=(0,u.useRestaurant)(e),l=(0,h.ymd)((0,u.useNow)(6e4));return(0,c.reservedOn)(s,l,(0,c.reservablesOf)(t))}function x(e,s){const t=(0,d.useSheets)(e);return s?t.find(e=>e.id===s)?.name:void 0}function f({rid:e,by:t,app:l,onClose:d,onOrder:u}){const c=(0,n.useShellfish)(e,t,l),[h,p]=(0,s.useState)({}),[f,j]=(0,s.useState)(null),k=x(e,c.items.find(e=>e.supplierId)?.supplierId),w=(e,s)=>p(t=>({...t,[e]:Math.max(0,Math.min(99,(t[e]??0)+s))})),C=(e,s=!1)=>{const t=c.itemOf(e);c.sell(e,s)&&j((s?`Half ${t?.name.toLowerCase()}`:`1 ${t?.name.toLowerCase()}`)+" sold.")},T=Object.values(h).reduce((e,s)=>e+s,0);return(0,b.jsxs)(r.Sheet,{visible:!0,onClose:d,title:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:"shellfish-panel",children:[(0,b.jsx)(r.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(e=>{const s=c.counts[e.key]??0;return(0,b.jsxs)(o.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(e.key)?a.colours.amber:a.colours.border,backgroundColor:a.colours.surface2},children:[(0,b.jsxs)(r.T,{center:!0,size:13,colour:a.colours.muted,children:[e.icon," ",e.plural]}),(0,b.jsx)(r.T,{center:!0,size:48,weight:"bold",colour:c.isLow(e.key)?a.colours.amber:a.colours.text,style:{lineHeight:56},children:(0,i.fmtCount)(s)}),(0,b.jsx)(r.Button,{label:`Sold 1 ${e.name.toLowerCase()} \u22121`,testID:`sell-${e.key}`,disabled:s<1,onPress:()=>C(e.key),style:{minHeight:56}}),'half'===e.unit?(0,b.jsx)(r.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${e.key}-half`,disabled:s<.5,onPress:()=>C(e.key,!0),style:{minHeight:52}}):(0,b.jsx)(o.default,{style:{minHeight:52}})]},e.key)})}),(0,b.jsx)(r.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,i.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:"shellfish-undo",disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&j(`Undone: ${(0,i.describe)(e,c.itemOf(e.kind))}.`)}}),f?(0,b.jsx)(r.Banner,{kind:"success",title:f}):null,(0,b.jsxs)(o.default,{testID:"delivery-in",style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:a.colours.gold,backgroundColor:a.colours.goldTint},children:[(0,b.jsx)(r.T,{weight:"semibold",colour:a.colours.goldLight,children:"Delivery in"}),c.items.map(e=>(0,b.jsxs)(r.Row,{gap:10,children:[(0,b.jsxs)(r.T,{style:{flex:1},children:[e.icon," ",e.plural]}),(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:`Fewer ${e.plural.toLowerCase()} in`,onPress:()=>w(e.key,-1),style:{minWidth:48,minHeight:48}}),(0,b.jsx)(r.T,{size:24,weight:"bold",style:{width:44,textAlign:'center'},children:h[e.key]??0}),(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:`More ${e.plural.toLowerCase()} in`,testID:`in-plus-${e.key}`,onPress:()=>w(e.key,1),style:{minWidth:48,minHeight:48}}),(0,b.jsx)(r.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>w(e.key,5)})]},e.key)),(0,b.jsx)(r.Button,{kind:"success",label:T?`Add to stock: ${c.items.filter(e=>h[e.key]).map(e=>`${h[e.key]} ${(1===h[e.key]?e.name:e.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!T,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,h[e.key]??0)),j('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),u?(0,b.jsx)(r.Button,{kind:"secondary",label:k?`${k} order sheet \u203a`:'Order sheets \u203a',onPress:u}):null,(0,b.jsxs)(o.default,{style:{gap:2},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:a.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{size:13,style:{flex:1},children:(0,i.describe)(e,c.itemOf(e.kind))}),(0,b.jsxs)(r.Muted,{children:[y(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c.synced?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Badge,{kind:"green",label:"Shared live"}),(0,b.jsx)(r.Muted,{children:"Every paired device sees the same count."})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Badge,{kind:"neutral",label:"Saved on this device"}),(0,b.jsx)(r.Muted,{children:"Not connected to the shared venue yet."})]})})]})}},891,[12,890,245,109,791,1035,1034,1087,799,797,805,796,6]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=y,_e.BookingAllergyChain=function({b:e,me:l,readOnly:j}){const k=(0,n.useOrders)(e.restaurantId),p=(0,o.useStore)(e=>e.ackBookingAllergy);if(!e.allergies.length)return null;const A=k.find(l=>l.allergies.length&&!['cancelled','closed'].includes(l.status)&&(l.bookingId===e.id||!l.bookingId&&(0,i.linkedBooking)(l,[e])?.id===e.id));if(A)return(0,f.jsx)(y,{o:A,me:l,readOnly:j,compact:!0});const w={booked:e.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,f.jsxs)(s.default,{testID:`allergy-chain-${e.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:e.allergyAck?c.colours.border:c.colours.red,backgroundColor:'#140f0e'},children:[(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(t.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",e.ref]}),(0,f.jsx)(t.Badge,{kind:e.allergyAck?'amber':'red',label:(e.allergyAck?1:0)+" of 5"})]}),(0,f.jsx)(x,{chain:w,next:e.allergyAck?null:'booked',testID:`allergy-steps-${e.ref}`}),e.allergyAck?(0,f.jsxs)(t.Row,{gap:6,children:[(0,f.jsx)(u.StaffAvatar,{name:e.allergyAck.by,size:20,ring:!1}),(0,f.jsxs)(t.Muted,{style:{flex:1},children:["1. Booked: ",b(e.allergyAck.by)," at ",h(e.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),j?null:(0,f.jsxs)(t.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(t.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${e.ref}`,accessibilityLabel:`Sign off Booked on ${e.ref}`,disabled:!l.trim(),onPress:()=>p(e.id,l)}),(0,f.jsxs)(t.Muted,{children:["as ",b(l)]})]})]})]})},r(d[0]);var e,l=r(d[1]),s=(e=l)&&e.__esModule?e:{default:e},t=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]);const h=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function x({chain:e,next:l,testID:n}){return(0,f.jsx)(s.default,{testID:n,accessibilityLabel:`Allergen sign-off ${i.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:i.CHAIN_STEPS.map((n,o)=>{const i=!!e[n.id],u=l===n.id,x=i?c.colours.green:u?c.colours.gold:c.colours.border;return(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%'},children:[(0,f.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:o?i||u?x:c.colours.border:'transparent'}}),(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:x,backgroundColor:i?c.colours.green:'transparent',alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(t.T,{size:12,weight:"bold",colour:i?'#0B0B0B':u?c.colours.gold:c.colours.muted,children:i?'\u2713':String(n.n)})}),(0,f.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:o<4?i?c.colours.green:c.colours.border:'transparent'}})]}),(0,f.jsx)(t.T,{size:11,weight:u?'semibold':'regular',colour:i?c.colours.text:u?c.colours.gold:c.colours.muted,center:!0,children:n.label}),e[n.id]?(0,f.jsxs)(t.T,{size:10,colour:c.colours.muted,center:!0,numberOfLines:2,children:[b(e[n.id].by).split(' ')[0]," ",h(e[n.id].at)]}):null]},n.id)})})}function y({o:e,me:l,readOnly:y,compact:j}){const k=(0,n.useBookings)(e.restaurantId),p=(0,o.useStore)(e=>e.signAllergyStep);if(!e.allergies.length)return null;const A=(0,i.linkedBooking)(e,k),w=(0,i.orderChain)(e,A),S=(0,i.nextStep)(e,A),I=i.CHAIN_STEPS.filter(e=>w[e.id]).length,C=S?(0,i.stepInfo)(S):null,B='table'===S&&!['ready','served','collected'].includes(e.status);return(0,f.jsxs)(s.default,{testID:`allergy-chain-${e.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:S?c.colours.red:c.colours.green,backgroundColor:'#140f0e'},children:[(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(t.T,{size:13,weight:"semibold",colour:S?'#FFD9D4':'#CFF3D7',children:["Allergen sign-off \xb7 ",e.ref]}),(0,f.jsx)(t.Badge,{kind:S?'red':'green',label:S?`${I} of 5`:'Complete'})]}),(0,f.jsx)(x,{chain:w,next:S,testID:`allergy-steps-${e.ref}`}),j?null:i.CHAIN_STEPS.filter(e=>w[e.id]).map(e=>(0,f.jsxs)(t.Row,{gap:6,children:[(0,f.jsx)(u.StaffAvatar,{name:w[e.id].by,size:20,ring:!1}),(0,f.jsxs)(t.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(w[e.id].by)," at ",h(w[e.id].at)]})]},e.id)),C?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(t.T,{size:13,children:["Next: ",C.n,". ",C.label,". ",C.what,"."]}),y?null:(0,f.jsxs)(t.Row,{wrap:!0,gap:8,children:[(0,f.jsx)(t.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${e.ref}`,accessibilityLabel:`Sign off ${C.label} on ${e.ref}`,disabled:!l.trim()||B,onPress:()=>p(e.id,S,l)}),(0,f.jsxs)(t.Muted,{children:["as ",b(l)]})]}),B?(0,f.jsx)(t.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,f.jsx)(t.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,f.jsx)(t.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},892,[12,109,791,924,855,893,799,898,6]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CHAIN_STEPS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"stepInfo",{enumerable:!0,get:function(){return t}}),e.linkedBooking=l,e.orderChain=o,e.nextStep=s,Object.defineProperty(e,"doneCount",{enumerable:!0,get:function(){return c}}),e.canSign=function(n,t,l){return s(n,l)===t},e.statusBlock=function(n,l,s){if(!n.allergies.length||'cancelled'===l)return null;const c=o(n,s),u=n=>c[n]?null:`${t(n).n}. ${t(n).label} needs signing off first`;return'acknowledged'===l||'preparing'===l||'ready'===l?u('booked')??u('ordered')??u('kitchen'):'served'===l?u('booked')??u('ordered')??u('kitchen')??u('pass'):'collected'===l||'closed'===l?u('booked')??u('ordered')??u('kitchen')??u('pass')??u('table'):null},e.chainNeedsAction=function(n,t){const o=s(n,l(n,t));return!(!o||'table'===o&&!['ready','served'].includes(n.status))},e.bookingNeedsAction=function(n,t){return n.allergies.length>0&&!n.allergyAck&&!t.some(t=>t.allergies.length&&l(t,[n])?.id===n.id)};const n=[{id:'booked',n:1,label:'Booked',what:'Allergy recorded (who took it)'},{id:'ordered',n:2,label:'Ordered',what:'Server confirms with the guest'},{id:'kitchen',n:3,label:'Kitchen',what:'Chef signs off before cooking'},{id:'pass',n:4,label:'Pass',what:'Checked before it leaves the pass'},{id:'table',n:5,label:'Table',what:'Server signs off when served'}],t=t=>n.find(n=>n.id===t);function l(n,t){return n.bookingId?t.find(t=>t.id===n.bookingId):'table'===n.type&&n.tableNo?t.find(t=>t.restaurantId===n.restaurantId&&'seated'===t.status&&!!t.table&&t.table.split('+').includes(String(n.tableNo))):void 0}function o(n,t){return{booked:n.allergyChain?.booked??(t?.allergies.length?t.allergyAck:void 0),ordered:n.allergyChain?.ordered,kitchen:n.allergyAck,pass:n.allergyChain?.pass,table:n.handoverCheck}}function s(t,l){if(!t.allergies.length)return null;const s=o(t,l);return n.find(n=>!s[n.id])?.id??null}const c=(t,l)=>{const s=o(t,l);return n.filter(n=>s[n.id]).length}},893,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=f,_e.NeedsPills=p,_e.BookingNeeds=k,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return j}}),_e.serveHolds=S,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=r.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],o=`${e.name}, ${(0,u.niceDate)((0,u.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=y(e.restaurantId);l.push(`${(0,a.holdsText)(e,(0,a.reservablesOf)(s),t)} reserved: ${o}. Tap Platter OK in the Head Chef app.`)}(0,a.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,a.allergenText)(e)} \u2014 ${o}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;n.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:e,today:t,by:n,app:b,canConfirm:f=!0,showAll:p}){const x=D(e,t),y=(0,r.useBookings)(e),I=(0,r.useRestaurant)(e),T=(0,o.useStockItems)(e),O=(0,a.reservablesOf)(I),$=y.filter(e=>e.date===t&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),F=p?[...x,...$.filter(e=>!x.includes(e))]:x;return F.length?(0,h.jsxs)(s.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:x.length?c.colours.amber:c.colours.hairline,backgroundColor:c.colours.surface},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:x.length?c.colours.amber:c.colours.goldMuted,style:{letterSpacing:1.6},children:x.length?`KITCHEN SIGN-OFF NEEDED (${x.length})`:'RESERVED TODAY'}),F.map(e=>(0,h.jsxs)(s.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:c.colours.hairline},testID:`signoff-${e.ref}`,children:[(0,h.jsxs)(l.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," covers \xb7 ",e.date===t?'Today':(0,u.niceDate)((0,u.parseYmd)(e.date))," ",e.time,e.table?` \xb7 T${e.table}`:'']}),(0,h.jsx)(k,{b:e}),f?(0,h.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,a.needsAllergenSeen)(e)?(0,h.jsx)(l.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${e.ref}`,onPress:()=>r.useStore.getState().ackBookingAllergy(e.id,n)}):null,(0,a.needsHoldOk)(e)?(0,h.jsx)(l.Button,{small:!0,kind:"success",label:/platter/i.test((0,a.holdsText)(e,O,T))?'Platter OK':'Reservation OK',testID:`platter-ok-${e.ref}`,onPress:()=>j(e.id,n)}):null,e.date===t&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(e.status)?(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${e.ref}`,onPress:()=>S(e,n,b)}):null]}):(0,h.jsx)(l.Muted,{children:"The kitchen signs these off."})]},e.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:n}){const u=(0,r.useBookings)(e),b=(0,r.useRestaurant)(e),f=(0,o.useStockItems)(e),p=(0,a.heldSummary)(u,t,(0,a.reservablesOf)(b)),k=Object.entries(p.stock).filter(([,e])=>e>0).map(([e,t])=>`${t} ${(f.find(t=>t.key===e)?.name??e).toLowerCase()}`);return p.platters||k.length?(0,h.jsx)(s.default,{testID:"platters-booked",children:(0,h.jsxs)(l.T,{weight:"semibold",colour:c.colours.goldLight,children:[n??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null},_r(d[0]);var e,t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=_r(d[2]),r=_r(d[3]),o=_r(d[4]),n=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]);const b=({label:e,bg:t,fg:r,border:o,testID:n})=>(0,h.jsx)(s.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,h.jsx)(l.T,{size:13,weight:"semibold",colour:r,children:e})});function f({b:e,big:t}){return(0,a.hasAllergens)(e)?(0,h.jsxs)(s.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:c.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,h.jsxs)(l.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,a.allergenText)(e)]}),e.allergyAck?(0,h.jsxs)(l.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,h.jsx)(l.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function p({b:e,r:t}){const s=(0,o.useStockItems)(e.restaurantId),r=(0,a.reservablesOf)(t),n=(e.holds??[]).some(e=>e.qty>0),u=[];return e.drinksOnly&&u.push((0,h.jsx)(b,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:c.colours.surface2,fg:c.colours.goldLight,border:c.colours.accentBorder},"x")),(0,a.hasAccess)(e)&&u.push((0,h.jsx)(b,{testID:"pill-access",label:`\u267f ${(0,a.accessText)(e)}`,bg:c.colours.blueBg,fg:"#D6E9FF",border:c.colours.blue},"a")),(0,a.dogCount)(e)&&u.push((0,h.jsx)(b,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,a.dogCount)(e)>1?`${(0,a.dogCount)(e)} dogs`:'Dog'),bg:c.colours.surface2,fg:c.colours.text,border:c.colours.hairline},"d")),(0,a.dietText)(e)&&u.push((0,h.jsx)(b,{testID:"pill-veg",label:`\ud83c\udf31 ${(0,a.dietText)(e)}`,bg:"#14261A",fg:"#CFF3D7",border:"#3C7A4E"},"v")),n&&u.push(e.holdOk?(0,h.jsx)(b,{testID:"pill-platter",label:`\u2713 ${(0,a.holdsText)(e,r,s)} \xb7 confirmed`,bg:c.colours.greenBg,fg:"#CFF3D7",border:c.colours.green},"h"):(0,h.jsx)(b,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,a.holdsText)(e,r,s)} \xb7 awaiting kitchen`,bg:c.colours.amberBg,fg:"#FFE2A8",border:c.colours.amber},"h")),e.tableReq?.length&&u.push((0,h.jsx)(b,{testID:"pill-request",label:`Requested: ${e.tableReq.map(e=>`T${e}`).join(' or ')}`,bg:c.colours.goldTint,fg:c.colours.goldLight,border:c.colours.accentBorder},"t")),u.length?(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:u}):null}function k({b:e,big:t}){const l=(0,r.useRestaurant)(e.restaurantId);return(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(f,{b:e,big:t}),(0,h.jsx)(p,{b:e,r:l})]})}const x=e=>[(0,a.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,a.hasAccess)(e)?'\u267f':'',(0,a.dogCount)(e)?'\ud83d\udc15':'',(0,a.dietText)(e)?'\ud83c\udf31':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),j=(e,t)=>r.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function S(e,t,s){const l=r.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),n=(0,a.stockNeed)(e,(0,a.reservablesOf)(l));for(const[l,r]of Object.entries(n))r>0&&o.shellfish.append({rid:e.restaurantId,kind:l,delta:-r,reason:'sold',by:t,app:s});const u=(new Date).toISOString();r.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:u}})})}const y=e=>o.useShellStore.getState().items[e]??[];function D(e,t){return(0,r.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,a.needsAllergenSeen)(e)||(0,a.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},894,[12,109,791,797,1034,813,805,796,799,6]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SHAPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"shapeLabel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"tableLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"FIXTURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"PLAN_W",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"PLAN_H",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"GRID",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"snap",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"clamp",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"fid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"slug",{enumerable:!0,get:function(){return f}}),_e.sizeFor=p,Object.defineProperty(_e,"minFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"numOf",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"byNumber",{enumerable:!0,get:function(){return y}}),_e.newTable=x,_e.autoArrange=O,_e.placeNew=P,_e.rotate90=function(e){const t=e.x+e.w/2,n=e.y+e.h/2;return{...e,w:e.h,h:e.w,x:b(c(t-e.h/2),0,u-e.h),y:b(c(n-e.w/2),0,l-e.w)}},_e.normalisePlan=function(e){return{...e,fixtures:e.fixtures??[],tables:e.tables.map(e=>{const t=e.shape;let n='booth'===t||'rect'===t?'rect':'round'===t?'round':'square',{w:r,h:a}=e;if('square'===n||'round'===n){const e=Math.max(r,a);r=e,a=e}if(90===e.rot||270===e.rot){const e=r;r=a,a=e}return'rect'===n&&r===a&&(n='square'),{...e,shape:n,w:r,h:a,rot:0}})}},Object.defineProperty(_e,"SECTION_COLOURS",{enumerable:!0,get:function(){return j}}),_e.buildPlan=M,_e.anchoragePlan=F,_e.starterPlan=function(){return M({areas:[{name:'Main room',tables:[[1,2],[2,4],[3,6],[4,4],[5,2],[6,6]],fixtures:[k(450,600)]}]},['SV'])},Object.defineProperty(_e,"TEMPLATES",{enumerable:!0,get:function(){return $}}),_e.parseTableList=function(e){const t=[],n=[];let r;for(const a of e.split(/\r?\n/)){const e=a.trim();if(!e)continue;if(!/\d/.test(e)){r=e.replace(/[:\-\u2013]+$/,'').trim()||r;continue}const o=e.match(/^(?:table|tbl|tab|t)?\s*(?:no\.?|number|#)?\s*([a-z]?\d+[a-z]?)\b[^\d]*?(\d+)/i);if(!o){n.push(e);continue}const s=parseInt(o[2],10);!s||s>30?n.push(e):t.push({area:r,name:o[1].toUpperCase(),seats:s})}return{items:t,skipped:n}},Object.defineProperty(_e,"planCounts",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"tableDogOk",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"dogTables",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"areaOfTable",{enumerable:!0,get:function(){return q}});var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e};const r=[{id:'square',label:'Square'},{id:'rect',label:'Rectangle'},{id:'round',label:'Round'}],a=e=>'rect'===e?'Rectangle':'round'===e?'Round':'Square',o=e=>e.label&&e.label.trim()||e.name,s=[{id:'bar',label:'Bar',w:300,h:50},{id:'wall',label:'Wall',w:250,h:25},{id:'door',label:'Door',w:100,h:25},{id:'window',label:'Window',w:200,h:25}],u=1e3,l=625,i=25,c=e=>Math.round(e/i)*i,b=(e,t,n)=>Math.max(t,Math.min(n,e));let m=0;const h=e=>`${e}-${Date.now().toString(36)}${(m++).toString(36)}`,f=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'area';function p(e){return e<=2?{shape:'square',w:75,h:75}:e<=4?{shape:'square',w:100,h:100}:e<=6?{shape:'rect',w:150,h:100}:e<=8?{shape:'rect',w:200,h:100}:e<=10?{shape:'rect',w:250,h:100}:{shape:'rect',w:300,h:100}}const g=e=>e<=2?1:Math.max(2,Math.ceil(e/2)),w=e=>{const t=e.match(/\d+/);return t?parseInt(t[0],10):9999},y=(e,t)=>w(e.name)-w(t.name)||e.name.localeCompare(t.name);function x(e,t,n,r){const a=p(n);return{id:`t-${e}-${h('x').slice(2)}`,name:e,areaId:t,shape:a.shape,minSeats:g(n),maxSeats:n,x:0,y:0,w:a.w,h:a.h,rot:0,online:!0,sectionId:r}}function O(e,t=125,n=75){const r=[...e].sort(y);if(!r.length)return r;let a=75;const o=e=>{const t=[];let n=[],a=0;for(const o of r){const r=(n.length?e:0)+o.w;n.length&&a+r>850&&(t.push(n),n=[],a=0),n.push(o),a+=(n.length>1?e:0)+o.w}return n.length&&t.push(n),t};let s=o(a);const m=(e,t)=>e.reduce((e,t)=>e+Math.max(...t.map(e=>e.h)),0)+t*(e.length-1);for(;m(s,a)>l-t-n&&a>25;)a-=25,s=o(a);const h=m(s,a),f=l-t-n,p=s.length>1?Math.min(150,a+Math.max(0,Math.floor((f-h)/(s.length-1)/i)*i)):0,g=s.reduce((e,t)=>e+Math.max(...t.map(e=>e.h)),0)+p*(s.length-1);let w=c(t+Math.max(0,(f-g)/2));const x=[];for(const e of s){const t=Math.max(...e.map(e=>e.h)),n=e.reduce((e,t)=>e+t.w,0)+a*(e.length-1);let r=c((u-n)/2);for(const n of e)x.push({...n,x:b(r,0,u-n.w),y:b(c(w+(t-n.h)/2),0,l-n.h),rot:0}),r+=n.w+a;w+=t+p}return x}function P(e,t,n=[]){const r=[...e,...n].map(e=>({x:e.x,y:e.y,w:e.w,h:e.h})),a=[];for(const e of t){let t=null;for(let n=50;n<=l-e.h-25&&!t;n+=i)for(let a=50;a<=u-e.w-25&&!t;a+=i){const o=50;r.some(t=>at.x&&nt.y)||(t={x:a,y:n})}const n=t??{x:50,y:50},o={...e,x:n.x,y:n.y};r.push({x:o.x,y:o.y,w:o.w,h:o.h}),a.push(o)}return a}const j=['#CFA45F','#8EC5FF','#C79BE8','#7BD88F','#FFB547','#FF9AA2'];function M(e,t=[]){const n=[],r=[],a=[],o=[];e.areas.forEach((e,s)=>{const i=f(e.name);n.push({id:i,name:e.name,dogs:!!e.dogs,outdoor:!!e.outdoor,...e.label?{label:e.label}:{},...e.colour?{colour:e.colour}:{}});const c=`s-${i}`;o.push({id:c,name:e.name,colour:e.colour??j[s%j.length],server:t[s]??''});const m=(e.fixtures??[]).map((e,t)=>({...e,id:`fx-${i}-${t}`,areaId:i}));a.push(...m);const h=m.some(e=>e.y<100&&('bar'===e.kind||e.w>=300))?150:100,p=e.tables.map(([e,t])=>({...x(String(e),i,t,c),id:`t-${e}`})),g=e.layout??{},w=p.filter(e=>g[e.name]).map(e=>{const t=g[e.name],n=t.shape??(t.w===t.h?'square':'rect'),r=b(Math.round(t.w),50,u),a=b(Math.round('rect'===n?t.h:t.w),50,l);return{...e,shape:n,w:r,h:a,x:b(Math.round(t.x),0,u-r),y:b(Math.round(t.y),0,l-a),...t.label?{label:t.label}:{}}}),y=p.filter(e=>!g[e.name]);w.length?r.push(...w,...P(w,y,m)):r.push(...O(p,h,75))});const s=new Set(r.map(e=>e.name)),i=(e.joins??[]).filter(e=>e.every(e=>s.has(e))).map(e=>({id:`j-${e.join('-')}`,tables:e}));return{areas:n,tables:r,joins:i,sections:o,fixtures:a}}const S=(e,t,n=0,r=25)=>({kind:'window',x:e,y:n,w:t,h:r}),k=(e,t,n=100,r=25)=>({kind:'door',x:e,y:t,w:n,h:r});function F(){const e=n.default;return M({areas:e.areas.map(e=>({name:e.name,dogs:!!e.dogFriendly,outdoor:!(!e.outdoor&&!e.weatherDependent),label:e.label,colour:e.colour,tables:e.tables.map(([e,t])=>[e,t]),layout:e.layout,fixtures:[]})),joins:e.joins??[]},e.areas.map(e=>e.server??''))}const $=[{id:'anchorage',name:'The Anchorage',sub:'4 areas \xb7 29 tables \xb7 119 seats',make:F},{id:'cafe',name:'Small caf\xe9',sub:'1 room \xb7 8 tables \xb7 dogs welcome',make:()=>M({areas:[{name:'Caf\xe9',dogs:!0,tables:[[1,2],[2,2],[3,4],[4,4],[5,2],[6,4],[7,2],[8,6]],fixtures:[{kind:'bar',x:300,y:25,w:400,h:50},k(450,600)]}]})},{id:'pub',name:'Pub with garden',sub:'Bar, lounge and beer garden',make:()=>M({areas:[{name:'Bar',dogs:!0,tables:[[1,2],[2,4],[3,4],[4,2],[5,4],[6,6]],fixtures:[{kind:'bar',x:250,y:25,w:500,h:75}]},{name:'Lounge',tables:[[7,4],[8,4],[9,2],[10,6],[11,4],[12,2],[13,4],[14,8]],fixtures:[S(150,700)]},{name:'Beer garden',dogs:!0,outdoor:!0,tables:[[20,6],[21,6],[22,4],[23,4],[24,6],[25,6]]}]})},{id:'restaurant',name:'Restaurant and terrace',sub:'Dining room with an outdoor terrace',make:()=>M({areas:[{name:'Dining room',tables:[[1,2],[2,2],[3,4],[4,4],[5,4],[6,6],[7,2],[8,2],[9,4],[10,4],[11,6],[12,8]],fixtures:[S(100,800),k(450,600)]},{name:'Terrace',outdoor:!0,tables:[[20,2],[21,4],[22,4],[23,2]]}]})},{id:'blank',name:'Blank',sub:'One empty room to start from',make:()=>M({areas:[{name:'Main room',tables:[]}]})}];const I=(e,t)=>{const n=t?e.tables.filter(e=>e.areaId===t):e.tables;return{tables:n.length,seats:n.reduce((e,t)=>e+t.maxSeats,0)}},C=(e,t)=>void 0!==t.dogOk?t.dogOk:!!e.areas.find(e=>e.id===t.areaId)?.dogs,T=e=>new Set(e.tables.filter(t=>C(e,t)).map(e=>e.name)),q=(e,t)=>e.areas.find(n=>n.id===e.tables.find(e=>e.name===t)?.areaId)},895,[1016]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useScreensaverAsleep",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(t=>({asleep:!1,set:n=>t({asleep:n})}))},896,[974]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ActionTile=function({label:e,sub:r,icon:c,onPress:u,primary:h,tone:b="gold",count:f,testID:x,accessibilityLabel:y}){const j='blue'===b?i.colours.blue:i.colours.gold;return(0,s.jsxs)(l.default,{testID:x,accessibilityRole:"button",accessibilityLabel:y??(r?`${e}, ${r}`:e),onPress:u,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:68,borderRadius:16,borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline,backgroundColor:e?i.colours.tilePressed:i.colours.tile,flexDirection:'row',alignItems:'center',gap:12,paddingHorizontal:14,paddingVertical:12}),children:[(0,s.jsx)(o.default,{style:{width:40,height:40,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:h?i.colours.accentBg:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:h?i.colours.accentBorder:i.colours.hairline},children:(0,s.jsx)(t.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,s.jsx)(n.T,{size:15,weight:"semibold",numberOfLines:1,colour:i.colours.text,children:e}),r?(0,s.jsx)(n.T,{size:12,numberOfLines:1,colour:i.colours.muted,children:r}):null]}),f?(0,s.jsx)(o.default,{style:{backgroundColor:i.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,s.jsx)(n.T,{size:12,weight:"bold",colour:i.colours.onGold,center:!0,children:f})}):null]})},_e.ActionGrid=function({children:e,testID:l="action-grid"}){const t=r.default.Children.toArray(e).filter(Boolean),i=[];for(let e=0;e(0,s.jsxs)(o.default,{style:{flexDirection:'row',gap:12},children:[e,1===e.length?(0,s.jsx)(o.default,{style:{flex:1}}):null]},r))})},Object.defineProperty(_e,"CardHeading",{enumerable:!0,get:function(){return c}});var r=e(_r(d[0])),l=e(_r(d[1])),o=e(_r(d[2])),t=_r(d[3]),i=_r(d[4]),n=_r(d[5]),s=_r(d[6]);const c=({children:e,right:r})=>(0,s.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,s.jsx)(n.T,{size:12,weight:"semibold",colour:i.colours.goldMuted,style:{letterSpacing:1.6,textTransform:'uppercase'},children:e}),r]})},897,[12,245,109,912,799,791,6]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";function i(i){return i&&i.__esModule?i:{default:i}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_AVATARS",{enumerable:!0,get:function(){return h}}),_e.specFor=p,_e.AvatarArt=b,_e.useStaffMember=A,_e.StaffAvatar=function({id:i,name:r,size:t=34,ring:s=!0}){const o=A(i,r),h=o?.id??i,y=(0,c.useAvatars)(i=>h?i.photos[h]:void 0),F=(0,n.useSetup)(i=>h?i.looks[h]:void 0),j=`${(o?.name??r??'Team member').replace(' (example)','')}'s avatar`;return(0,f.jsx)(e.default,{testID:h?`avatar-${h}`:'avatar',accessibilityLabel:j,accessibilityRole:"image",style:{width:t,height:t,borderRadius:t/2,overflow:'hidden',borderWidth:s?Math.max(1,t/22):0,borderColor:x.colours.gold,backgroundColor:'#111'},children:y?(0,f.jsx)(l.default,{source:{uri:y.dataUrl},style:{width:'100%',height:'100%'},accessibilityIgnoresInvertColors:!0}):(0,f.jsx)(b,{spec:null!=F?p(`${h}#look${F}`):p(h,o?.name??r),size:t-(s?2*Math.max(1,t/22):0)})})},_r(d[0]);var l=i(_r(d[1])),e=i(_r(d[2])),r=_r(d[3]),t=i(r),s=_r(d[4]),c=_r(d[5]),n=_r(d[6]),x=_r(d[7]),o=_r(d[8]),f=_r(d[9]);const h=Object.fromEntries(o.ROSTER.map(i=>[i.id,i.avatar])),y=['#1F6F78','#C8553D','#D9A441','#3D5A80','#6A4C93','#2E7D5B'],F=['#F1C7A5','#E8B48F','#C68B5E','#8D5B3E','#F4D2B8','#A86B45'],j=['#2B1B12','#7A4E2A','#151515','#C2462E','#D9B26A'],u=['quiff','flip','crop','beehive','bob','curls'],C=i=>{let l=7;for(const e of i)l=31*l+e.charCodeAt(0)>>>0;return l};function p(i,l){if(i&&h[i])return h[i];const e=C(i||l||'crew');return{bg:y[e%6],ring:e%2?'#E9B949':'#3FB8AF',skin:F[(e>>3)%6],hair:j[(e>>6)%5],hairStyle:u[(e>>9)%6],suit:'#F2EAD8',antenna:['ball','star','none'][(e>>12)%3]}}const E=(i,l,e)=>`M${i} ${l-e} Q${i+.18*e} ${l-.18*e} ${i+e} ${l} Q${i+.18*e} ${l+.18*e} ${i} ${l+e} Q${i-.18*e} ${l+.18*e} ${i-e} ${l} Q${i-.18*e} ${l-.18*e} ${i} ${l-e}Z`;function b({spec:i,size:l=40}){const e=i,s='#1B1B1B',c='flip'===e.hairStyle?(0,f.jsx)(r.Path,{d:"M29 50 C26 30 40 22 50 22 C60 22 74 30 71 50 C75 56 79 60 76 65 C72 60 69 58 66 57 L34 57 C31 58 28 60 24 65 C21 60 25 56 29 50Z",fill:e.hair}):'bob'===e.hairStyle?(0,f.jsx)(r.Path,{d:"M30 58 C27 32 40 24 50 24 C60 24 73 32 70 58 L66 60 L34 60Z",fill:e.hair}):'beehive'===e.hairStyle?(0,f.jsxs)(r.G,{children:[(0,f.jsx)(r.Ellipse,{cx:50,cy:25,rx:15,ry:14,fill:e.hair}),(0,f.jsx)(r.Path,{d:"M31 54 C28 34 40 27 50 27 C60 27 72 34 69 54 Z",fill:e.hair})]}):'curls'===e.hairStyle?(0,f.jsx)(r.G,{children:[[34,34],[40,27],[50,24],[60,27],[66,34],[69,43],[31,43]].map(([i,l],t)=>(0,f.jsx)(r.Circle,{cx:i,cy:l,r:7,fill:e.hair},t))}):null,n='quiff'===e.hairStyle?(0,f.jsxs)(r.G,{children:[(0,f.jsx)(r.Path,{d:"M32 42 C31 27 43 23 51 25 C61 22 70 30 68 42 C63 35 57 33 50 34 C43 34 37 37 32 42Z",fill:e.hair}),(0,f.jsx)(r.Path,{d:"M46 26 C51 14 66 14 66 23 C61 20 54 21 50 28Z",fill:e.hair})]}):'crop'===e.hairStyle?(0,f.jsx)(r.Path,{d:"M32 42 C31 28 42 25 50 25 C58 25 69 28 68 42 C64 36 58 33 50 33 C42 33 36 36 32 42Z",fill:e.hair}):'curls'===e.hairStyle?null:(0,f.jsx)(r.Path,{d:"M32 43 C33 30 42 27 50 27 C58 27 67 30 68 43 C61 38 57 33 51 33 C47 37 39 41 32 43Z",fill:e.hair});return(0,f.jsxs)(t.default,{width:l,height:l,viewBox:"0 0 100 100",children:[(0,f.jsx)(r.Circle,{cx:50,cy:50,r:50,fill:e.bg}),(0,f.jsx)(r.Ellipse,{cx:50,cy:50,rx:46,ry:13,fill:"none",stroke:"#FFF4E0",strokeOpacity:.28,strokeWidth:1.6,transform:"rotate(-28 50 50)"}),(0,f.jsx)(r.Path,{d:E(16,24,6),fill:"#FFF4E0",fillOpacity:.85}),(0,f.jsx)(r.Path,{d:E(84,34,4),fill:"#FFF4E0",fillOpacity:.7}),(0,f.jsx)(r.Circle,{cx:80,cy:16,r:1.6,fill:"#FFF4E0",fillOpacity:.8}),(0,f.jsx)(r.Circle,{cx:22,cy:70,r:1.3,fill:"#FFF4E0",fillOpacity:.6}),(0,f.jsx)(r.Path,{d:"M12 100 C14 82 31 74 50 74 C69 74 86 82 88 100 Z",fill:e.suit}),(0,f.jsx)(r.Path,{d:"M36 100 L40 84 L50 90 L60 84 L64 100Z",fill:e.ring,fillOpacity:.35}),(0,f.jsx)(r.Rect,{x:44,y:60,width:12,height:12,fill:e.skin}),c,(0,f.jsx)(r.Ellipse,{cx:50,cy:46,rx:17,ry:18.5,fill:e.skin}),n,e.specs?(0,f.jsxs)(r.G,{stroke:s,strokeWidth:1.6,fill:"#FFFFFF",fillOpacity:.25,children:[(0,f.jsx)(r.Rect,{x:37,y:42,width:11,height:8,rx:4}),(0,f.jsx)(r.Rect,{x:52,y:42,width:11,height:8,rx:4}),(0,f.jsx)(r.Line,{x1:48,y1:45,x2:52,y2:45})]}):null,(0,f.jsx)(r.Ellipse,{cx:42.5,cy:46.5,rx:2.1,ry:2.7,fill:s}),(0,f.jsx)(r.Ellipse,{cx:57.5,cy:46.5,rx:2.1,ry:2.7,fill:s}),(0,f.jsx)(r.Circle,{cx:43.3,cy:45.5,r:.8,fill:"#FFFFFF"}),(0,f.jsx)(r.Circle,{cx:58.3,cy:45.5,r:.8,fill:"#FFFFFF"}),(0,f.jsx)(r.Circle,{cx:38,cy:53,r:3,fill:"#F08A7E",fillOpacity:.55}),(0,f.jsx)(r.Circle,{cx:62,cy:53,r:3,fill:"#F08A7E",fillOpacity:.55}),(0,f.jsx)(r.Path,{d:"M44.5 55 Q50 60 55.5 55",stroke:s,strokeWidth:1.8,fill:"none",strokeLinecap:"round"}),(0,f.jsx)(r.Ellipse,{cx:50,cy:74,rx:21,ry:5.5,fill:e.ring}),(0,f.jsx)(r.Ellipse,{cx:50,cy:73,rx:16,ry:3,fill:"#000000",fillOpacity:.18}),(0,f.jsx)(r.Circle,{cx:50,cy:88,r:4,fill:e.ring}),(0,f.jsx)(r.Circle,{cx:50,cy:88,r:1.6,fill:e.bg}),(0,f.jsx)(r.Circle,{cx:50,cy:45,r:29,fill:"#DFF3F7",fillOpacity:.1,stroke:"#E8F6FA",strokeOpacity:.85,strokeWidth:2}),(0,f.jsx)(r.Path,{d:"M29 36 A23 23 0 0 1 41 22",stroke:"#FFFFFF",strokeOpacity:.85,strokeWidth:3.2,fill:"none",strokeLinecap:"round"}),(0,f.jsx)(r.Circle,{cx:28.5,cy:42,r:1.5,fill:"#FFFFFF",fillOpacity:.85}),'none'!==e.antenna?(0,f.jsx)(r.Line,{x1:50,y1:16,x2:50,y2:8,stroke:e.ring,strokeWidth:2}):null,'ball'===e.antenna?(0,f.jsx)(r.Circle,{cx:50,cy:6.5,r:3.3,fill:e.ring}):'star'===e.antenna?(0,f.jsx)(r.Path,{d:E(50,6.5,4.5),fill:e.ring}):null]})}const k=i=>(i??'').replace(' (example)','').trim().toLowerCase();function A(i,l){const e=(0,s.useOwner)(i=>i.staff);return i?e.find(l=>l.id===i):l?e.find(i=>k(i.name)===k(l)):void 0}},898,[12,178,109,852,813,1089,1090,799,916,6]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.2.21'},908,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtDate",{enumerable:!0,get:function(){return m}}),_e.SignOffLine=b,_e.CardView=w,_e.CardEditor=I,_e.RecipeCards=function({rid:e,actor:t,mode:d}){const f=(0,o.useRecipeCards)(e),[j,b]=(0,s.useState)(''),[C,D]=(0,s.useState)([]),[v,k]=(0,s.useState)('free-from'),[T,S]=(0,s.useState)('all'),[B,$]=(0,s.useState)(null),[P,R]=(0,s.useState)(null),L='edit'===d&&(0,h.canEditCards)(t.role),A=L?f:f.filter(e=>!!e.signOff),M=(0,s.useMemo)(()=>{const e='all'===T?A:A.filter(e=>(0,h.cardState)(e)===T);return(0,h.filterCards)(e,j,C,v).slice().sort((e,s)=>e.section.localeCompare(s.section)||e.dish.localeCompare(s.dish))},[A,j,C,v,T]),E=f.filter(e=>!e.signOff).length,N=B?f.find(e=>e.id===B):void 0,O=P&&'new'!==P?f.find(e=>e.id===P)??null:null,H=e=>D(s=>s.includes(e)?s.filter(s=>s!==e):[...s,e]);return(0,p.jsxs)(i.default,{testID:"recipe-cards",style:{gap:12},children:['read'===d?(0,p.jsx)(a.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,p.jsx)(a.Muted,{children:(0,h.canSignOffCards)(t.role)?'You can add, edit and sign off cards. A card only goes live once you sign it off; any edit sets it back to Awaiting sign-off.':'You can add and edit cards. The head chef signs them off before they go live; any edit sets a card back to Awaiting sign-off.'}),f.some(e=>'example'===e.origin)?(0,p.jsx)(a.Banner,{kind:"example",title:"Example data",children:"Cards marked \u201cExample data\u201d are made-up examples to show how recipe cards work. Replace them with your own dishes."}):null,L?(0,p.jsx)(a.Button,{testID:"new-card",label:"+ New recipe card",onPress:()=>R('new')}):null,(0,p.jsx)(l.default,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:j,onChangeText:b,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,p.jsxs)(a.Row,{gap:6,wrap:!0,children:[(0,p.jsx)(a.T,{size:r.font.small,colour:r.colours.muted,children:"Allergens:"}),(0,p.jsx)(a.Chip,{label:"Free from",selected:'free-from'===v,onPress:()=>k('free-from')}),(0,p.jsx)(a.Chip,{label:"Contains",selected:'contains'===v,onPress:()=>k('contains')}),C.length?(0,p.jsx)(a.Chip,{label:"Clear",onPress:()=>D([])}):null]}),(0,p.jsx)(a.Row,{gap:6,wrap:!0,children:c.ALLERGENS.map(e=>(0,p.jsx)(n.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:C.includes(e.id)},onPress:()=>H(e.id),style:{paddingVertical:5,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:C.includes(e.id)?r.colours.gold:r.colours.border,backgroundColor:C.includes(e.id)?r.colours.gold:'transparent'},children:(0,p.jsx)(a.T,{size:13,colour:C.includes(e.id)?r.colours.onGold:r.colours.text,children:e.short})},e.id))}),L?(0,p.jsxs)(a.Row,{gap:6,wrap:!0,children:[(0,p.jsx)(a.Chip,{label:`All (${f.length})`,selected:'all'===T,onPress:()=>S('all')}),(0,p.jsx)(a.Chip,{label:`Awaiting sign-off (${E})`,selected:'awaiting'===T,onPress:()=>S('awaiting')}),(0,p.jsx)(a.Chip,{label:`Signed off (${f.length-E})`,selected:'signed-off'===T,onPress:()=>S('signed-off')})]}):null,(0,p.jsx)(i.default,{testID:"card-count",children:(0,p.jsxs)(a.Muted,{children:[M.length," ",1===M.length?'card':'cards',C.length?` ${'free-from'===v?'free from':'containing'} ${C.map(c.allergenLabel).join('free-from'===v?' and ':' or ')}`:'']})}),M.map(e=>(0,p.jsx)(n.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:`${e.dish}, ${e.signOff?'signed off':'awaiting sign-off'}`,onPress:()=>$(e.id),children:(0,p.jsx)(a.Card,{highlight:!e.signOff&&L?r.colours.amber:void 0,children:(0,p.jsxs)(a.Row,{gap:12,style:{alignItems:'flex-start'},children:[(0,p.jsx)(i.default,{style:{width:84},children:(0,p.jsx)(y,{card:e,height:64})}),(0,p.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,p.jsx)(a.T,{weight:"semibold",children:e.dish}),(0,p.jsxs)(a.Muted,{children:[e.section," \xb7 ",x(e.price),'example'===e.origin?` \xb7 ${u.EXAMPLE_TAG}`:'']}),(0,p.jsxs)(a.Row,{gap:4,wrap:!0,children:[e.signOff?(0,p.jsx)(a.Badge,{label:`\u2713 ${m(e.signOff.at)}`,kind:"green"}):(0,p.jsx)(a.Badge,{label:h.STATE_LABEL.awaiting,kind:"amber"}),c.ALLERGENS.filter(s=>e.allergens[s.id]).map(s=>(0,p.jsx)(a.Badge,{label:'may'===e.allergens[s.id]?`${s.short}?`:s.short,kind:'may'===e.allergens[s.id]?'amber':'red'},s.id))]})]})]})})},e.id)),M.length?null:(0,p.jsx)(a.Muted,{children:"No cards match."}),(0,p.jsx)(a.Sheet,{visible:!!N&&!P,onClose:()=>$(null),title:N?.dish??'',maxWidth:640,testID:"card-sheet",children:N?(0,p.jsx)(w,{card:N,actor:'read'===d?{...t,role:'staff'}:t,onEdit:L?()=>R(N.id):void 0}):null}),(0,p.jsx)(a.Sheet,{visible:!!P,onClose:()=>R(null),title:'new'===P?'New recipe card':`Edit: ${O?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:P?(0,p.jsx)(I,{rid:e,card:O,actor:t,onDone:e=>{R(null),$(e)}},P):null})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),l=e(_r(_d[3])),i=e(_r(_d[4])),r=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]);const m=e=>{const s=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+s)?e:s.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},x=e=>null==e?'Price on the board':`\xa3${(e/100).toFixed(2)}`,j={example:u.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function b({card:e,testID:s}){return e.signOff?(0,p.jsxs)(i.default,{testID:s,style:{gap:2},children:[(0,p.jsx)(a.Badge,{label:`\u2713 ${h.STATE_LABEL['signed-off']}`,kind:"green"}),(0,p.jsxs)(a.T,{size:r.font.small,colour:r.colours.green,children:["Signed off by ",e.signOff.by," on ",m(e.signOff.at)]})]}):(0,p.jsxs)(i.default,{testID:s,style:{gap:2},children:[(0,p.jsx)(a.Badge,{label:h.STATE_LABEL.awaiting,kind:"amber"}),(0,p.jsx)(a.T,{size:r.font.small,colour:r.colours.amber,children:e.wasLive?'Edited since the last sign-off. The dish shows "awaiting allergen sign-off" to guests and cannot be ordered until the head chef signs it off.':'New dish: it stays off the menu until the head chef signs it off.'})]})}function y({card:e,height:s=180,pending:n}){const l=n?{uri:n}:e.photo?(0,d.recipeCards)().photoSource(e.photo):null;return l?(0,p.jsx)(t.default,{testID:"card-photo",accessibilityLabel:`Plating photo: ${e.dish}`,source:l,style:{width:'100%',height:s,borderRadius:12,backgroundColor:r.colours.surface2},resizeMode:"cover"}):(0,p.jsx)(i.default,{style:{height:s,borderRadius:12,backgroundColor:r.colours.surface2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:r.colours.border},children:(0,p.jsx)(a.Muted,{children:"No plating photo yet"})})}function C({map:e}){const s=c.ALLERGENS.filter(s=>e[s.id]).map(e=>e.id);return s.length?(0,p.jsx)(a.Row,{wrap:!0,gap:6,children:s.map(s=>(0,p.jsx)(a.Badge,{label:'may'===e[s]?`May contain ${(0,c.allergenLabel)(s).toLowerCase()}`:(0,c.allergenLabel)(s),kind:'may'===e[s]?'amber':'red'},s))}):(0,p.jsx)(a.Muted,{children:"None of the UK 14 allergens."})}function w({card:e,actor:t,onEdit:n}){const[l,o]=(0,s.useState)(null),c=(0,h.signOffBlock)(e),u=j[e.origin];return(0,p.jsxs)(i.default,{testID:"card-view",style:{gap:12},children:[(0,p.jsx)(y,{card:e,height:200}),(0,p.jsxs)(a.Row,{wrap:!0,gap:6,children:[u?(0,p.jsx)(a.Badge,{label:u,kind:'example'===e.origin?'blue':'neutral'}):null,(0,p.jsx)(a.Badge,{label:e.section,kind:"gold"}),(0,p.jsx)(a.Badge,{label:x(e.price)})]}),(0,p.jsx)(b,{card:e,testID:"card-status"}),(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Allergens"}),(0,p.jsx)(i.default,{testID:"card-allergens",children:(0,p.jsx)(C,{map:e.allergens})}),e.allergenNotes?(0,p.jsx)(a.Muted,{children:e.allergenNotes}):null,e.allergensConfirmed?(0,p.jsxs)(a.Muted,{children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",m(e.allergensConfirmed.at),"."]}):null,(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Ingredients"}),e.ingredients.length?e.ingredients.map(e=>(0,p.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(a.T,{style:{flex:1},children:e.name}),(0,p.jsx)(a.T,{colour:r.colours.goldLight,children:[e.qty,e.unit].filter(Boolean).join(' ')})]},e.id)):(0,p.jsx)(a.Muted,{children:"No ingredients on this card yet."}),(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Method"}),e.steps.length?e.steps.map((e,s)=>(0,p.jsxs)(a.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,p.jsx)(i.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:r.colours.goldTint,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(a.T,{size:r.font.small,colour:r.colours.gold,children:s+1})}),(0,p.jsx)(a.T,{style:{flex:1},children:e})]},s)):(0,p.jsxs)(a.Muted,{children:["No method yet.",(0,h.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,p.jsxs)(a.Muted,{children:["Version ",e.version," \xb7 last changed ",m(e.updatedAt)," by ",e.updatedBy]}),(0,h.canEditCards)(t.role)&&n?(0,p.jsx)(a.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",onPress:n}):null,(0,h.canSignOffCards)(t.role)&&!e.signOff?(0,p.jsxs)(i.default,{style:{gap:6},children:[c?(0,p.jsx)(a.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,p.jsx)(a.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,d.recipeCards)().signOff(e.id,t),o(null)}catch(e){o(e?.message??'Could not sign off.')}}})]}):null,!(0,h.canEditCards)(t.role)||(0,h.canSignOffCards)(t.role)||e.signOff?null:(0,p.jsx)(a.Banner,{kind:"info",title:"Head chef sign-off",children:"Only the head chef can sign off a recipe card, in the Head Chef app."}),l?(0,p.jsx)(a.Banner,{kind:"danger",children:l}):null]})}const D=()=>`i-${Math.random().toString(36).slice(2,9)}`,v=(e,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photo:e.photo,pending:null,confirm:!!e.allergensConfirmed}:{id:(0,h.uuid)(),dish:'',section:s,price:'',description:'',ingredients:[{id:D(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',pending:null,confirm:!1},k=e=>{const s=e.replace(/[\xa3\s]/g,'');if(!s)return null;const t=Number(s);return isFinite(t)&&t>=0?Math.round(100*t):'bad'};function I({rid:e,card:t,actor:u,onDone:m}){const x=(0,o.useRestaurant)(e),j=x?.sections??['Mains'],[b,C]=(0,s.useState)(()=>v(t,j[0]??'Mains')),[w,I]=(0,s.useState)(null),[T,S]=(0,s.useState)(null),[B,$]=(0,s.useState)(!1),P=e=>C(s=>({...s,...e})),R=b.ingredients.filter(e=>e.name.trim()),L={ingredients:R,allergens:b.allergens,dismissed:b.dismissed},A=(0,h.suggestAllergens)(R),M=(0,h.unresolved)(L),E=e=>{const s=b.allergens[e],t={...b.allergens};s?'contains'===s?t[e]='may':delete t[e]:t[e]='contains',P({allergens:t,dismissed:b.dismissed.filter(s=>s!==e),confirm:!1})},N=e=>{const s={...b.allergens};delete s[e],P({allergens:s,dismissed:[...new Set([...b.dismissed,e])],confirm:!1})},O=(e,s)=>P({ingredients:b.ingredients.map((t,n)=>n===e?{...t,...s}:t),confirm:!1}),H=(e,s)=>P({steps:b.steps.map((t,n)=>n===e?s:t)}),F=(e,s)=>{const t=[...b.steps],n=e+s;n<0||n>=t.length||([t[e],t[n]]=[t[n],t[e]],P({steps:t}))},_=async e=>{S(null);try{const s=await(0,f.capturePlatingPhoto)(e);s&&(P({pending:s}),S(`Compressed on this device: ${s.width}\xd7${s.height}, ${(0,f.kb)(s.bytes)}${s.originalBytes?` (was ${(0,f.kb)(s.originalBytes)})`:''}.`))}catch(e){S(e?.message??'Could not read that photo.')}},[z,G]=(0,s.useState)(!1),W=t??{id:b.id,dish:b.dish,photo:b.photo};return(0,p.jsxs)(i.default,{testID:"card-editor",style:{gap:12},children:[t?.signOff?(0,p.jsx)(a.Banner,{kind:"warn",title:"Saving a change resets the sign-off",children:"This card is signed off. Any change you save sets it back to \"Awaiting sign-off\" until the head chef signs it off again."}):null,(0,p.jsx)(a.Field,{testID:"dish-name",label:"Dish name",value:b.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),t?null:(0,p.jsx)(a.Field,{testID:"dish-description",label:"Menu description (optional)",value:b.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,p.jsx)(a.T,{size:r.font.small,weight:"medium",colour:r.colours.muted,children:"Menu section"}),(0,p.jsx)(a.Row,{wrap:!0,gap:6,children:j.map(e=>(0,p.jsx)(a.Chip,{label:e,selected:b.section===e,onPress:()=>P({section:e})},e))}),(0,p.jsx)(a.Field,{testID:"dish-price",label:"Price (\xa3)",value:b.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Plating photo"}),(0,p.jsx)(y,{card:W,pending:b.pending?.dataUrl??null,height:170}),(0,p.jsxs)(a.Row,{gap:8,wrap:!0,children:[(0,p.jsx)(a.Button,{testID:"photo-camera",small:!0,kind:"secondary",label:"\ud83d\udcf7 Take photo",onPress:()=>_('camera')}),(0,p.jsx)(a.Button,{testID:"photo-library",small:!0,kind:"secondary",label:"Choose photo",onPress:()=>_('library')}),b.pending||b.photo?(0,p.jsx)(a.Button,{testID:"photo-remove",small:!0,kind:"ghost",label:"Remove photo",onPress:()=>P({pending:null,photo:void 0})}):null]}),T?(0,p.jsx)(i.default,{testID:"photo-info",children:(0,p.jsx)(a.Muted,{children:T})}):(0,p.jsx)(a.Muted,{children:"Photos are shrunk on this device before they are saved."}),(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Ingredients"}),(0,p.jsx)(a.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),b.ingredients.map((e,s)=>{const t=e.name.trim()?(0,h.suggestAllergens)([e]):[];return(0,p.jsxs)(i.default,{style:{gap:4},children:[(0,p.jsxs)(a.Row,{gap:6,children:[(0,p.jsx)(l.default,{testID:`ing-qty-${s}`,accessibilityLabel:`Quantity ${s+1}`,value:e.qty,onChangeText:e=>O(s,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[a.styles.input,{width:64}]}),(0,p.jsx)(l.default,{testID:`ing-unit-${s}`,accessibilityLabel:`Unit ${s+1}`,value:e.unit,onChangeText:e=>O(s,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[a.styles.input,{width:92}]}),(0,p.jsx)(l.default,{testID:`ing-name-${s}`,accessibilityLabel:`Ingredient ${s+1}`,value:e.name,onChangeText:e=>O(s,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[a.styles.input,{flex:1}]}),(0,p.jsx)(n.default,{accessibilityLabel:`Remove ingredient ${s+1}`,onPress:()=>P({ingredients:b.ingredients.filter((e,t)=>t!==s)}),hitSlop:8,children:(0,p.jsx)(a.T,{colour:r.colours.muted,children:"\u2715"})})]}),t.length?(0,p.jsxs)(a.Muted,{children:["Suggests: ",t.map(c.allergenLabel).join(', ')]}):null]},e.id)}),(0,p.jsx)(a.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"+ Add ingredient",onPress:()=>P({ingredients:[...b.ingredients,{id:D(),name:'',qty:'',unit:''}]})}),(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Method"}),b.steps.map((e,s)=>(0,p.jsxs)(a.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,p.jsx)(a.T,{colour:r.colours.gold,style:{width:20,paddingTop:10},children:s+1}),(0,p.jsx)(l.default,{testID:`step-${s}`,accessibilityLabel:`Step ${s+1}`,value:e,onChangeText:e=>H(s,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[a.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,p.jsxs)(i.default,{style:{gap:4},children:[(0,p.jsx)(n.default,{accessibilityLabel:`Move step ${s+1} up`,onPress:()=>F(s,-1),hitSlop:6,children:(0,p.jsx)(a.T,{colour:r.colours.muted,children:"\u25b2"})}),(0,p.jsx)(n.default,{accessibilityLabel:`Move step ${s+1} down`,onPress:()=>F(s,1),hitSlop:6,children:(0,p.jsx)(a.T,{colour:r.colours.muted,children:"\u25bc"})}),(0,p.jsx)(n.default,{accessibilityLabel:`Remove step ${s+1}`,onPress:()=>P({steps:b.steps.filter((e,t)=>t!==s)}),hitSlop:6,children:(0,p.jsx)(a.T,{colour:r.colours.muted,children:"\u2715"})})]})]},s)),(0,p.jsx)(a.Button,{testID:"step-add",small:!0,kind:"ghost",label:"+ Add step",onPress:()=>P({steps:[...b.steps,'']})}),(0,p.jsx)(a.Divider,{}),(0,p.jsx)(a.H2,{children:"Allergens (UK 14)"}),(0,p.jsx)(a.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),M.length?(0,p.jsxs)(i.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,p.jsx)(a.Banner,{kind:"warn",title:`Check ${M.length} suggested allergen${1===M.length?'':'s'}`,children:M.map(e=>`${(0,c.allergenLabel)(e)} (from ${(0,h.suggestedBy)(R,e).join(', ')})`).join('; ')}),M.map(e=>(0,p.jsxs)(a.Row,{gap:6,wrap:!0,children:[(0,p.jsx)(a.T,{style:{flex:1},children:(0,c.allergenLabel)(e)}),(0,p.jsx)(a.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...b.allergens,[e]:'contains'},confirm:!1})}),(0,p.jsx)(a.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...b.allergens,[e]:'may'},confirm:!1})}),(0,p.jsx)(a.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,p.jsx)(a.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...b.allergens};M.forEach(s=>{e[s]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,p.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(e=>{const s=b.allergens[e.id],t=A.includes(e.id)&&!s&&!b.dismissed.includes(e.id),l='contains'===s?r.colours.redBg:'may'===s?r.colours.amberBg:r.colours.surface2,i='contains'===s?r.colours.red:'may'===s?r.colours.amber:t?r.colours.gold:r.colours.border;return(0,p.jsx)(n.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===s?'contains':'may'===s?'may contain':'not marked'}`,onPress:()=>E(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:t?2:1,borderStyle:t?'dashed':'solid',borderColor:i,backgroundColor:l},children:(0,p.jsxs)(a.T,{size:r.font.small,colour:'contains'===s?'#FFD9D4':'may'===s?'#FFE2A8':r.colours.text,children:[e.short,'may'===s?' (may)':'',t?' ?':'']})},e.id)})}),b.dismissed.length?(0,p.jsxs)(a.Muted,{children:["Ruled out: ",b.dismissed.map(c.allergenLabel).join(', ')]}):null,(0,p.jsx)(a.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:b.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,p.jsxs)(n.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:b.confirm,disabled:M.length>0},disabled:M.length>0,onPress:()=>P({confirm:!b.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:b.confirm?r.colours.green:r.colours.border,opacity:M.length?.5:1},children:[(0,p.jsx)(i.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:b.confirm?r.colours.green:r.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:b.confirm?r.colours.greenBg:'transparent'},children:b.confirm?(0,p.jsx)(a.T,{colour:r.colours.green,children:"\u2713"}):null}),(0,p.jsx)(a.T,{style:{flex:1},children:M.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${u.name})`})]}),w?(0,p.jsx)(a.Banner,{kind:"danger",children:w}):null,(0,p.jsx)(a.Button,{testID:"card-save",label:z?'Saving\u2026':t?'Save changes':'Save card',disabled:z,onPress:async()=>{I(null);const s=k(b.price);if(!b.dish.trim())return I('Give the dish a name.');if('bad'===s)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const n=(0,d.recipeCards)();G(!0);try{let l=b.photo;b.pending&&(l=await n.savePhoto(e,b.id,b.pending));const i=b.steps.map(e=>e.trim()).filter(Boolean),r={dish:b.dish.trim(),section:b.section,price:s,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:b.allergens,dismissed:b.dismissed,allergenNotes:b.allergenNotes.trim()||void 0,photo:l};if(t)await n.update(t.id,{...r,confirmAllergens:b.confirm},u),m(t.id);else{const s=await n.create(e,{...r,id:b.id,description:b.description.trim()||void 0},u);b.confirm&&await n.update(s.id,{confirmAllergens:!0},u),m(s.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{G(!1)}}}),(0,p.jsx)(a.Muted,{children:(0,h.canSignOffCards)(u.role)?'After saving, sign the card off so it goes live.':'After saving, the head chef signs it off in the Head Chef app before it goes live.'}),t?B?(0,p.jsxs)(a.Row,{gap:8,children:[(0,p.jsx)(a.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(t)try{await(0,d.recipeCards)().remove(t.id,u),m(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,p.jsx)(a.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>$(!1)})]}):(0,p.jsx)(a.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>$(!0)}):null]})}},909,[12,178,245,255,109,799,791,797,808,792,1017,1024,1143,6]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ChatAsCtx",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return m.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return m.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>i.useOwner.getState().sys(e,t,n))},_e.ensureChat=C,_e.useChatUnread=v,_e.Chat=function({go:e}){return(0,x.jsx)(k,{children:(0,x.jsx)(I,{go:e})})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),a=e(r(d[3])),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=r(d[7]),h=r(d[8]),u=r(d[9]),m=r(d[10]),f=r(d[11]),x=r(d[12]);const b=(0,t.createContext)(null);function p(e){const n=(0,h.useCtx)(e),s=(0,t.useContext)(b);return s?{...n,meId:s.meId,role:s.role}:n}const j=[{id:'all',name:'Team',icon:'\ud83d\udce3'},{id:'kitchen',name:'Kitchen',icon:'\ud83c\udf73',pinned:!0},{id:'foh',name:'Front of house',icon:'\ud83c\udf7d\ufe0f'},{id:'managers',name:'Managers',icon:'\ud83d\udd12'}],y=[],w=e=>(e??'').replace(' (example)','');function C(e){const t=i.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&i.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on Cover Charge.'}),t.chat.length)return;const n=(t,n,s,a={})=>{return{id:`m-seed-${t}`,ch:t,from:'system',text:s,at:(o=n,new Date(e.getTime()-6e4*o).toISOString()),reactions:{},seenBy:[],...a};var o};i.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on Cover Charge.',{pinned:!0}),n('kitchen',4,'Kitchen channel: Head Chef, kitchen team and managers.'),n('foh',3,'Front of house channel: front of house, bar and managers.'),n('managers',2,'Managers channel: owners, managers and the supervisor only.')]})}function v(){const{meId:e}=p(3e4),{role:n}=p(3e4),s=(0,i.useOwner)(e=>e.chat),a=(0,i.useOwner)(e=>e.staff),o=(0,i.useOwner)(t=>t.chatMuted[e]??y),l=(0,t.useMemo)(()=>S(a,e,n),[a,e,n]);return(0,t.useMemo)(()=>{const t={};return s.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,m.inChannel)(n.ch,l)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!o.includes(e)).reduce((e,[,t])=>e+t,0)}},[s,e,o,l])}function S(e,t,n){const s=e.find(e=>e.id===t);return s||!t?s:{id:t,name:'You',role:n,job:'',active:!0,level:'owner'===n?'Owner':'manager'===n?'Manager':'Staff',dept:''}}class k extends t.Component{state={err:null};static getDerivedStateFromError(e){return{err:String(e?.message??e)}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.err&&this.setState({err:null})}render(){return this.state.err?(0,x.jsxs)(a.default,{style:{gap:10},testID:"chat-error",children:[(0,x.jsx)(o.Banner,{kind:"warn",title:"Chat couldn\u2019t open",children:"Something went wrong showing this chat. Your messages are still saved on this phone. Go back and try again; if it keeps happening, close and reopen the app."}),(0,x.jsx)(o.Button,{kind:"secondary",label:"\u2039 Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const R={owner:c.colours.gold,manager:c.colours.blue,staff:'#7a6f5c'};function O({s:e,size:t=34}){return e?(0,x.jsx)(u.StaffAvatar,{id:e.id,size:t}):(0,x.jsx)(a.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:'#333',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(o.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const T=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#26403A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],M=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude02','\u2705','\ud83d\udd25'];function P({ch:e,go:u,back:b}){const{now:y,meId:C,role:v,today:S}=p(1e4),k=(0,i.useOwner)(e=>e.staff),P=(0,i.useOwner)(e=>e.chat),I=(0,i.useOwner)(e=>e.shifts),B=P.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[z,A]=(k.find(e=>e.id===C),(0,t.useState)('')),[D,$]=(0,t.useState)(null),[E,L]=(0,t.useState)(!1),[H,N]=(0,t.useState)(!1),W=e.startsWith('dm:')?e.split(':').slice(1).length:k.filter(t=>t.active&&(0,m.inChannel)(e,t)).length;(0,t.useEffect)(()=>{i.useOwner.getState().chatSeen(e,C)},[e,C,B.length]);const K=t=>i.useOwner.getState().chatSend({ch:e,from:C,at:y.toISOString(),...t}),_=B.filter(e=>e.pinned&&!e.removed),Y=e.startsWith('dm:')?w(k.find(t=>t.id===e.split(':').slice(1).find(e=>e!==C))?.name):j.find(t=>t.id===e)?.name,F=(0,f.useChatSync)(e=>e.synced),U=I.filter(e=>e.staffId===C&&e.published&&e.date>=S).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,x.jsxs)(a.default,{style:{gap:8},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Back to chats",onPress:b,hitSlop:10,children:(0,x.jsx)(o.T,{colour:c.colours.gold,children:"\u2039 Chats"})}),(0,x.jsx)(o.T,{weight:"semibold",children:Y}),(0,x.jsxs)(o.Muted,{children:[W," members"]})]}),_.map(e=>(0,x.jsxs)(o.Card,{highlight:c.colours.gold,children:[(0,x.jsxs)(o.T,{size:12,colour:c.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${w(k.find(t=>t.id===e.from)?.name)}`]}),(0,x.jsx)(o.T,{size:14,children:e.text})]},e.id)),B.map((t,s)=>{const h=k.find(e=>e.id===t.from),m=t.from===C,f=t.seenBy.filter(e=>e!==t.from).length,b=0===s||t.at.slice(0,10)!==B[s-1].at.slice(0,10);return'system'===t.from?(0,x.jsxs)(a.default,{style:{alignItems:'center',gap:2},children:[b?(0,x.jsx)(o.Muted,{children:(0,l.niceDate)(new Date(t.at))}):null,(0,x.jsx)(a.default,{style:{backgroundColor:'#1c1a14',borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:c.colours.border},children:(0,x.jsxs)(o.T,{size:13,colour:/Allergy|86/.test(t.text??'')?c.colours.amber:c.colours.muted,children:["\u2699\ufe0e Cover Charge \xb7 ",t.text," \xb7 ",(0,l.hm)(new Date(t.at))]})})]},t.id):(0,x.jsxs)(a.default,{style:{gap:2},children:[b?(0,x.jsx)(o.Muted,{center:!0,children:(0,l.niceDate)(new Date(t.at))}):null,(0,x.jsxs)(o.Row,{style:{alignItems:'flex-start',flexDirection:m?'row-reverse':'row'},children:[(0,x.jsx)(O,{s:h}),(0,x.jsxs)(n.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${h?.name}`,onPress:()=>$(D===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:m?'#3a2f12':c.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?c.colours.gold:c.colours.border,gap:3},children:[(0,x.jsxs)(o.Row,{gap:6,children:[(0,x.jsx)(o.T,{size:12,weight:"semibold",colour:h?R[h.role]:c.colours.muted,children:w(h?.name)}),(0,x.jsxs)(o.T,{size:11,colour:c.colours.muted,children:[h?i.ROLE_LABEL[h.role]:''," \xb7 ",(0,l.hm)(new Date(t.at))]})]}),t.removed?(0,x.jsx)(o.T,{size:14,colour:c.colours.muted,children:"Message removed by the owner"}):(0,x.jsxs)(x.Fragment,{children:[t.photo?(0,x.jsx)(a.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,x.jsxs)(o.T,{size:12,children:["\ud83d\udcf7 ",t.photo.caption," (example image)"]})}):null,t.text?(0,x.jsx)(o.T,{size:15,children:t.text}):null,'cover'===t.action?(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>u('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,x.jsx)(o.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,x.jsx)(a.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(C)?'#4a3c16':'#222'},children:(0,x.jsxs)(o.T,{size:12,children:[e," ",t.length]})},e))}):null,m?(0,x.jsx)(o.T,{size:11,colour:c.colours.muted,children:f?`Seen by ${f}`:'Sent'}):null]})]}),D!==t.id||t.removed?null:(0,x.jsxs)(o.Row,{wrap:!0,gap:6,style:{justifyContent:m?'flex-end':'flex-start',paddingLeft:m?0:40},children:[M.map(e=>(0,x.jsx)(n.default,{accessibilityLabel:`React ${e}`,onPress:()=>{i.useOwner.getState().chatReact(t.id,e,C),$(null)},style:{padding:4},children:(0,x.jsx)(o.T,{size:20,children:e})},e)),'staff'===v||e.startsWith('dm:')?null:(0,x.jsx)(o.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{i.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),$(null)}}),'owner'!==v||m?null:(0,x.jsx)(o.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{i.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),$(null)}})]})]},t.id)}),(0,x.jsxs)(o.Row,{gap:6,children:[(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>L(!0),style:{padding:8},children:(0,x.jsx)(o.T,{size:20,children:"\ud83d\udcf7"})}),(0,x.jsx)(s.default,{accessibilityLabel:"Message",placeholder:`Message ${Y}`,placeholderTextColor:"#7D776C",value:z,onChangeText:A,style:[o.styles.input,{flex:1}]}),(0,x.jsx)(o.Button,{small:!0,label:"Send",disabled:!z.trim(),onPress:()=>{K({text:z.trim()}),A('')}})]}),(0,x.jsx)(o.Row,{wrap:!0,gap:6,children:(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>N(!0)})}),F?null:(0,x.jsx)(o.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,x.jsx)(o.Sheet,{visible:E,onClose:()=>L(!1),title:"Send a photo (example images)",children:(0,x.jsx)(o.Row,{wrap:!0,gap:8,children:T.map(e=>(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{K({photo:e}),L(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,x.jsx)(o.T,{size:12,children:e.caption})},e.caption))})}),(0,x.jsxs)(o.Sheet,{visible:H,onClose:()=>N(!1),title:"Ask for shift cover",children:[U.length?null:(0,x.jsx)(o.Muted,{children:"You have no shifts on the rota this week."}),U.map(e=>(0,x.jsx)(o.Button,{kind:"secondary",label:`${h.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,h.fmtH)(e.start)}\u2013${(0,h.fmtH)(e.end)}`,onPress:()=>{const t=`${h.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,h.fmtH)(e.start)}\u2013${(0,h.fmtH)(e.end)}`;i.useOwner.getState().addSwap({shiftId:e.id,fromId:C,kind:'cover',note:`Cover asked in chat for ${t}`}),K({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),N(!1)}},e.id)),(0,x.jsx)(o.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function I({go:e}){const{now:s,meId:h,role:u}=p(3e4),b=(0,i.useOwner)(e=>e.staff),R=(0,i.useOwner)(e=>e.chat),T=(0,i.useOwner)(e=>e.chatMuted[h]??y),{by:M}=v(),I=(0,f.useChatSync)(e=>e.synced),B=(0,f.useChatSync)(e=>e.error),z=(0,m.useKitchenExtra)(e=>e.extra),[A,D]=(0,t.useState)(null),[$,E]=(0,t.useState)(!1),[L,H]=(0,t.useState)(!1);(0,t.useEffect)(()=>{C(s)},[]),(0,t.useEffect)(()=>{D(null)},[h]);const N=S(b,h,u);if(A)return(0,x.jsx)(k,{resetKey:A,onBack:()=>D(null),children:(0,x.jsx)(P,{ch:A,go:e,back:()=>D(null)})});const W=e=>R.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],K=b.filter(e=>e.active&&e.id!==h).map(e=>{const t=(0,m.dmId)(h,e.id);return{x:e,id:t,u:M[t]??0,l:W(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||w(e.x.name).localeCompare(w(t.x.name))),_='owner'===u||'manager'===u,Y=({id:e,name:t,icon:s,avatar:i})=>{const h=W(e),u=M[e]??0,m=T.includes(e);return(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>D(e),style:{padding:12,borderTopWidth:1,borderColor:c.colours.border},children:(0,x.jsxs)(o.Row,{children:[i?(0,x.jsx)(O,{s:i}):(0,x.jsx)(a.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:'#222',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(o.T,{size:16,children:s})}),(0,x.jsxs)(a.default,{style:{flex:1},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(o.T,{weight:u?'bold':'medium',children:[t,m?' \ud83d\udd15':'']}),h?(0,x.jsx)(o.Muted,{children:(0,l.hm)(new Date(h.at))}):null]}),(0,x.jsx)(o.Muted,{numberOfLines:1,children:h?h.removed?'Message removed':`${'system'===h.from?'Cover Charge':w(b.find(e=>e.id===h.from)?.name)}: ${h.text??'\ud83d\udcf7 Photo'}`:'No messages yet'})]}),u?(0,x.jsx)(a.default,{style:{backgroundColor:m?'#555':c.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,x.jsx)(o.T,{size:11,weight:"bold",children:u})}):null]})})};return(0,x.jsxs)(a.default,{style:{gap:10},children:[I?(0,x.jsx)(a.default,{testID:"chat-synced",children:(0,x.jsx)(o.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,x.jsx)(o.Banner,{kind:"warn",title:"On this device only for now",children:"You\u2019re not connected with your personal link (or chat sharing isn\u2019t switched on yet), so anything you send stays on this device and nobody else will see it. Open your personal invite link to share chat with the team. Use your usual group chat for anything urgent."}),I&&B?(0,x.jsx)(a.default,{testID:"chat-sync-error",children:(0,x.jsx)(o.Banner,{kind:"warn",title:"Can\u2019t reach the server right now",children:"Showing the messages on this phone. New messages will be sent and others\u2019 messages will appear when the connection is back; it retries automatically."})}):null,(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(o.Muted,{children:["Signed in as ",w(N?.name)," (",'Head Chef'===N?.level?'Head Chef':i.ROLE_LABEL[u],")"]}),(0,x.jsx)(o.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>H(!0)})]}),(0,x.jsxs)(a.default,{style:{borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface,overflow:'hidden'},children:[(0,x.jsx)(o.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{padding:10},children:"TEAM CHATS"}),j.filter(e=>'all'===e.id||(0,m.inChannel)(e.id,N)).map(e=>(0,x.jsx)(Y,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,x.jsxs)(a.default,{style:{borderRadius:14,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface,overflow:'hidden'},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,x.jsx)(o.T,{size:12,weight:"semibold",colour:c.colours.gold,children:"PRIVATE MESSAGES"}),(0,x.jsx)(o.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>E(!0)})]}),K.map(e=>(0,x.jsx)(Y,{id:e.id,name:w(e.x.name),avatar:e.x},e.id)),K.length?null:(0,x.jsx)(o.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,x.jsx)(o.Muted,{children:"Private messages can only be read by the two people in them; owners and managers can\u2019t read other people\u2019s private messages. The Kitchen chat is for owners, managers, head chefs and kitchen staff, and can\u2019t be left."}),(0,x.jsx)(o.Sheet,{visible:$,onClose:()=>E(!1),title:"New private message",children:b.filter(e=>e.active&&e.id!==h).map(e=>(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{E(!1),D((0,m.dmId)(h,e.id))},style:{paddingVertical:8},children:(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(O,{s:e}),(0,x.jsxs)(a.default,{children:[(0,x.jsx)(o.T,{children:w(e.name)}),(0,x.jsxs)(o.Muted,{children:[i.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,x.jsxs)(o.Sheet,{visible:L,onClose:()=>H(!1),title:"Chat settings",children:[(0,x.jsx)(o.Banner,{kind:"info",title:"Privacy",children:"Chat is for work. Managers and the owner see messages in the channels they belong to and the owner can remove messages in group chats. Private messages can only be read by the two people in them: the server enforces this, so nobody else (not even the owner) can read them. Don\u2019t share customer card or health details beyond what\u2019s needed for service."}),(0,x.jsx)(o.T,{weight:"semibold",children:"Mute channels"}),j.filter(e=>(0,m.inChannel)(e.id,N)).map(e=>(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(o.T,{children:[e.icon," ",e.name]}),(0,x.jsx)(o.Toggle,{label:`Mute ${e.name}`,value:T.includes(e.id),onChange:()=>i.useOwner.getState().chatMute(h,e.id)})]},e.id)),(0,x.jsx)(o.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),_?(0,x.jsxs)(a.default,{style:{gap:6},testID:"kitchen-members",children:[(0,x.jsx)(o.T,{weight:"semibold",children:"Kitchen chat members"}),(0,x.jsxs)(o.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",I?'':'; saved on this device for now',"."]}),b.filter(e=>e.active).map(e=>{const t=z[e.id]??(0,m.kitchenByRule)(e);return(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(o.T,{children:[w(e.name),null!=z[e.id]?' (changed)':'']}),(0,x.jsx)(o.Toggle,{label:`Kitchen chat: ${w(e.name)}`,value:t,onChange:t=>m.useKitchenExtra.getState().set(e.id,t===(0,m.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},910,[12,245,255,109,791,813,796,799,884,898,981,1092,6]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return S}}),_e.signInWithText=y,_e.SignInWithLink=function(){const[e,n]=(0,t.useState)(''),[o,r]=(0,t.useState)('');return(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(f.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"https://\u2026?invite=\u2026",autoCapitalize:"none",autoCorrect:!1}),(0,h.jsx)(f.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await y(e);r('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':''),'ok'===t&&n('')}}),o?(0,h.jsx)(f.T,{size:13,colour:u.colours.red,children:o}):null]})},_e.InviteGate=function(){const[e,y]=(0,t.useState)(l.useSession.persist.hasHydrated()),[b,k]=(0,t.useState)(l.START_INVITE?'checking':'done'),w=(0,l.useSession)(e=>e.meId),v=(0,l.useSession)(e=>!w||!!e.welcomed[w]);if((0,t.useEffect)(()=>{const e=l.useSession.persist.onFinishHydration(()=>y(!0));return l.useSession.persist.hasHydrated()&&y(!0),e},[]),(0,t.useEffect)(()=>{if(!e||!I.includes(o.APP_VARIANT))return;let t=!0;return(async()=>{if(l.START_INVITE){const e=await(0,l.personForInvite)(l.START_INVITE);if(!t)return;if(!e)return void k('bad');T(e),(0,p.claimInviteForSync)(l.START_INVITE)}const e=(0,l.rosterPerson)(l.useSession.getState().meId),n=e&&r.useOwner.getState().staff.some(t=>t.id===e.id&&t.active);if(e&&!n)l.useSession.getState().signOut();else if(e&&!S(e)){const t=(0,l.appUrl)(e.app,l.START_INVITE);if(t)return void window.location.replace(t)}k('done')})(),()=>{t=!1}},[e]),!I.includes(o.APP_VARIANT))return null;if(!e||'checking'===b)return(0,h.jsx)(s.default,{style:[n.default.absoluteFill,{backgroundColor:u.colours.bg,zIndex:1e3}]});if('bad'===b)return(0,h.jsxs)(s.default,{testID:"invite-bad",style:[n.default.absoluteFill,{backgroundColor:u.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,h.jsx)(f.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,h.jsx)(f.Muted,{center:!0,children:"Part of the link may be missing. Go back to the message from your manager and tap the whole link, rather than copying part of it. If it still doesn't work, ask your manager for your personal Cover Charge link."}),(0,h.jsx)(f.Button,{label:"Look around the example app instead",kind:"secondary",onPress:()=>k('done')}),(0,h.jsx)(f.Muted,{center:!0,children:"The example app uses made-up data, and nothing you do there is shared with the team."})]});const x=(0,l.rosterPerson)(w);return x&&!v&&S(x)?(0,h.jsx)(c.LaunchWelcome,{p:x,onDone:()=>l.useSession.getState().markWelcomed(x.id)}):null};var t=_r(d[0]);_r(d[1]);var n=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),f=_r(d[9]),p=_r(d[10]),h=_r(d[11]);const I=['owner','staff','chef'],S=e=>'staff'===o.APP_VARIANT||e.app===o.APP_VARIANT;function T(e){l.useSession.getState().signIn(e.id);const t=r.useOwner.getState();r.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?t.previewRole:e.role})}async function y(e){const t=(0,l.inviteFromText)(e),n=t?await(0,l.personForInvite)(t):void 0;if(!n)return'bad';if(T(n),(0,p.claimInviteForSync)(t),!S(n)){const e=(0,l.appUrl)(n.app);if(e)return window.location.replace(e),'moved'}return'ok'}},911,[12,104,28,109,787,813,816,799,1149,791,798,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:t=22,colour:x}){const n={stroke:x,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(e.default,{width:t,height:t,viewBox:"0 0 24 24",children:['home'===l?(0,h.jsx)(s.Path,{d:"M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z",...n}):null,'orders'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,h.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'bookings'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:x}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:x}),(0,h.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:x})]}):null,'search'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,h.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,h.jsx)(s.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0",...n}):null,'chat'===l?(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,h.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,h.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,h.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M7 15a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 7.5a3.75 3.75 0 0 1 .5 7.5z",...n}),(0,h.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,h.jsx)(s.Path,{d:"M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4",...n})]}):null,'payroll'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,h.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,h.jsx)(s.Path,{d:"M14.5 9a2.5 2.5 0 0 0-5 0c0 2.5 0 4-1.5 6h7M9 12.5h4",...n})]}):null,'sparkle'===l?(0,h.jsx)(s.Path,{d:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM19 16l.7 1.8 1.8.7-1.8.7L19 21l-.7-1.8-1.8-.7 1.8-.7z",...n}):null,'platter'===l?(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,h.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,h.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,h.jsx)(s.Path,{d:"M11 7.5v6h5l2.5 5M11 10h5M8 11.5a5.5 5.5 0 1 0 7.5 6.5",...n})]}):null,'dog'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M5 10l1-5 3 3h4l3-3 1 5v4a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5z",...n}),(0,h.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,h.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,h.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'swap'===l?(0,h.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null]})},r(d[0]);var l,s=r(d[1]),e=(l=s)&&l.__esModule?l:{default:l},h=r(d[2])},912,[12,852,6]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.usePay=j,_e.periodPay=T,_e.MyHoursPay=P,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),l='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),z=(0,s.useMemo)(()=>j.filter(e=>e.active),[j]),k=(0,y.useHourly)(),D=(0,a.useOwner)(e=>e.attendance),M=(0,a.useOwner)(e=>e.troncHistory),{now:R,rid:N}=(0,y.useCtx)(6e4),v=(0,b.useVenuePay)(N).pay,[B,O]=(0,s.useState)(-1),[L,$]=(0,s.useState)(null),[S,H]=(0,s.useState)(''),[I,E]=(0,s.useState)(null),W=(0,s.useMemo)(()=>z.map(e=>({...T(e.id,B,R,D,k[e.id]??0,v,M),person:e})),[z,B,D,k,v,M]),_=W.reduce((e,s)=>({paid:e.paid+s.paid,gross:e.gross+s.gross,tips:e.tips+s.tips,total:e.total+s.total}),{paid:0,gross:0,tips:0,total:0}),V=W[0]?.label??'',F=z.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(n.Muted,{children:"Periods follow your venue's pay dates (Settings \u203a Pay & tips). For hours to copy into a spreadsheet, use Payroll hours."}),(0,f.jsxs)(n.Muted,{children:["Pay period (venue setting",l?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(C,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(o.default,{horizontal:!0,children:(0,f.jsxs)(r.default,{children:[(0,f.jsx)(n.Row,{gap:0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'].map((e,s)=>(0,f.jsx)(n.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),W.map(e=>(0,f.jsxs)(n.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>E(e.person.id),style:{width:120},children:[(0,f.jsx)(n.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(n.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==k[e.person.id]?'':(k[e.person.id]/100).toFixed(2))},style:{width:96},children:(0,f.jsxs)(n.T,{size:13,colour:null==k[e.person.id]?h.colours.muted:'owner'!==e.person.role&&k[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(n.Muted,{children:F?`${F.level??a.ROLE_LABEL[F.role]} \xb7 ${F.job}${F.noTax?' \xb7 No tax deducted':''} \xb7 now: ${(0,a.wageLabel)(F,k[F.id],u.gbp)}`:''}),(0,f.jsx)(i.default,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:n.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=k[L]?(0,f.jsx)(n.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(n.Sheet,{visible:!!I,onClose:()=>E(null),title:`What ${x(z.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(P,{staffId:I}):null})]})};var s=_r(d[0]),t=e(_r(d[1])),o=e(_r(d[2])),i=e(_r(d[3])),r=e(_r(d[4])),l=e(_r(d[5])),n=_r(d[6]),a=_r(d[7]),u=_r(d[8]),c=_r(d[9]),h=_r(d[10]),p=_r(d[11]),y=_r(d[12]),b=_r(d[13]),f=_r(d[14]);const x=e=>(e??'').replace(' (example)',''),w='Before tax and deductions, estimate';function j(e,t){const{now:o,rid:i}=(0,y.useCtx)(6e4),r=(0,a.useOwner)(e=>e.attendance),l=(0,y.useHourly)()[e]??0,n=(0,b.useVenuePay)(i).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,s.useMemo)(()=>T(e,t,o,r,l,n,u),[e,t,r,l,n,u,Math.floor(o.getTime()/6e4)])}function T(e,s,t,o,i,r,l){const{s:n,e:u,key:h}=(0,b.venueRange)(r,'wage',s,t),p=(0,c.ymd)(n),f=(0,c.ymd)(u),x=o.filter(s=>s.staffId===e&&s.date>=p&&s.date<=f&&s.in).sort((e,s)=>e.date.localeCompare(s.date)).map(e=>{const s=(0,y.paidMins)(e,t);return{a:e,...s,gross:Math.round(s.paid/60*i),open:!e.out,confirmed:(0,a.isConfirmed)(e)}}),w=x.filter(e=>e.confirmed),j=w.reduce((e,s)=>e+s.paid,0),T=w.reduce((e,s)=>e+s.gross,0),C=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),P=l.filter(e=>e.end>=p&&e.end<=f).map(s=>({label:s.label,amount:s.rows.find(s=>s.staffId===e)?.amount??0})).filter(e=>e.amount>0),z=P.reduce((e,s)=>e+s.amount,0);return{s:n,e:u,key:h,label:`${(0,c.niceDate)(n)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:C,gross:T,tips:z,tipItems:P,total:T+z,rate:i}}function C({label:e,offset:s,setOffset:t,badge:o}){return(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(r.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(n.T,{weight:"semibold",children:e}),o?(0,f.jsx)(n.Badge,{kind:0===s?'amber':'neutral',label:o}):null]}),(0,f.jsx)(n.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function P({staffId:e}){const{meId:i,now:P,rid:z}=(0,y.useCtx)(6e4),k=e??i,D=(0,b.useVenuePay)(z).pay,M=(0,a.useOwner)(e=>e.staff).find(e=>e.id===k),R=(0,a.useOwner)(e=>e.attendance),N=(0,a.useOwner)(e=>e.troncHistory),v=(0,y.useHourly)(),B=v[k]??0,O=null!=v[k],[L,$]=(0,s.useState)(0),S=j(k,L),H=(0,l.default)().width<520,I=(0,s.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(k,e,P,R,B,D,N)})),[k,R,B,D,N]);return(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(n.Banner,{kind:"info",title:w,children:"Gross pay from your clocked hours at your hourly rate, plus tips shared to you. Tax, National Insurance and pension come off in payroll."}),(0,f.jsxs)(n.Muted,{children:[x(M?.name)," \xb7 ",M?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",D.wagePayDay,[1,21,31].includes(D.wagePayDay)?'st':[2,22].includes(D.wagePayDay)?'nd':[3,23].includes(D.wagePayDay)?'rd':'th',", cut-off the ",D.wageCutoffDay,[1,21].includes(D.wageCutoffDay)?'st':[2,22].includes(D.wageCutoffDay)?'nd':[3,23].includes(D.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(C,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(n.Card,{children:[(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{children:"Confirmed paid hours"}),(0,f.jsx)(n.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(n.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{children:"Gross pay from hours"}),(0,f.jsx)(n.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{children:"Tips allocated"}),(0,f.jsx)(n.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(n.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(r.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(n.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(n.Muted,{children:[w,". Tips are shown separately and only once a tip period is approved."]})]}),(0,f.jsx)(p.SectionHead,{title:"Shifts",sub:"Paid hours = clock out \u2212 clock in \u2212 break"}),H?(0,f.jsxs)(r.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(r.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(n.T,{size:14,weight:"semibold",colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'On now':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]}),(0,f.jsxs)(n.Muted,{children:[(0,c.hm)(new Date(e.a.in)),"\u2013",e.a.out?(0,c.hm)(new Date(e.a.out)):'now',e.open?'':` \xb7 ${e.brk}m break \xb7 ${(0,y.hmDur)(e.paid)} paid`]})]},e.a.id)),S.shifts.length?null:(0,f.jsx)(n.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(n.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(o.default,{horizontal:!0,children:(0,f.jsxs)(r.default,{children:[(0,f.jsx)(n.Row,{gap:0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(n.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,64][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(n.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(n.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(n.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(n.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(n.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(n.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(n.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(n.T,{size:13,weight:"semibold",style:{width:64},colour:e.open||e.confirmed?void 0:h.colours.amber,children:e.open?'\u2013':e.confirmed?(0,u.gbp)(e.gross):'Pending'})]},e.a.id)),S.shifts.length?null:(0,f.jsx)(n.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(n.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(n.Muted,{children:"Hours marked Pending count once a manager signs them off."}):null,(0,f.jsx)(p.SectionHead,{title:"History"}),I.map(e=>(0,f.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(n.Card,{children:[(0,f.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(n.T,{weight:"semibold",children:e.label}),(0,f.jsx)(n.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(n.Muted,{children:[(0,y.hmDur)(e.paid)," paid \xb7 ",(0,u.gbp)(e.gross)," from hours",e.tips?` + ${(0,u.gbp)(e.tips)} tips`:''," \xb7 ",w.toLowerCase()]})]})},e.o))]})}},913,[12,245,133,255,109,269,791,813,794,796,799,921,884,1127,6]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"payFor",{enumerable:!0,get:function(){return b.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return b.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:t,today:o}=(0,x.useCtx)(6e4),{pay:n,source:r}=(0,b.useVenuePay)(t),[l,c]=(0,s.useState)(n),[p,y]=(0,s.useState)((0,u.ukDate)(n.tipsAnchorPayday)),[C,S]=(0,s.useState)(null),M=(0,u.parseUk)(p),D=(0,u.cleanPay)({...l,tipsAnchorPayday:M??l.tipsAnchorPayday}),B=JSON.stringify(D)!==JSON.stringify(n)||'settings'!==r,z=(0,u.nextToPay)(D,'tips',o).period,R=(0,u.nextToPay)(D,'wage',o).period,v=(0,u.tipsPeriod)(D,z.start,1),$=(0,u.wagePeriod)(D,R.start,1),O=e=>{c({...l,...e}),S(null)};return(0,j.jsxs)(d.default,{style:{gap:12},testID:"pay-settings",children:['none'===r?(0,j.jsx)(i.Banner,{kind:"warn",title:"Pay dates not set up yet",children:"Set your tips and wage dates here. Until then the app uses calendar months and weekly tips."}):null,'questionnaire'===r?(0,j.jsx)(i.Banner,{kind:"info",title:"From your sign-up answers",children:"These dates came from your questionnaire. Check them and tap Save to make them your venue's pay dates."}):null,(0,j.jsx)(f.SectionHead,{title:"Tips (tronc)",sub:"How often tips are paid out, and which days each payout covers."}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"How often"}),(0,j.jsx)(i.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,j.jsx)(i.Chip,{label:w[e],selected:l.tipsFrequency===e,onPress:()=>O({tipsFrequency:e})},e))}),(0,j.jsx)(i.Field,{label:"A tips payday (DD/MM/YYYY). Every other one is worked out from it",value:p,onChangeText:e=>{y(e),S(null)},placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),M?(0,j.jsxs)(i.Muted,{children:[(0,u.dayMonth)(M)," ",M.slice(0,4)]}):(0,j.jsx)(i.T,{size:13,colour:h.colours.red,children:"Enter a date like 02/11/2026"}),(0,j.jsx)(i.T,{weight:"semibold",children:"Each tips period ends"}),(0,j.jsxs)(i.Row,{children:[(0,j.jsx)(i.Stepper,{label:"days before payday",value:l.tipsEndsDaysBefore,min:0,max:13,onChange:e=>O({tipsEndsDaysBefore:e})}),(0,j.jsx)(i.Muted,{style:{flex:1},children:0===l.tipsEndsDaysBefore?'on payday':1===l.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,j.jsx)(f.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,j.jsx)(i.Stepper,{label:"pay day",value:l.wagePayDay,min:1,max:31,onChange:e=>O({wagePayDay:e})})]}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,j.jsx)(i.Stepper,{label:"cut-off day",value:l.wageCutoffDay,min:1,max:28,onChange:e=>O({wageCutoffDay:e})})]}),(0,j.jsxs)(i.Muted,{children:["Period runs the ",P(l.wageCutoffDay)," to the ",P(1===l.wageCutoffDay?31:l.wageCutoffDay-1),1===l.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,j.jsx)(i.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,j.jsx)(i.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,j.jsx)(i.Chip,{label:T[e],selected:(l.weekendRule??'none')===e,onPress:()=>O({weekendRule:e})},e))})]}),(0,j.jsx)(f.SectionHead,{title:"Preview"}),(0,j.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,j.jsx)(k,{label:"Next tips payday",day:z.payday,period:z}),(0,j.jsx)(k,{label:"Then",day:v.payday,period:v}),(0,j.jsx)(d.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,j.jsx)(k,{label:"Next payday",day:R.payday,period:R}),(0,j.jsx)(k,{label:"Then",day:$.payday,period:$})]}),(0,j.jsx)(i.Button,{kind:"success",label:'settings'===r?'Save pay dates':'Save as our pay dates',disabled:!M||!B,testID:"save-pay",onPress:()=>{a.useStore.getState().updateSettings(t,{pay:D}),S('Saved. Everyone in the venue sees these dates.')}}),C?(0,j.jsx)(i.Banner,{kind:"success",title:C}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=S,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return $}}),_e.summaryTable=O,_e.detailTable=H,_e.copyText=I,_e.periodOptions=W,_e.PayrollHours=function({go:e}){const{rid:t,today:r,now:a,r:y}=(0,x.useCtx)(6e4),{pay:f,source:w}=(0,b.useVenuePay)(t),T=(0,l.useOwner)(e=>e.staff),P=(0,l.useOwner)(e=>e.attendance),k=(0,x.useHourly)(),C=(0,s.useMemo)(()=>W(f,r),[f,r]),[B,z]=(0,s.useState)('wage'),[R,N]=(0,s.useState)(null),[V,A]=(0,s.useState)(!1),[E,Y]=(0,s.useState)({}),[U,G]=(0,s.useState)(null),_='custom'===B&&R?R:(C.find(e=>e.id===B)??C[0]).period,q=(0,s.useMemo)(()=>S(_,T,P,a,k),[_.key,T,P,k,Math.floor(a.getTime()/6e4)]),J=q.some(e=>null!=e.rate),K='tips'===_.kind,Q=q.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0}),X=q.filter(e=>e.pending>0).length,Z=`${y.name}: hours ${(0,u.rangeText)(_.start,_.end)}`,ee=`hours-${_.start}-to-${_.end}`,se=e=>{G(e),setTimeout(()=>G(null),6e3)};return(0,j.jsxs)(d.default,{style:{gap:10},testID:"payroll-hours",children:['none'===w?(0,j.jsxs)(i.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,j.jsx)(i.Muted,{children:"Using calendar months for now."}),(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[C.map(e=>(0,j.jsx)(i.Chip,{label:e.label,sub:e.sub,selected:B===e.id,onPress:()=>{z(e.id),A(!1)}},e.id)),(0,j.jsx)(i.Chip,{label:"Custom dates",sub:R&&'custom'===B?(0,u.rangeText)(R.start,R.end):'Pick any range',selected:'custom'===B,onPress:()=>A(!V)})]}),V?(0,j.jsx)(L,{onSet:e=>{N(e),z('custom'),A(!1)}}):null,(0,j.jsx)(i.Card,{highlight:h.colours.gold,children:(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsxs)(d.default,{children:[(0,j.jsxs)(i.T,{weight:"bold",size:18,children:[(0,u.rangeText)(_.start,_.end)," ",_.end.slice(0,4)]}),(0,j.jsxs)(i.Muted,{children:[(0,u.ukDate)(_.start)," to ",(0,u.ukDate)(_.end),_.payday?` \xb7 ${_.payday>=r?'pays':'paid'} ${(0,u.dayMonth)(_.payday)}`:'',K?' \xb7 tips period':'wage'===_.kind?' \xb7 wage period':'']})]}),(0,j.jsxs)(d.default,{style:{alignItems:'flex-end'},children:[(0,j.jsxs)(i.T,{size:22,weight:"bold",colour:h.colours.gold,children:[(0,u.decH)(Q.c)," h"]}),(0,j.jsxs)(i.Muted,{children:["confirmed (",(0,u.hMm)(Q.c),")"]})]})]})}),X?(0,j.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,j.jsxs)(d.default,{style:{backgroundColor:h.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:h.colours.amber,gap:4},children:[(0,j.jsxs)(i.T,{weight:"bold",colour:h.colours.amber,children:["\u26a0 ",(0,u.decH)(Q.p)," h still waiting for sign-off (",X," ",1===X?'person':'people',")"]}),(0,j.jsx)(i.T,{size:14,children:"Pending hours are not in the totals or the exports' confirmed columns. Sign them off first so everyone is paid in full."}),(0,j.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"Sign off hours \u203a"})]})}):(0,j.jsx)(i.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(i.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await I(v(O(q,_,J,K)));se(e?`Copied ${q.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,p.downloadText)(`${ee}.csv`,$(O(q,_,J,K))),se('CSV downloaded (summary).')}}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,p.downloadText)(`${ee}-daily.csv`,$(H(q))),se('CSV downloaded (one line per shift).')}}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=O(q,_,J,K);(0,p.printTable)(Z,`${(0,u.ukDate)(_.start)} to ${(0,u.ukDate)(_.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,u.ukDate)(r)}`,e[0],e.slice(1))}})]}),U?(0,j.jsx)(i.Banner,{kind:"success",title:U}):null,(0,j.jsx)(n.default,{horizontal:!0,children:(0,j.jsxs)(d.default,{testID:"hours-table",children:[(0,j.jsx)(i.Row,{gap:0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Name','Shifts','Confirmed','Pending',K?'Tips h':'h:mm',J?'Rate':'',J?'Gross':''].map((e,s)=>(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:F[s]},children:e},s))}),q.map(e=>{const s=!!E[e.person.id];return(0,j.jsxs)(d.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,j.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`${D(e.person)} daily hours`,onPress:()=>Y({...E,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,j.jsxs)(i.Row,{gap:0,children:[(0,j.jsxs)(d.default,{style:{width:F[0]},children:[(0,j.jsxs)(i.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",D(e.person)]}),(0,j.jsx)(i.Muted,{numberOfLines:1,children:M(e.person)})]}),(0,j.jsx)(i.T,{size:14,style:{width:F[1]},children:e.shifts}),(0,j.jsx)(i.T,{size:14,weight:"semibold",style:{width:F[2]},children:(0,u.decH)(e.confirmed)}),(0,j.jsx)(i.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?h.colours.amber:h.colours.muted,style:{width:F[3]},children:e.pending?`\u26a0 ${(0,u.decH)(e.pending)}`:'0.00'}),(0,j.jsx)(i.T,{size:14,style:{width:F[4]},children:K?(0,u.decH)(e.confirmed):(0,u.hMm)(e.confirmed)}),(0,j.jsx)(i.T,{size:14,colour:h.colours.muted,style:{width:F[5]},children:J?null!=e.rate?(0,c.gbp)(e.rate):'\u2013':''}),(0,j.jsx)(i.T,{size:14,weight:"semibold",style:{width:F[6]},children:J?null!=e.gross?(0,c.gbp)(e.gross):'\u2013':''})]})}),s?(0,j.jsxs)(d.default,{style:{backgroundColor:h.colours.surface2,borderRadius:8,padding:8,marginBottom:8,gap:2},testID:`daily-${e.person.id}`,children:[(0,j.jsx)(i.Row,{gap:0,children:['Date','In','Out','Break','Paid','Status'].map((e,s)=>(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[96,52,52,52,56,90][s]},children:e},e))}),e.days.map(e=>(0,j.jsxs)(i.Row,{gap:0,children:[(0,j.jsx)(i.T,{size:13,style:{width:96},children:(0,u.dayMonth)(e.date)}),(0,j.jsx)(i.T,{size:13,style:{width:52},children:e.inT}),(0,j.jsx)(i.T,{size:13,style:{width:52},children:e.outT||'\u2013'}),(0,j.jsx)(i.T,{size:13,style:{width:52},children:'On now'===e.status?'\u2013':`${e.brk}m`}),(0,j.jsx)(i.T,{size:13,style:{width:56},children:'On now'===e.status?'\u2013':(0,u.hMm)(e.paid)}),(0,j.jsx)(i.T,{size:13,weight:"semibold",style:{width:90},colour:'Confirmed'===e.status?h.colours.green:'Pending'===e.status?h.colours.amber:h.colours.blue,children:e.status})]},e.a.id)),e.days.length?null:(0,j.jsx)(i.Muted,{children:"No clocked shifts in this period."})]}):null]},e.person.id)}),(0,j.jsxs)(i.Row,{gap:0,style:{paddingVertical:8,borderTopWidth:2,borderColor:h.colours.gold},children:[(0,j.jsxs)(i.T,{size:14,weight:"bold",style:{width:F[0]},children:["Total (",q.length,")"]}),(0,j.jsx)(i.T,{size:14,weight:"bold",style:{width:F[1]},children:Q.s}),(0,j.jsx)(i.T,{size:14,weight:"bold",colour:h.colours.gold,style:{width:F[2]},children:(0,u.decH)(Q.c)}),(0,j.jsx)(i.T,{size:14,weight:"bold",colour:Q.p?h.colours.amber:h.colours.muted,style:{width:F[3]},children:(0,u.decH)(Q.p)}),(0,j.jsx)(i.T,{size:14,weight:"bold",style:{width:F[4]},children:K?(0,u.decH)(Q.c):(0,u.hMm)(Q.c)}),(0,j.jsx)(i.T,{size:14,style:{width:F[5]},children:" "}),(0,j.jsx)(i.T,{size:14,weight:"bold",style:{width:F[6]},children:J?(0,c.gbp)(Q.g):''})]})]})}),(0,j.jsxs)(i.Muted,{children:["Tap a name for each day. Hours are decimal (37.50 = 37 hours 30 minutes); h:mm is also in the export. Paid hours = clock out \u2212 clock in \u2212 break. ",J?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),K?(0,j.jsx)(i.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]})},_e.TipsDay=function({go:e}){const{rid:t,today:a,now:f}=(0,x.useCtx)(6e4),{pay:w,source:T}=(0,b.useVenuePay)(t),P=(0,l.useOwner)(e=>e.staff),k=(0,l.useOwner)(e=>e.attendance),C=(0,l.useOwner)(e=>e.tronc),z=(0,u.nextToPay)(w,'tips',a),[R,O]=(0,s.useState)(0),H=(0,u.tipsPeriod)(w,z.period.start,R),[W,L]=(0,s.useState)(''),[F,N]=(0,s.useState)({}),[V,A]=(0,s.useState)(null),E=(0,s.useMemo)(()=>S(H,P,k,f,{}),[H.key,P,k]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>F[e.id]??Y(e),G=E.filter(e=>e.confirmed>0||e.pending>0),_=Math.round(100*Number(W.replace(/[\xa3,\s]/g,''))),q=Number.isFinite(_)&&_>0&&_<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(W),J=G.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:K}=(0,y.allocate)(q?_:0,J.map(e=>e.confirmed)),Q={};J.forEach((e,s)=>{Q[e.person.id]=K[s]});const X=J.reduce((e,s)=>e+s.confirmed,0),Z=Object.values(Q).reduce((e,s)=>e+s,0),ee=G.filter(e=>e.pending>0&&!U(e.person)),se=ee.reduce((e,s)=>e+s.pending,0),te=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],...G.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[D(e.person),M(e.person),(0,u.ukDate)(H.start),(0,u.ukDate)(H.end),H.payday?(0,u.ukDate)(H.payday):'',(0,u.decH)(e.confirmed),(0,u.hMm)(e.confirmed),s&&X?(e.confirmed/X*100).toFixed(2):'0.00',s?B(Q[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,u.ukDate)(H.start),(0,u.ukDate)(H.end),H.payday?(0,u.ukDate)(H.payday):'',(0,u.decH)(X),(0,u.hMm)(X),X?'100.00':'0.00',B(Z)]],oe=e=>{A(e),setTimeout(()=>A(null),6e3)};return(0,j.jsxs)(d.default,{style:{gap:10},testID:"tips-day",children:[(0,j.jsx)(i.Banner,{kind:"info",title:"Saving payouts and notifying staff are coming next",children:"For now this works out the split and exports it. Nothing is saved to the team, sent or paid."}),'none'===T?(0,j.jsxs)(i.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,j.jsx)(i.Muted,{children:"Using weekly tips for now."}),(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:R<=-6,onPress:()=>O(R-1)}),(0,j.jsxs)(d.default,{style:{alignItems:'center',flex:1},children:[(0,j.jsx)(i.T,{weight:"bold",size:18,children:(0,u.rangeText)(H.start,H.end)}),(0,j.jsxs)(i.Muted,{children:[(0,u.ukDate)(H.start)," to ",(0,u.ukDate)(H.end)," \xb7 ",H.payday>=a?'paid':'was paid'," ",(0,u.dayMonth)(H.payday)]}),0===R?(0,j.jsx)(i.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:R>=1,onPress:()=>O(R+1)})]}),(0,j.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Total tips to share"}),(0,j.jsxs)(i.Row,{style:{alignItems:'center'},children:[(0,j.jsx)(i.T,{size:28,weight:"bold",colour:h.colours.gold,children:"\xa3"}),(0,j.jsx)(r.default,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:W,onChangeText:L,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),W&&!q?(0,j.jsx)(i.T,{size:13,colour:h.colours.red,children:"Enter an amount like 1250.00"}):(0,j.jsx)(i.Muted,{children:"Shared by confirmed hours: share = total \xd7 (their hours \xf7 everyone's hours). Rounded to the penny; leftover pennies go to the largest shares so it adds up exactly."})]}),ee.length?(0,j.jsx)(o.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,j.jsxs)(d.default,{style:{backgroundColor:h.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:h.colours.red,gap:4},children:[(0,j.jsxs)(i.T,{weight:"bold",colour:h.colours.red,children:["\u26a0 Don't pay out yet: ",(0,u.decH)(se)," h not signed off"]}),(0,j.jsxs)(i.T,{size:14,children:[ee.map(e=>`${D(e.person)} (${(0,u.decH)(e.pending)} h)`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,j.jsx)(i.T,{weight:"semibold",colour:h.colours.gold,children:"Sign off hours \u203a"})]})}):G.length?(0,j.jsx)(i.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,j.jsx)(n.default,{horizontal:!0,children:(0,j.jsxs)(d.default,{testID:"tips-table",children:[(0,j.jsx)(i.Row,{gap:0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[64,150,80,64,84][s]},children:e},e))}),G.map(e=>{const s=U(e.person),t=Q[e.person.id]??0;return(0,j.jsxs)(i.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,j.jsx)(o.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${D(e.person)}`,onPress:()=>N({...F,[e.person.id]:!s}),style:{width:64},children:(0,j.jsx)(d.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?h.colours.muted:h.colours.green,backgroundColor:s?'transparent':h.colours.greenBg,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.T,{size:14,colour:h.colours.green,children:s?'':'\u2713'})})}),(0,j.jsxs)(d.default,{style:{width:150},children:[(0,j.jsx)(i.T,{size:14,weight:"semibold",numberOfLines:1,children:D(e.person)}),(0,j.jsxs)(i.Muted,{numberOfLines:1,children:[s?'Excluded':M(e.person),e.pending?` \xb7 \u26a0 ${(0,u.decH)(e.pending)} h pending`:'']})]}),(0,j.jsxs)(i.T,{size:14,style:{width:80},children:[(0,u.decH)(e.confirmed)," h"]}),(0,j.jsx)(i.T,{size:14,colour:h.colours.muted,style:{width:64},children:!s&&X?`${(e.confirmed/X*100).toFixed(1)}%`:'\u2013'}),(0,j.jsx)(i.T,{size:15,weight:"bold",colour:s?h.colours.muted:h.colours.gold,style:{width:84},children:s?'\u2013':(0,c.gbp)(t)})]},e.person.id)}),(0,j.jsxs)(i.Row,{gap:0,style:{paddingVertical:8,borderTopWidth:2,borderColor:h.colours.gold},children:[(0,j.jsx)(i.T,{size:14,style:{width:64},children:" "}),(0,j.jsxs)(i.T,{size:14,weight:"bold",style:{width:150},children:["Total (",J.length," people)"]}),(0,j.jsxs)(i.T,{size:14,weight:"bold",style:{width:80},children:[(0,u.decH)(X)," h"]}),(0,j.jsx)(i.T,{size:14,style:{width:64},children:X?'100%':'\u2013'}),(0,j.jsx)(i.T,{size:15,weight:"bold",colour:q&&Z===_?h.colours.green:h.colours.text,style:{width:84},children:(0,c.gbp)(Z)})]})]})}),G.length?null:(0,j.jsx)(i.Muted,{children:"No clocked hours in this fortnight yet."}),q&&X?(0,j.jsxs)(i.Muted,{children:["Check: ",J.length," shares add up to ",(0,c.gbp)(Z)," of ",(0,c.gbp)(_)," ",Z===_?'\u2713':'',". \xa3",(_/100/(X/60)).toFixed(4)," per confirmed hour."]}):null,(0,j.jsxs)(i.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips (tronc)). Tick or untick anyone for this split."]}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(i.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!q,onPress:async()=>{const e=await I(v(te()));oe(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!q,onPress:()=>{(0,p.downloadText)(`tips-${H.start}-to-${H.end}.csv`,$(te())),oe('CSV downloaded.')}}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!q,onPress:()=>{const e=te();(0,p.printTable)(`Tips ${(0,u.rangeText)(H.start,H.end)} (paid ${(0,u.dayMonth)(H.payday)})`,`Total ${(0,c.gbp)(_)} shared by confirmed hours${ee.length?` \xb7 WARNING ${(0,u.decH)(se)} h not signed off`:''}`,e[0],e.slice(1))}})]}),V?(0,j.jsx)(i.Banner,{kind:"success",title:V}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:o}=(0,x.useCtx)(6e4),{pay:n,source:r}=(0,b.useVenuePay)(s),a=(0,u.nextToPay)(n,'tips',o).period,l=(0,u.nextToPay)(n,'wage',o).period;return(0,j.jsxs)(d.default,{testID:"paydays-card",style:{backgroundColor:h.colours.surface,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,padding:16,gap:8},children:[(0,j.jsx)(t.CardHeading,{right:'none'===r?(0,j.jsx)(i.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsxs)(i.T,{children:["Next tips payday: ",(0,j.jsx)(i.T,{weight:"semibold",colour:h.colours.goldLight,children:a.payday===o?'today':(0,u.dayMonth)(a.payday)})]}),(0,j.jsx)(i.Muted,{children:(0,u.rangeText)(a.start,a.end)})]}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsxs)(i.T,{children:["Next payday: ",(0,j.jsx)(i.T,{weight:"semibold",colour:h.colours.goldLight,children:l.payday===o?'today':(0,u.dayMonth)(l.payday)})]}),(0,j.jsxs)(i.Muted,{children:["period ",(0,u.rangeText)(l.start,l.end)]})]}),(0,j.jsxs)(t.ActionGrid,{testID:"paydays-actions",children:[(0,j.jsx)(t.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,j.jsx)(t.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==r?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e('more','paysettings'),style:{alignSelf:'flex-start'}}):null]})},_e.MyPeriods=function({staffId:e}){const{rid:s,today:t,now:o,meId:n}=(0,x.useCtx)(6e4),r=e??n,{pay:a}=(0,b.useVenuePay)(s),c=(0,l.useOwner)(e=>e.attendance),p=(0,l.useOwner)(e=>e.staff.find(e=>e.id===r)),y=(0,u.wagePeriod)(a,t,0),f=(0,u.tipsPeriod)(a,t,0),w=e=>p?S(e,[p],c,o,{})[0]??null:null,T=(e,s,o)=>(0,j.jsxs)(d.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:h.colours.surface,borderRadius:14,borderWidth:1,borderColor:h.colours.border,padding:12,gap:2},children:[(0,j.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:e.toUpperCase()}),(0,j.jsxs)(i.Muted,{children:[(0,u.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,u.dayMonth)(s.payday)]}),(0,j.jsxs)(i.T,{size:24,weight:"bold",children:[(0,u.decH)(o?.confirmed??0)," h"]}),(0,j.jsxs)(i.Muted,{children:["confirmed (",(0,u.hMm)(o?.confirmed??0),") \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,j.jsxs)(i.T,{size:13,colour:h.colours.amber,children:["+ ",(0,u.decH)(o.pending)," h waiting for sign-off"]}):null]},e);return(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[T('This pay period',y,w(y)),T('This tips fortnight',f,w(f))]})};var s=_r(_d[0]),t=_r(_d[1]);_r(_d[2]);var o=e(_r(_d[3])),n=e(_r(_d[4])),r=e(_r(_d[5])),d=e(_r(_d[6])),i=_r(_d[7]),a=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),f=_r(_d[15]),x=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]);const w={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},T={none:'Keep the date',before:'Friday before',after:'Monday after'};const P=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function k({label:e,day:s,period:t}){return(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsxs)(i.T,{children:[e,": ",(0,j.jsx)(i.T,{weight:"bold",colour:h.colours.gold,children:(0,u.dayMonth)(s)})]}),(0,j.jsx)(i.Muted,{children:(0,u.rangeText)(t.start,t.end)})]})}const C=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function S(e,s,t,o,n){const r=t.filter(s=>s.in&&s.date>=e.start&&s.date<=e.end);return s.map(e=>{const s=r.filter(s=>s.staffId===e.id).sort((e,s)=>e.date.localeCompare(s.date)||(e.in??'').localeCompare(s.in??'')).map(e=>{const s=(0,x.paidMins)(e,o),t=(0,l.attStatus)(e);return{a:e,date:e.date,inT:C(e.in),outT:C(e.out),brk:s.brk,paid:s.paid,status:'open'===t?'On now':'awaiting'===t?'Pending':'Confirmed'}}),t=e=>s.filter(s=>s.status===e).reduce((e,s)=>e+s.paid,0),d=t('Confirmed'),i=n[e.id];return{person:e,confirmed:d,pending:t('Pending'),open:t('On now'),shifts:s.filter(e=>'On now'!==e.status).length,days:s,rate:i,gross:null!=i?Math.round(d/60*i):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const M=e=>`${l.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,D=e=>e.name.replace(' (example)',''),B=e=>null==e?'':(e/100).toFixed(2),z=e=>e.replace(/[\t\r\n]+/g,' '),R=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,v=e=>e.map(e=>e.map(z).join('\t')).join('\n'),$=e=>e.map(e=>e.map(R).join(',')).join('\r\n');function O(e,s,t,o){const n=['Name','Role','Period start','Period end','Confirmed hours','Confirmed h:mm','Pending hours','Pending h:mm','Shifts',...o?['Tips hours']:[],...t?['Rate \xa3/h','Gross \xa3']:[]],r=e.map(e=>[D(e.person),M(e.person),(0,u.ukDate)(s.start),(0,u.ukDate)(s.end),(0,u.decH)(e.confirmed),(0,u.hMm)(e.confirmed),(0,u.decH)(e.pending),(0,u.hMm)(e.pending),String(e.shifts),...o?[(0,u.decH)(e.confirmed)]:[],...t?[B(e.rate),B(e.gross)]:[]]),d=e.reduce((e,s)=>({c:e.c+s.confirmed,p:e.p+s.pending,s:e.s+s.shifts,g:e.g+(s.gross??0)}),{c:0,p:0,s:0,g:0});return[n,...r,['TOTAL','',(0,u.ukDate)(s.start),(0,u.ukDate)(s.end),(0,u.decH)(d.c),(0,u.hMm)(d.c),(0,u.decH)(d.p),(0,u.hMm)(d.p),String(d.s),...o?[(0,u.decH)(d.c)]:[],...t?['',B(d.g)]:[]]]}function H(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[D(e.person),M(e.person),(0,u.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,u.decH)(s.paid),'On now'===s.status?'':(0,u.hMm)(s.paid),s.status]))]}async function I(e){if('undefined'==typeof document)return!1;try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const s=document.createElement('textarea');s.value=e,s.style.position='fixed',s.style.opacity='0',document.body.appendChild(s),s.select();const t=document.execCommand('copy');return s.remove(),t}catch{return!1}}function W(e,s){const t=(0,u.nextToPay)(e,'wage',s),o=(0,u.nextToPay)(e,'tips',s),n=(0,u.wagePeriod)(e,t.period.start,-1),r=(0,u.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,u.dayMonth)(e.payday)}`:`Paid ${(0,u.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,u.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,u.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,u.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,u.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function L({onSet:e}){const[t,o]=(0,s.useState)(''),[n,r]=(0,s.useState)(''),a=(0,u.parseUk)(t),l=(0,u.parseUk)(n),c=!!a&&!!l&&l>=a&&(0,u.plusDays)(a,92)>=l;return(0,j.jsxs)(i.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,j.jsx)(d.default,{style:{flexBasis:130,flexGrow:1},children:(0,j.jsx)(i.Field,{label:"From (DD/MM/YYYY)",value:t,onChangeText:o,placeholder:"23/10/2026"})}),(0,j.jsx)(d.default,{style:{flexBasis:130,flexGrow:1},children:(0,j.jsx)(i.Field,{label:"To (DD/MM/YYYY)",value:n,onChangeText:r,placeholder:"22/11/2026"})}),(0,j.jsx)(i.Button,{small:!0,kind:"success",label:"Show",disabled:!c,onPress:()=>c&&e((0,u.customPeriod)(a,l))}),t&&n&&!c?(0,j.jsx)(i.T,{size:13,colour:h.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const F=[150,54,62,62,48,62,70]},914,[12,897,104,245,133,255,109,791,855,813,794,1130,799,1131,915,921,884,1127,6]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"category",{enumerable:!0,get:function(){return b}}),_e.allocate=C,_e.Tips=function({go:e}={}){const{rid:y,now:S,today:O,role:M,meId:v,me:$}=(0,p.useCtx)(6e4),P=(0,l.useOwner)(e=>e.staff),B=(0,l.useOwner)(e=>e.attendance),R=(0,l.useOwner)(e=>e.shifts),I=(0,l.useOwner)(e=>e.tronc),A=(0,l.useOwner)(e=>e.troncCash),F=(0,l.useOwner)(e=>e.troncHistory),D=(0,l.useOwner)(e=>e.troncLog),z=(0,r.useOrders)(y),q=(0,m.useVenuePay)(y).pay,[E,L]=(0,t.useState)(-1),[H,V]=(0,t.useState)(''),[N,_]=(0,t.useState)(!1),[Y,K]=(0,t.useState)(!1),[W,G]=(0,t.useState)(I.text),[Q,J]=(0,t.useState)(null),U='staff'!==M,X='owner'===M,{s:Z,e:ee,key:te}=(0,m.venueRange)(q,'tips',E,S),se=`${(0,a.niceDate)(Z)} \u2013 ${(0,a.niceDate)(ee)} ${ee.getFullYear()}`,ne=F.find(e=>e.key===te),oe=e=>l.useOwner.getState().setOwner({tronc:{...I,...e}}),ie=(0,f.useSync)(e=>!!e.venueId&&'guest'!==e.kind),re=Math.round((ee.getTime()-Z.getTime())/864e5)+1,le=(0,t.useMemo)(()=>{let e=z.filter(e=>e.createdAt.slice(0,10)>=(0,a.ymd)(Z)&&e.createdAt.slice(0,10)<=(0,a.ymd)(ee)).reduce((e,t)=>e+(t.tip??0),0);if(!ie)for(let t=0;tS)break;const n=(0,p.weekday)(s);0!==n&&1!==n&&(e+=Math.round(6e3+9e3*(0,x.hash)((0,a.ymd)(s)+'tip')))}return e},[te,z.length,ie]),de=A[te]??0,ae=ne?ne.pot:le+de,ce=(0,t.useMemo)(()=>{const e={};for(let t=0;tO)break;const n=(0,a.ymd)(s);P.forEach(t=>{const s=B.filter(e=>e.staffId===t.id&&e.date===n&&e.out),o=s.filter(l.isConfirmed).reduce((e,t)=>e+(0,p.paidMins)(t,S).paid,0),i=s.filter(e=>!(0,l.isConfirmed)(e)).reduce((e,t)=>e+(0,p.paidMins)(t,S).paid,0);(o||i)&&(e[t.id]={paid:(e[t.id]?.paid??0)+o,est:(e[t.id]?.est??!1)||i>0})})}return e},[te,B.length,R.length,P.length]),ue=P.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&I.includeManagers||'owner'===e.role&&I.includeOwner)),he=(0,t.useMemo)(()=>{if(ne)return ne.rows;const e=ue.map(e=>{const t=(ce[e.id]?.paid??0)/60,s=I.points[b(e)]??1;return'hours'===I.method?t:'points'===I.method?t*s:'equal'===I.method?t>0?1:0:I.custom[e.id]??0}),{amounts:t}=C(ae,e),s=e.reduce((e,t)=>e+t,0);return ue.map((n,o)=>({staffId:n.id,hours:(ce[n.id]?.paid??0)/60,points:I.points[b(n)]??1,pct:s?e[o]/s*100:0,amount:t[o]}))},[ne,ue.map(e=>e.id).join(),ce,I,ae]),pe=he.reduce((e,t)=>e+t.amount,0),me=ne?0:(()=>{const e=he.map(e=>e.pct);return C(ae,e).remainder})(),ge=Object.entries(I.custom).filter(([e])=>ue.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),xe='custom'===I.method&&Math.abs(ge-100)>.01,fe=new Date(ee.getFullYear(),ee.getMonth()+2,0),ye=[...F].sort((e,t)=>t.end.localeCompare(e.end))[0],je=0!==F.length&&(0,a.parseYmd)(ye.end)<(0,a.addMins)(S,-89280),we=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(he.map(e=>{const t=P.find(t=>t.id===e.staffId);return`${T(t.name)},${b(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(pe/100).toFixed(2)}`]);return U?(0,j.jsxs)(o.default,{style:{gap:10},children:[(0,j.jsxs)(i.Card,{highlight:c.colours.gold,children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,j.jsx)(i.Muted,{children:"Enter the total and it's shared by confirmed hours for the fortnight, to the penny. Tips periods follow your pay dates (Settings \u203a Pay & tips)."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(i.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>L(E-1)}),(0,j.jsxs)(o.default,{style:{alignItems:'center',flex:1},children:[(0,j.jsx)(i.T,{weight:"semibold",children:se}),ne?(0,j.jsx)(i.Badge,{kind:"green",label:`Approved & locked ${ne.lockedAt}`}):E>=0?(0,j.jsx)(i.Badge,{kind:"amber",label:"Period in progress"}):(0,j.jsx)(i.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:E>=0,onPress:()=>L(E+1)})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Tip pot"}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{children:"Card tips on orders"}),(0,j.jsx)(i.T,{children:(0,d.gbp)(ne?ne.card:le)})]}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{children:"Cash tips"}),(0,j.jsx)(i.T,{children:(0,d.gbp)(ne?ne.cash:de)})]}),ne?null:(0,j.jsxs)(i.Row,{gap:6,children:[(0,j.jsx)(n.default,{accessibilityLabel:"Cash tips \xa3",placeholder:"Cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:H,onChangeText:V,style:[i.styles.input,{flex:1}]}),(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(H)>=0)||''===H.trim(),onPress:()=>{l.useOwner.getState().setOwner({troncCash:{...A,[te]:Math.round(100*Number(H))}}),V('')}})]}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"bold",children:"Total pot"}),(0,j.jsx)(i.T,{size:20,weight:"bold",colour:c.colours.gold,children:(0,d.gbp)(ae)})]}),(0,j.jsx)(i.Muted,{children:ie?'Card tips are the tips taken on orders in Cover Charge. Add cash tips above.':'Card tips are example figures plus any tips on orders in this demo.'})]}),ne?(0,j.jsxs)(i.Muted,{children:["Locked with method: ",w[ne.method],"."]}):(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,j.jsx)(i.Row,{wrap:!0,gap:6,children:Object.keys(w).map(e=>(0,j.jsx)(i.Chip,{label:w[e],selected:I.method===e,onPress:()=>X&&oe({method:e})},e))}),X?null:(0,j.jsx)(i.Muted,{children:"Only the owner can change the policy."}),'points'===I.method?Object.entries(I.points).map(([e,t])=>(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{children:e}),(0,j.jsxs)(i.Row,{gap:6,children:[(0,j.jsx)(i.Stepper,{value:Math.round(10*t),min:0,max:20,onChange:t=>X&&oe({points:{...I.points,[e]:t/10}}),label:`${e} points`}),(0,j.jsx)(i.T,{style:{width:30},children:t.toFixed(1)})]})]},e)):null,'custom'===I.method?(0,j.jsxs)(j.Fragment,{children:[ue.map(e=>(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{style:{flex:1},children:T(e.name)}),(0,j.jsx)(n.default,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(I.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>oe({custom:{...I.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&oe({custom:{...l.useOwner.getState().tronc.custom,[e.id]:s}})},style:[i.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,j.jsxs)(i.T,{size:13,colour:xe?c.colours.red:c.colours.green,children:["Total ",ge.toFixed(1),"%",xe?' (must be 100%)':' \u2713']})]}):null,(0,j.jsx)(i.Toggle,{label:"Include managers",value:I.includeManagers,onChange:e=>X&&oe({includeManagers:e})}),(0,j.jsx)(i.Toggle,{label:"Include owner",value:I.includeOwner,onChange:e=>X&&oe({includeOwner:e})}),I.includeOwner?(0,j.jsx)(i.Banner,{kind:"warn",title:"Owner included",children:"Employers must not keep tips. An owner may only share in tips for qualifying work they personally do; check the statutory Code of Practice before including yourself."}):null]}),(0,j.jsx)(s.default,{horizontal:!0,children:(0,j.jsxs)(o.default,{children:[(0,j.jsx)(i.Row,{gap:0,style:{borderBottomWidth:1,borderColor:c.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,j.jsx)(i.T,{size:12,weight:"semibold",colour:c.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),he.map(e=>{const t=P.find(t=>t.id===e.staffId);return(0,j.jsxs)(i.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,j.jsxs)(i.T,{size:13,style:{width:130},numberOfLines:1,children:[T(t?.name),ce[e.staffId]?.est&&!ne?'*':'']}),(0,j.jsx)(i.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,j.jsx)(i.T,{size:13,style:{width:54},children:'points'===I.method||'points'===ne?.method?e.points.toFixed(1):'\u2013'}),(0,j.jsxs)(i.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,j.jsx)(i.T,{size:13,weight:"semibold",style:{width:80},children:(0,d.gbp)(e.amount)})]},e.staffId)}),(0,j.jsxs)(i.Row,{gap:0,style:{paddingVertical:6},children:[(0,j.jsx)(i.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,j.jsx)(i.T,{size:13,weight:"bold",colour:pe===ae?c.colours.green:c.colours.red,style:{width:80},children:(0,d.gbp)(pe)})]})]})}),(0,j.jsxs)(i.Muted,{children:[pe===ae?`\u2713 Total equals the pot (${(0,d.gbp)(ae)}).`:'\u2717 Total does not equal the pot.',me?` Rounding: ${me}p left after rounding down went to the largest fractions, 1p each.`:''," * has hours still awaiting sign-off, which don\u2019t count until a manager confirms them. Paid hours already exclude breaks."]}),ne?null:(0,j.jsx)(i.Button,{label:"Approve & lock period",disabled:!X||E>=0||xe||pe!==ae||ae<=0,onPress:()=>{const e=`${(0,a.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${te}`,key:te,label:se,end:(0,a.ymd)(ee),pot:ae,card:le,cash:de,method:I.method,rows:he,lockedAt:e,by:$};l.useOwner.getState().setOwner({troncHistory:[t,...F],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${$} approved & locked tips for ${se}: ${(0,d.gbp)(ae)} split ${w[I.method].toLowerCase()} between ${he.filter(e=>e.amount>0).length} staff`},...D]})}}),!ne&&E>=0?(0,j.jsx)(i.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,X||ne?null:(0,j.jsx)(i.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>_(!0)}),ne?(0,j.jsx)(i.Button,{small:!0,kind:"secondary",label:ne.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!ne.shared,onPress:()=>{(0,u.autoPost)('all',`Tips for ${se} approved: ${(0,d.gbp)(ne.pot)} shared between ${ne.rows.filter(e=>e.amount>0).length} staff. See your own share in Team \u203a Tips.`),l.useOwner.getState().setOwner({troncHistory:F.map(e=>e.id===ne.id?{...e,shared:(0,a.niceDate)(S)}:e)}),J('Posted to All staff chat. Demo, nothing is sent.')}}):null]}),Q?(0,j.jsx)(i.Banner,{kind:"demo",title:Q}):null,(0,j.jsx)(h.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,j.jsxs)(i.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,d.gbp)(ae)} = allocated ${(0,d.gbp)(pe)}`],[I.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!je,'Tips allocated by the end of the following month',`This period: by ${(0,a.niceDate)(fe)} ${fe.getFullYear()}`],[!0,'Tip records kept for 3 years',`${F.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${D.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,j.jsxs)(i.Row,{style:{alignItems:'flex-start'},children:[(0,j.jsx)(i.T,{colour:e?c.colours.green:c.colours.red,children:e?'\u2713':'\u2717'}),(0,j.jsxs)(o.default,{style:{flex:1},children:[(0,j.jsx)(i.T,{size:14,children:t}),(0,j.jsx)(i.Muted,{children:s})]})]},String(t))),(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{G(I.text),K(!0)}})]}),(0,j.jsx)(h.SectionHead,{title:"Tip history & audit log"}),F.map(e=>(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:e.label}),(0,j.jsx)(i.T,{weight:"bold",children:(0,d.gbp)(e.pot)})]}),(0,j.jsxs)(i.Muted,{children:[w[e.method]," \xb7 ",e.rows.filter(e=>e.amount>0).length," staff \xb7 locked ",e.lockedAt," by ",e.by,e.shared?` \xb7 shared ${e.shared}`:'']})]},e.id)),D.map(e=>(0,j.jsxs)(i.Muted,{children:[(0,a.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),F.length||D.length?null:(0,j.jsx)(i.Muted,{children:"No approved periods yet."}),(0,j.jsxs)(i.Sheet,{visible:N,onClose:()=>_(!1),title:"Tips summary export",children:[(0,j.jsx)(i.Banner,{kind:"demo",title:"Placeholder \u2014 nothing is sent",children:"In production this downloads a CSV or a PDF payslip summary for payroll."}),(0,j.jsx)(o.default,{style:{backgroundColor:'#111',borderRadius:8,padding:8},children:we.map((e,t)=>(0,j.jsx)(i.T,{size:11,colour:t?c.colours.text:c.colours.gold,children:e},t))}),(0,j.jsxs)(i.Muted,{children:[se," \xb7 ",w[ne?.method??I.method]]})]}),(0,j.jsxs)(i.Sheet,{visible:Y,onClose:()=>K(!1),title:"Tipping policy",children:[(0,j.jsx)(n.default,{accessibilityLabel:"Tipping policy",multiline:!0,editable:X,value:W,onChangeText:G,style:[i.styles.input,{minHeight:220,textAlignVertical:'top'}]}),X?(0,j.jsx)(i.Button,{label:"Save policy",onPress:()=>{oe({text:W}),K(!1)}}):null,(0,j.jsx)(i.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,j.jsx)(k,{})},_e.MyTips=k;var t=_r(_d[0]),s=e(_r(_d[1])),n=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]);const w={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},b=e=>'staff'!==e.role?'Manager':/porter|KP/i.test(e.job)?'KP':/kitchen|chef/i.test(e.job)?'Kitchen':/bar/i.test(e.job)?'Bar':'FOH',T=e=>(e??'').replace(' (example)','');function C(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const n=t.map(t=>e*t/s),o=n.map(Math.floor);let i=e-o.reduce((e,t)=>e+t,0);const r=i;return n.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{i>0&&(o[e]+=1,i-=1)}),{amounts:o,remainder:r}}function k({staffId:e}={}){const s=(0,p.useCtx)(6e4),{now:n,me:r}=s,a=e??s.meId,u=(0,l.useOwner)(e=>e.tronc),h=(0,l.useOwner)(e=>e.troncHistory),m=(0,l.useOwner)(e=>e.troncLog),[x,f]=(0,t.useState)(!1),[b,T]=(0,t.useState)(null),C=h.flatMap(e=>e.rows.filter(e=>e.staffId===a).map(t=>({h:e,r:t})));return(0,j.jsxs)(o.default,{style:{gap:10},children:[(0,j.jsx)(y.TipGoalCard,{staffId:a}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"My tips"}),(0,j.jsx)(i.Muted,{children:"Only your own tip history is shown. 100% of tips go to staff; nothing is deducted."})]}),C.map(({h:e,r:t})=>(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:e.label}),(0,j.jsx)(i.T,{weight:"bold",colour:c.colours.gold,children:(0,d.gbp)(t.amount)})]}),(0,j.jsxs)(i.Muted,{children:[(0,p.hmDur)(Math.round(60*t.hours))," paid \xb7 ",t.pct.toFixed(1),"% share \xb7 ",w[e.method]," \xb7 approved ",e.lockedAt]})]},e.id)),C.length?null:(0,j.jsx)(i.Muted,{children:"No approved tip periods yet. (Preview: approve a period in the Owner view first.)"}),(0,j.jsx)(i.Button,{kind:"secondary",label:"Request my tip records",onPress:()=>{l.useOwner.getState().setOwner({troncLog:[{id:`tl-${Date.now()}`,at:n.toISOString(),text:`${r} requested their tip records`},...m]}),T('Request logged for your manager (demo, nothing is sent).')}}),b?(0,j.jsx)(i.Banner,{kind:"success",title:b}):null,(0,j.jsx)(i.Button,{kind:"ghost",label:"Read the tipping policy",onPress:()=>f(!0)}),(0,j.jsx)(i.Sheet,{visible:x,onClose:()=>f(!1),title:"Tipping policy",children:(0,j.jsx)(i.T,{size:14,children:u.text})})]})}},915,[12,133,255,109,791,797,813,794,796,799,910,921,884,1127,1094,798,1132,6]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ROSTER_VERSION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ROSTER",{enumerable:!0,get:function(){return t}});const n='4ef0b26f4d11',t=[{id:"st-tracy",name:"Tracy",level:"Owner",role:"owner",job:"Owner",dept:"Management",app:"owner",tokenHash:"64918845ba3e3f31ec287c0ad303ed80c81806005a9d7bdb21b8344e6114f81f",hourlyPence:null,salaried:!0,noTax:!1,avatar:{bg:"#1F6F78",ring:"#E9B949",skin:"#F1C7A5",hair:"#D9B26A",hairStyle:"beehive",suit:"#F2EAD8",antenna:"star"}},{id:"st-james",name:"James",level:"Owner",role:"owner",job:"Owner",dept:"Management",app:"owner",tokenHash:"b4781ef0b4fa7648f943245fe7a5d308f60debea174b9db9b07bccc3c21307e2",hourlyPence:null,salaried:!0,noTax:!1,avatar:{bg:"#3D5A80",ring:"#E9B949",skin:"#E8B48F",hair:"#2B1B12",hairStyle:"quiff",suit:"#F2EAD8",antenna:"ball"}},{id:"st-gordon",name:"Gordon",level:"Manager",role:"manager",job:"General Manager",dept:"Kitchen",app:"owner",tokenHash:"9026c833cde6696e48f79b1c7245fa39617cf7a8dffe11e5bd747093f08eca63",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#C8553D",ring:"#3FB8AF",skin:"#F4D2B8",hair:"#7A4E2A",hairStyle:"crop",suit:"#FFFFFF",antenna:"ball",specs:!0}},{id:"st-bisto",name:"Bisto",level:"Head Chef",role:"staff",job:"Head Chef",dept:"Kitchen",app:"chef",tokenHash:"b764b6a58005e4311bee1cbe77f316b5b0ca9ebaab117a76c93c21bf07ee599b",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#D9A441",ring:"#C8553D",skin:"#C68B5E",hair:"#151515",hairStyle:"quiff",suit:"#FFFFFF",antenna:"star"}},{id:"st-lenny",name:"Lenny",level:"Staff",role:"staff",job:"Commis Chef",dept:"Kitchen",app:"staff",tokenHash:"d83627269458f816918e10760aa749bcfe7dfbc57e6ff782c7a2ac0c82540ba7",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#2E7D5B",ring:"#E9B949",skin:"#F1C7A5",hair:"#C2462E",hairStyle:"curls",suit:"#FFFFFF",antenna:"none"}},{id:"st-agate",name:"Agate",level:"Supervisor",role:"manager",job:"Restaurant Supervisor",dept:"Front of house",app:"owner",tokenHash:"303c5ef91b6d9db6554f65f4e499345b9aab7bfa860a6afcaa6d83054242dc1b",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#6A4C93",ring:"#E9B949",skin:"#E8B48F",hair:"#151515",hairStyle:"bob",suit:"#F2EAD8",antenna:"star",specs:!0}},{id:"st-finn",name:"Finn (Paddy)",level:"Staff",role:"staff",job:"Bar Extraordinaire",dept:"Bar",app:"staff",tokenHash:"0e294833ce0e7a2485f66948cc1c577d51ab13883eed58d46b2501ce9c40b062",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#1F6F78",ring:"#C8553D",skin:"#A86B45",hair:"#2B1B12",hairStyle:"quiff",suit:"#F2EAD8",antenna:"star"}},{id:"st-eilidh",name:"Eilidh",level:"Staff",role:"staff",job:"Front of house",dept:"Front of house",app:"staff",tokenHash:"133c098eb5906c32edf362e24bb32a7bfd57c36cb6b2cce4094ebc43dbe02ff1",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#C8553D",ring:"#E9B949",skin:"#F4D2B8",hair:"#C2462E",hairStyle:"flip",suit:"#F2EAD8",antenna:"ball"}},{id:"st-emily",name:"Emily",level:"Staff",role:"staff",job:"Front of house",dept:"Front of house",app:"staff",tokenHash:"d16fa49ec8987b81135d84e889c88b12c5b674a6f18ab67d4d0bab74e03e050f",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#3D5A80",ring:"#3FB8AF",skin:"#F1C7A5",hair:"#D9B26A",hairStyle:"bob",suit:"#F2EAD8",antenna:"none"}},{id:"st-gabrielle",name:"Gabrielle",level:"Staff",role:"staff",job:"Front of house",dept:"Front of house",app:"staff",tokenHash:"85cd2671f1e9cf0290c125de6b3972519dca189c92d4f626a9232ef73e9e409b",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#6A4C93",ring:"#3FB8AF",skin:"#8D5B3E",hair:"#151515",hairStyle:"curls",suit:"#F2EAD8",antenna:"ball"}},{id:"st-cameron",name:"Cameron Mc",level:"Staff",role:"staff",job:"Front of house (temp)",dept:"Front of house",app:"staff",tokenHash:"b4caac557b1d65c1a4083c1546adfac393078b5650dc56d7dfa7c25383e46e0b",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#2E7D5B",ring:"#C8553D",skin:"#E8B48F",hair:"#7A4E2A",hairStyle:"crop",suit:"#F2EAD8",antenna:"star",specs:!0}},{id:"st-lillie",name:"Lillie",level:"Staff",role:"staff",job:"Kitchen porter (KP)",dept:"Kitchen",app:"staff",tokenHash:"daed0ae0e13f323bf73e0cd7c60ea11f223198bf183e758280bf9c742e45ec29",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#D9A441",ring:"#3FB8AF",skin:"#F4D2B8",hair:"#2B1B12",hairStyle:"flip",suit:"#FFFFFF",antenna:"star"}},{id:"st-mia",name:"Mia",level:"Staff",role:"staff",job:"Kitchen porter (KP)",dept:"Kitchen",app:"staff",tokenHash:"e42954a50e3aecf75dd13536806724ae660a14fca5bfbcb83a37dd0cefd7b48f",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#1F6F78",ring:"#3FB8AF",skin:"#C68B5E",hair:"#151515",hairStyle:"beehive",suit:"#FFFFFF",antenna:"ball"}},{id:"st-jack",name:"Jack",level:"Staff",role:"staff",job:"Kitchen porter (KP)",dept:"Kitchen",app:"staff",tokenHash:"40fdbcb8935fefa51e516b58e281b1fe1d1e49fc42f587b67a2f20630cdeada4",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#C8553D",ring:"#E9B949",skin:"#F1C7A5",hair:"#D9B26A",hairStyle:"quiff",suit:"#FFFFFF",antenna:"none"}},{id:"st-harvey",name:"Harvey",level:"Staff",role:"staff",job:"Kitchen porter (KP)",dept:"Kitchen",app:"staff",tokenHash:"0fadccb2956e636aa070817bde99461f048ad57de67d098a793754cc4e553c8c",hourlyPence:null,salaried:!1,noTax:!1,avatar:{bg:"#3D5A80",ring:"#C8553D",skin:"#A86B45",hair:"#7A4E2A",hairStyle:"curls",suit:"#FFFFFF",antenna:"star",specs:!0}}]},916,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.AccidentBook=function({me:e,meId:s,now:n,app:d,seeAll:h}){const p=(0,l.useSafety)(e=>e.accidents),[y,f]=(0,t.useState)(h?'list':'add'),b=p.filter(e=>e.reportedById===s),w=p.length-b.length;return(0,u.jsxs)(a.default,{style:{gap:12},testID:"accident-book",children:[(0,u.jsx)(c.Tabs,{value:y,onChange:f,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:h?`All entries (${p.length})`:`My entries (${b.length})`}]}),'add'===y?(0,u.jsx)(x,{me:e,meId:s,now:n,app:d,onSaved:()=>f('list')}):null,'list'===y?(0,u.jsxs)(c.Box,{testID:"accident-list",children:[(h?p:b).length?(h?p:b).map(e=>(0,u.jsx)(j,{a:e,manager:h},e.id)):(0,u.jsx)(o.Muted,{children:"No entries yet."}),!h&&w>0?(0,u.jsx)(a.default,{testID:"accident-others",children:(0,u.jsxs)(o.Muted,{children:[w," other entr",1===w?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,u.jsx)(o.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device in the prototype; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=e(r(_d[1])),n=e(r(_d[2])),a=e(r(_d[3])),o=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const h=e=>String(e).padStart(2,'0'),p=e=>`${e.getFullYear()}-${h(e.getMonth()+1)}-${h(e.getDate())}T${h(e.getHours())}:${h(e.getMinutes())}`,y=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${h(t.getHours())}:${h(t.getMinutes())}`};function x({me:e,meId:s,now:h,app:y,onSaved:x}){const[j,f]=(0,t.useState)({date:p(h).slice(0,10),time:p(h).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[b,w]=(0,t.useState)(''),[T,D]=(0,t.useState)(''),S=e=>f({...j,...e}),C='Near miss'===j.category,v=(e,t,s,l=!1)=>(0,u.jsxs)(a.default,{style:{gap:4},children:[(0,u.jsx)(o.T,{size:14,weight:"medium",colour:d.colours.muted,children:e}),(0,u.jsx)(n.default,{accessibilityLabel:e,value:String(j[t]),onChangeText:e=>S({[t]:e}),placeholder:s,placeholderTextColor:"#7D776C",multiline:l,style:[o.styles.input,l&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,u.jsxs)(c.Box,{testID:"accident-form",children:[(0,u.jsx)(o.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsxs)(a.default,{style:{flex:1,gap:4},children:[(0,u.jsx)(o.T,{size:14,weight:"medium",colour:d.colours.muted,children:"Date"}),(0,u.jsx)(n.default,{accessibilityLabel:"Date",value:j.date,onChangeText:e=>S({date:e}),placeholder:"YYYY-MM-DD",placeholderTextColor:"#7D776C",style:[o.styles.input,{minWidth:0,width:40}]})]}),(0,u.jsxs)(a.default,{style:{width:110,gap:4},children:[(0,u.jsx)(o.T,{size:14,weight:"medium",colour:d.colours.muted,children:"Time"}),(0,u.jsx)(n.default,{accessibilityLabel:"Time",value:j.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:o.styles.input})]})]}),(0,u.jsx)(o.T,{size:14,weight:"medium",colour:d.colours.muted,children:"What kind?"}),(0,u.jsx)(o.Row,{wrap:!0,gap:6,children:l.ACCIDENT_CATEGORIES.map(e=>(0,u.jsx)(o.Chip,{label:e,selected:j.category===e,onPress:()=>S({category:e})},e))}),v('Where it happened','location','e.g. kitchen pass, cellar steps, terrace'),v('Person involved','person','Name'),(0,u.jsx)(o.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,u.jsx)(o.Chip,{label:e,selected:j.personType===e,onPress:()=>S({personType:e})},e))}),v('What happened','what','Describe what happened, in order',!0),v('Injury','injury',C?'None (near miss)':'e.g. small cut to left thumb'),v('First aid given','firstAid','e.g. cleaned and plaster applied by \u2026'),v('Witnesses','witnesses','Names, or none'),v('Reported by','reportedBy','Your name'),b?(0,u.jsx)(o.Banner,{kind:"warn",children:b}):null,(0,u.jsx)(o.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(j.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(j.time)?j.category?j.location.trim()&&j.person.trim()&&j.what.trim()?(l.useSafety.getState().addAccident({when:`${j.date}T${j.time}`,location:j.location.trim(),person:j.person.trim(),personType:j.personType,category:j.category,what:j.what.trim(),injury:j.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:j.firstAid.trim()||'None recorded',witnesses:j.witnesses.trim()||'None',reportedBy:j.reportedBy.trim()||e,reportedById:s,app:y}),D(`Saved to the accident book: ${j.category}, ${j.location.trim()}.`),w(''),f({...j,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void x()):w('Fill in where it happened, who was involved and what happened.'):w('Pick what kind of accident or near miss it was.'):w('Enter the date as YYYY-MM-DD and the time as HH:MM.')}),T?(0,u.jsx)(a.default,{testID:"accident-saved",children:(0,u.jsx)(o.T,{size:14,colour:d.colours.green,children:T})}):null,(0,u.jsx)(o.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function j({a:e,manager:c}){const h=l.RIDDOR_CATEGORIES.includes(e.category),[p,x]=(0,t.useState)(e.riddorNote??''),[j,f]=(0,t.useState)(!1);return(0,u.jsxs)(a.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:d.colours.border,gap:4},children:[(0,u.jsxs)(s.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>f(!j),children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(o.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,u.jsx)(o.Badge,{kind:'Near miss'===e.category?'blue':h?'red':'amber',label:'Near miss'===e.category?'Near miss':h?'Serious':'Accident'})]}),(0,u.jsxs)(o.Muted,{children:[y(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||c?(0,u.jsxs)(a.default,{style:{gap:2},children:[(0,u.jsxs)(o.T,{size:14,children:["What happened: ",e.what]}),(0,u.jsxs)(o.T,{size:14,children:["Injury: ",e.injury]}),(0,u.jsxs)(o.T,{size:14,children:["First aid: ",e.firstAid]}),(0,u.jsxs)(o.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,c&&h?(0,u.jsxs)(a.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,u.jsx)(o.Banner,{kind:"danger",title:"Consider RIDDOR",children:"This may need reporting to the HSE under RIDDOR (for example a specified injury, over-7-day incapacitation, or a member of the public taken to hospital). Check the HSE\u2019s RIDDOR guidance and decide. Cover Charge never reports anything for you."}),(0,u.jsx)(n.default,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:x,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:o.styles.input}),(0,u.jsx)(o.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>l.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,u.jsxs)(o.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},917,[12,245,255,109,791,977,799,1131,6]); +__d(function(g,_r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.MissedBanner=f,_e.HaccpLog=function({me:e,meId:n,now:s,mode:o}){const[r,d]=(0,t.useState)('today'),c=(e,t)=>({id:e,label:t}),u='chef'===o?[c('today','Today'),c('units','Fridges & units'),c('record','Quick entry'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:'managers'===o?[c('today','Today'),c('units','Fridges & units'),c('diary','Diary'),c('weekly','Weekly sign-off'),c('report','EHO report'),c('history','History'),c('limits','Safe limits'),c('probes','Wireless probes')]:[c('today','Today'),c('record','Quick entry'),c('diary','Diary'),c('history','My entries')],x={me:e,meId:n,now:s,mode:o};return(0,m.jsxs)(i.default,{style:{gap:12},testID:"haccp-log",children:['today'!==r?(0,m.jsx)(f,{now:s,onPress:()=>d('today')}):null,(0,m.jsx)(h.Tabs,{value:r,onChange:d,options:u}),'today'===r?(0,m.jsx)(p.TodayView,{who:x}):null,'units'===r?(0,m.jsx)(p.UnitsView,{who:x}):null,'record'===r?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(w,{who:x}),(0,m.jsx)(v,{who:x})]}):null,'diary'===r?(0,m.jsx)(p.DiaryView,{who:x}):null,'weekly'===r?(0,m.jsx)(p.WeeklyView,{who:x}):null,'report'===r?(0,m.jsx)(p.ReportView,{who:x}):null,'history'===r?(0,m.jsx)(k,{who:x}):null,'limits'===r?(0,m.jsx)(S,{editable:'chef'===o}):null,'probes'===r?(0,m.jsx)(I,{me:e,now:s}):null,(0,m.jsx)(l.Muted,{children:"Every reading here was entered by a person; the app never fills in or estimates a value. Sections follow Safer Food, Better Business (cross-contamination, cleaning, chilling, cooking, management). Your own HACCP plan (e.g. CookSafe) sets the limits that count. Demo: stored on this device only."})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),o=e(_r(_d[3])),i=e(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),y=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function f({now:e,onPress:t}){const n=(0,r.useSafety)(e=>e.points),o=(0,r.useSafety)(e=>e.entries),c=(0,d.missedChecks)(n,o,e);if(!c.length)return(0,m.jsx)(i.default,{testID:"haccp-uptodate",children:(0,m.jsx)(l.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const u=(0,m.jsx)(i.default,{testID:"haccp-missed",children:(0,m.jsx)(l.Banner,{kind:"warn",title:`${c.length} food safety check${1===c.length?'':'s'} overdue`,children:c.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,m.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:u}):u}function j(e,t){r.useSafety.getState().addEntries(t.map(t=>{const n=(0,d.isTempKind)(t.point.kind)?(0,d.inRange)(t.point,t.value):!!t.done;return{pointId:t.point.id,name:t.point.name,kind:t.point.kind,at:e.now.toISOString(),by:e.me.replace(' (example)',''),byId:e.meId,app:e.mode,value:t.value,done:t.done,ok:n,corrective:t.corrective?.trim()||void 0,note:t.note?.trim()||void 0,source:t.source,initials:(0,d.initialsOf)(e.me)}}))}function w({who:e}){const n=(0,r.useSafety)(e=>e.points),[u,p]=(0,t.useState)(''),[x,b]=(0,t.useState)(null),[f,w]=(0,t.useState)(''),[v,k]=(0,t.useState)(!1),[C,S]=(0,t.useState)(!1),T=(0,t.useRef)(null),D=(e,t)=>{const s=(0,d.parseQuick)(e,n);S(t),w(''),b(s.map((e,t)=>({key:`${t}-${e.text}`,text:e.text,pointId:e.point?.id,value:null==e.value?'':String(e.value),done:!(!e.point||(0,d.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},I=(e,t)=>b(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),P=(x??[]).map(e=>{const t=n.find(t=>t.id===e.pointId),s=y(e.value),o=!!t&&(0,d.isTempKind)(t.kind),i=!!t&&(o?null!=s:void 0!==e.done),l=t?o?null!=s?(0,d.inRange)(t,s):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:s,temp:o,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),R=P.length>0&&P.every(e=>e.ready&&!e.needsAction);return(0,m.jsxs)(h.Box,{testID:"haccp-quick",children:[(0,m.jsx)(l.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,m.jsx)(l.Muted,{children:"For example \u201cwalk-in fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,m.jsxs)(l.Row,{gap:8,children:[(0,m.jsx)(o.default,{accessibilityLabel:"Readings",value:u,onChangeText:p,placeholder:"walk-in fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>D(u,!1),style:[l.styles.input,{flex:1,minWidth:0,width:40}]}),(0,m.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,h.speechRecognition)();if(!e)return void w("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(v)return void T.current?.stop();const t=new e;T.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'';p(t),t&&D(t,!0)},t.onerror=()=>w("Didn't catch that. Try again or type the readings."),t.onend=()=>k(!1);try{t.start(),k(!0)}catch{w("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:v?c.colours.gold:'transparent'},children:(0,m.jsx)(l.T,{size:20,children:v?'\u25a0':'\ud83c\udfa4'})})]}),(0,m.jsx)(l.Button,{label:"Check readings",disabled:!u.trim(),onPress:()=>D(u,!1)}),f?(0,m.jsx)(i.default,{testID:"haccp-quick-msg",children:(0,m.jsx)(l.Banner,{kind:"info",children:f})}):null,x?(0,m.jsxs)(i.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,m.jsxs)(l.T,{weight:"semibold",children:["Check these ",x.length," reading",1===x.length?'':'s']}),P.map(({d:e,point:t,temp:r,ok:u,needsAction:h})=>(0,m.jsxs)(i.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===u?c.colours.red:c.colours.border,backgroundColor:c.colours.surface2},children:[(0,m.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,m.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:`Remove ${t?.name??e.text}`,onPress:()=>b(t=>t.filter(t=>t.key!==e.key)),children:(0,m.jsx)(l.T,{colour:c.colours.muted,children:"\u2715"})})]}),t?(0,m.jsxs)(l.T,{weight:"semibold",children:[t.name," ",(0,m.jsxs)(l.Muted,{children:["\xb7 safe: ",(0,d.limitText)(t)]})]}):(0,m.jsxs)(i.default,{style:{gap:6},children:[(0,m.jsx)(l.T,{colour:c.colours.amber,children:e.problem}),(0,m.jsx)(l.Row,{wrap:!0,gap:6,children:n.map(t=>(0,m.jsx)(l.Chip,{label:t.name,onPress:()=>I(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),t&&r?(0,m.jsxs)(l.Row,{gap:8,children:[(0,m.jsx)(o.default,{accessibilityLabel:`Reading for ${t.name}`,value:e.value,onChangeText:t=>I(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:96,fontSize:20}]}),(0,m.jsx)(l.T,{size:18,children:"\xb0C"}),null===u?(0,m.jsx)(l.Badge,{kind:"amber",label:"Type the reading"}):(0,m.jsx)(l.Badge,{kind:u?'green':'red',label:u?'OK':'OUT OF RANGE'})]}):null,t&&!r?(0,m.jsxs)(l.Row,{gap:6,children:[(0,m.jsx)(l.Chip,{label:"Done",selected:!0===e.done,onPress:()=>I(e.key,{done:!0})}),(0,m.jsx)(l.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>I(e.key,{done:!1})})]}):null,!1===u?(0,m.jsx)(o.default,{accessibilityLabel:`Corrective action for ${t.name}`,value:e.corrective,onChangeText:t=>I(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[l.styles.input,h&&{borderColor:c.colours.red}]}):null,h?(0,m.jsx)(l.T,{size:13,colour:c.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,m.jsxs)(l.Row,{gap:8,children:[(0,m.jsx)(l.Button,{label:`Save ${P.length} reading${1===P.length?'':'s'}`,testID:"haccp-save-quick",disabled:!R,onPress:()=>{j(e,P.map(e=>({point:e.point,value:e.temp?e.v:void 0,done:e.temp?void 0:e.d.done,corrective:e.d.corrective,source:C?'voice':'typed'}))),w(`Saved ${P.length} reading${1===P.length?'':'s'}.`),b(null),p('')},style:{flex:1}}),(0,m.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>{b(null),w('Nothing saved.')}})]}),(0,m.jsx)(l.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function v({who:e}){const n=(0,r.useSafety)(e=>e.points),[s,i]=(0,t.useState)(n[0]?.id),[u,p]=(0,t.useState)(''),[x,b]=(0,t.useState)(),[f,w]=(0,t.useState)(''),[v,k]=(0,t.useState)(''),[C,S]=(0,t.useState)(''),T=n.find(e=>e.id===s),D=!!T&&(0,d.isTempKind)(T.kind),I=y(u),P=T?D?null==I?null:(0,d.inRange)(T,I):void 0===x?null:x:null,R=null!==P&&(P||f.trim());return(0,m.jsxs)(h.Box,{testID:"haccp-manual",children:[(0,m.jsx)(l.T,{weight:"semibold",size:17,children:"Record one check"}),(0,m.jsx)(l.Row,{wrap:!0,gap:6,children:n.map(e=>(0,m.jsx)(l.Chip,{label:e.name,selected:e.id===s,onPress:()=>{i(e.id),p(''),b(void 0),w(''),S('')}},e.id))}),T?(0,m.jsxs)(l.Muted,{children:[d.KIND_LABEL[T.kind]," \xb7 safe: ",(0,d.limitText)(T)]}):null,D?(0,m.jsxs)(l.Row,{gap:8,children:[(0,m.jsx)(o.default,{accessibilityLabel:"Temperature reading",value:u,onChangeText:p,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:110,fontSize:22}]}),(0,m.jsx)(l.T,{size:18,children:"\xb0C"}),null===P?null:(0,m.jsx)(l.Badge,{kind:P?'green':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,m.jsxs)(l.Row,{gap:6,children:[(0,m.jsx)(l.Chip,{label:"Done",selected:!0===x,onPress:()=>b(!0)}),(0,m.jsx)(l.Chip,{label:"Not done",selected:!1===x,onPress:()=>b(!1)})]}),!1===P?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.Banner,{kind:"danger",title:D?'Out of range':'Check not done',children:"Write what you did about it before saving (e.g. moved food, discarded, called the engineer, re-checked in 30 minutes)."}),(0,m.jsx)(o.default,{accessibilityLabel:"Corrective action",value:f,onChangeText:w,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:l.styles.input})]}):null,(0,m.jsx)(o.default,{accessibilityLabel:"Note (optional)",value:v,onChangeText:k,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,m.jsx)(l.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{j(e,[{point:T,value:D?I:void 0,done:D?void 0:x,corrective:f,note:v,source:'typed'}]),p(''),b(void 0),w(''),k(''),S(`Saved: ${T.name}.`)}}),C?(0,m.jsx)(l.T,{size:14,colour:c.colours.green,children:C}):null]})}function k({who:e}){const n=(0,r.useSafety)(e=>e.entries),s=(0,r.useSafety)(e=>e.points),[o,u]=(0,t.useState)('7'),[p,x]=(0,t.useState)('all'),[b,y]=(0,t.useState)(!1),[f,j]=(0,t.useState)(''),w='staff'===e.mode,v=(0,t.useMemo)(()=>{const t=new Date(e.now);t.setHours(0,0,0,0);const s='today'===o?t.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return n.filter(t=>!(w&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==p&&t.kind!==p||b&&t.ok))},[n,o,p,b,w,e.meId,e.now.getTime()]),k=Array.from(new Set(s.map(e=>e.kind))),S=e.now.toISOString().slice(0,10);return(0,m.jsxs)(h.Box,{testID:"haccp-history",children:[(0,m.jsx)(l.T,{weight:"semibold",size:17,children:w?'My entries':'Food safety log'}),(0,m.jsx)(l.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,m.jsx)(l.Chip,{label:t,selected:o===e,onPress:()=>u(e)},e))}),(0,m.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(l.Chip,{label:"All checks",selected:'all'===p,onPress:()=>x('all')}),k.map(e=>(0,m.jsx)(l.Chip,{label:d.KIND_LABEL[e],selected:p===e,onPress:()=>x(e)},e))]}),(0,m.jsx)(l.Toggle,{label:"Out of range only",value:b,onChange:y}),(0,m.jsx)(i.default,{testID:"haccp-count",children:(0,m.jsxs)(l.Muted,{children:[v.length," entr",1===v.length?'y':'ies',v.filter(e=>!e.ok).length?` \xb7 ${v.filter(e=>!e.ok).length} out of range`:'']})}),v.length?v.slice(0,200).map(e=>(0,m.jsx)(C,{e:e},e.id)):(0,m.jsx)(l.Muted,{children:"No entries for these filters yet."}),w?null:(0,m.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,m.jsx)(l.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>j((0,h.downloadText)(`food-safety-log-${S}.csv`,(0,d.toCsv)(v,s))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,m.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>j((0,h.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,d.LOG_HEAD,(0,d.logRows)(v,s))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),f?(0,m.jsx)(l.T,{size:14,colour:c.colours.green,children:f}):null]})}function C({e:e}){return(0,m.jsxs)(i.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border,gap:2},children:[(0,m.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsx)(l.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,m.jsx)(l.T,{size:17,weight:"bold",colour:e.ok?c.colours.green:c.colours.red,children:(0,d.fmtEntryValue)(e)})]}),(0,m.jsxs)(l.Row,{gap:6,children:[(0,m.jsx)(u.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,m.jsxs)(l.Muted,{style:{flex:1},children:[b(e.at)," ",x(e.at)," \xb7 ",e.initials??(0,d.initialsOf)(e.by)," ",e.by,'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 probe':'',e.ok?'':' \xb7 OUT OF RANGE']})]}),e.corrective?(0,m.jsxs)(l.T,{size:13,colour:c.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,m.jsxs)(l.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,m.jsx)(n.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function S({editable:e}){const n=(0,r.useSafety)(e=>e.points),[s,o]=(0,t.useState)('');return(0,m.jsxs)(h.Box,{testID:"haccp-limits",children:[(0,m.jsx)(l.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,m.jsx)(l.Muted,{children:e?'Set the limits from your own HACCP plan. Leave min or max empty if it doesn\u2019t apply. Due times are daily reminders (24 h, comma separated).':'Set by the Head Chef in Cover Charge for Head Chef.'}),n.map(t=>(0,m.jsx)(T,{p:t,editable:e,onSaved:()=>o(`Saved limits for ${t.name}.`)},t.id)),e?(0,m.jsx)(D,{onAdded:e=>o(`Added ${e}.`)}):null,s?(0,m.jsx)(l.T,{size:14,colour:c.colours.green,children:s}):null]})}function T({p:e,editable:n,onSaved:s}){const[u,h]=(0,t.useState)(null==e.min?'':String(e.min)),[p,x]=(0,t.useState)(null==e.max?'':String(e.max)),[b,f]=(0,t.useState)(e.due.join(', ')),j=(0,d.isTempKind)(e.kind),w=''===b.trim()||b.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),v=u!==(null==e.min?'':String(e.min))||p!==(null==e.max?'':String(e.max))||b!==e.due.join(', '),k=w&&(''===u||null!=y(u))&&(''===p||null!=y(p));return n?(0,m.jsxs)(i.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},testID:`limit-${e.id}`,children:[(0,m.jsxs)(l.T,{weight:"medium",children:[e.name," ",(0,m.jsxs)(l.Muted,{children:["\xb7 ",d.KIND_LABEL[e.kind]]})]}),(0,m.jsxs)(l.Row,{wrap:!0,gap:8,children:[j?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(o.default,{accessibilityLabel:`Minimum for ${e.name}`,value:u,onChangeText:h,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[l.styles.input,{width:90}]}),(0,m.jsx)(o.default,{accessibilityLabel:`Maximum for ${e.name}`,value:p,onChangeText:x,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[l.styles.input,{width:90}]})]}):null,(0,m.jsx)(o.default,{accessibilityLabel:`Due times for ${e.name}`,value:b,onChangeText:f,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{flex:1,minWidth:140,width:40}]}),v?(0,m.jsx)(l.Button,{small:!0,label:"Save",disabled:!k,onPress:()=>{r.useSafety.getState().setPoint(e.id,{min:''===u?void 0:y(u),max:''===p?void 0:y(p),due:b.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),w?null:(0,m.jsx)(l.T,{size:13,colour:c.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,m.jsxs)(l.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,m.jsx)(l.T,{size:14,style:{flex:1},children:e.name}),(0,m.jsxs)(l.Muted,{children:[(0,d.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function D({onAdded:e}){const[n,s]=(0,t.useState)(''),[u,h]=(0,t.useState)('fridge');return(0,m.jsxs)(i.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,m.jsx)(l.T,{weight:"medium",children:"Add a check point"}),(0,m.jsx)(o.default,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,m.jsx)(l.Row,{wrap:!0,gap:6,children:Object.keys(d.KIND_LABEL).map(e=>(0,m.jsx)(l.Chip,{label:d.KIND_LABEL[e],selected:e===u,onPress:()=>h(e)},e))}),(0,m.jsx)(l.Button,{small:!0,label:"Add check point",disabled:!n.trim(),onPress:()=>{const t='fridge'===u?{max:5}:'freezer'===u?{max:-18}:'cook'===u?{min:75}:'hothold'===u?{min:63}:'cool'===u||'delivery'===u?{max:8}:{};r.useSafety.getState().addPoint({name:n.trim(),kind:u,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function I({me:e,now:n}){const s=(0,r.useSafety)(e=>e.probes??[]),d=(0,r.useSafety)(e=>e.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),[u,p]=(0,t.useState)(!1),[x,b]=(0,t.useState)(''),[y,f]=(0,t.useState)(''),[j,w]=(0,t.useState)(null),[v,k]=(0,t.useState)(''),C=d.find(e=>e.id===y);return(0,m.jsxs)(h.Box,{testID:"haccp-probes",children:[(0,m.jsx)(l.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,m.jsx)(l.Muted,{children:"Wireless fridge and freezer probes. Once a probe is connected, its readings go into the food safety log tagged \u201cprobe\u201d with the time they were taken. Out-of-range probe readings still need a corrective action from a person."}),s.length?s.map(e=>(0,m.jsxs)(i.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border},children:[(0,m.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(i.default,{style:{flex:1,gap:2},children:[(0,m.jsx)(l.T,{weight:"semibold",children:e.name}),(0,m.jsx)(l.Muted,{children:e.location})]}),(0,m.jsx)(l.Badge,{kind:'connected'===e.status?'green':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,m.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(l.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>w(j===e.id?null:e.id)}),(0,m.jsx)(l.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>r.useSafety.getState().removeProbe(e.id)})]}),j===e.id?(0,m.jsxs)(i.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:c.colours.gold},children:[(0,m.jsx)(l.T,{weight:"semibold",children:"Connect your probe"}),(0,m.jsxs)(l.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,m.jsx)(l.T,{size:14,children:"2. Keep this device near the probe."}),(0,m.jsx)(l.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,m.jsx)(l.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>k(`No probe found for ${e.name}. Probe hardware isn\u2019t available in the prototype yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,m.jsx)(i.default,{testID:"probes-empty",children:(0,m.jsx)(l.Muted,{children:"No probes yet."})}),v?(0,m.jsx)(i.default,{testID:"probe-msg",children:(0,m.jsx)(l.Banner,{kind:"info",children:v})}):null,u?(0,m.jsxs)(i.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:c.colours.gold},children:[(0,m.jsx)(o.default,{accessibilityLabel:"Probe name",value:x,onChangeText:b,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0}]}),(0,m.jsx)(l.Muted,{children:"Where is it?"}),(0,m.jsx)(l.Row,{wrap:!0,gap:6,children:d.map(e=>(0,m.jsx)(l.Chip,{label:e.name,selected:y===e.id,onPress:()=>f(e.id)},e.id))}),(0,m.jsxs)(l.Row,{gap:8,children:[(0,m.jsx)(l.Button,{label:"Save probe",disabled:!x.trim()||!C,onPress:()=>{x.trim()&&C&&(r.useSafety.getState().addProbe({name:x.trim(),pointId:C.id,location:C.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),k(`Added \u201c${x.trim()}\u201d for ${C.name}. Next: connect your probe.`),b(''),f(''),p(!1))}}),(0,m.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>p(!1)})]})]}):(0,m.jsx)(l.Button,{kind:"secondary",label:"Add probe",onPress:()=>{p(!0),k('')}}),(0,m.jsx)(l.Muted,{children:"Demo: no probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},918,[12,178,245,255,109,791,977,980,799,898,1131,1134,6]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.styliseOnDevice=p,_e.pickPhoto=b,_e.AvatarMaker=function({meId:e,me:h}){const u=(0,n.useAvatars)(t=>t.photos[e]),[g,f]=(0,t.useState)(null),[v,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,I]=(0,t.useState)(!1),[P,k]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{g&&URL.revokeObjectURL(g)},[g]);const M='undefined'!=typeof document,R=async e=>{k('');const t=await b(e);if(t){I(!0),j(!1);try{const e=await p(t);g&&URL.revokeObjectURL(g),f(URL.createObjectURL(t)),y(e)}catch{k("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{I(!1)}}},S=()=>{g&&URL.revokeObjectURL(g),f(null),y(null),j(!1)},C=h.replace(' (example)','');return(0,c.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,c.jsxs)(d.Box,{children:[(0,c.jsxs)(s.Row,{gap:14,children:[(0,c.jsx)(l.StaffAvatar,{id:e,size:88}),(0,c.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,c.jsx)(s.T,{weight:"semibold",size:17,children:C}),(0,c.jsxs)(s.Muted,{children:[u?`Your avatar from a photo (made ${new Date(u.at).toLocaleDateString('en-GB')}).`:'Your default space-age avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),u?(0,c.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{n.useAvatars.getState().reset(e,{id:e,role:'staff',name:C}),k('Back to your default avatar.')}}):null]}),(0,c.jsxs)(d.Box,{testID:"avatar-create",children:[(0,c.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,c.jsx)(s.Muted,{children:"Upload a photo or take a selfie. Your phone turns it into a retro space-age avatar. The photo never leaves this device and isn't saved: only the finished avatar is kept."}),M?v?(0,c.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,c.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,c.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[g?(0,c.jsx)(a.default,{source:{uri:g},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,c.jsx)(s.Muted,{children:"Your photo"})]}),(0,c.jsx)(s.T,{size:22,colour:i.colours.gold,children:"\u2192"}),(0,c.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,c.jsx)(a.default,{source:{uri:v},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:i.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,c.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,c.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:x},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>j(!x),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:x?i.colours.gold:i.colours.border},children:[(0,c.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:i.colours.gold,backgroundColor:x?i.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:x?(0,c.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,c.jsx)(s.T,{size:14,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in Cover Charge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!x,onPress:()=>{const t=n.useAvatars.getState().setOwn(e,e,v,C);k(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&S()}}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:S})]})]}):(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:w?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:w,onPress:()=>R(!1)}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:w,onPress:()=>R(!0)})]}):(0,c.jsx)(s.Muted,{children:"Available in the web app."}),P?(0,c.jsx)(o.default,{testID:"avatar-msg",children:(0,c.jsx)(s.T,{size:14,colour:i.colours.green,children:P})}):null,(0,c.jsx)(s.Banner,{kind:"info",title:"Coming soon: AI avatars",children:"A future version will use AI to draw you as a full cartoon in the same style. For now it's a simple filter that runs on your phone."})]})]})};var t=_r(_d[0]),a=e(_r(_d[1]));_r(_d[2]);var r=e(_r(_d[3])),o=e(_r(_d[4])),s=_r(_d[5]),l=_r(_d[6]),n=_r(_d[7]),i=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]);const h=['#1B1B2F','#1F6F78','#C8553D','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),u=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function g(e){return new Promise((t,a)=>{const r=URL.createObjectURL(e),o=new window.Image;o.onload=()=>t({img:o,url:r}),o.onerror=()=>{URL.revokeObjectURL(r),a(new Error('bad image'))},o.src=r})}function f(e,t,a,r){e.beginPath(),e.moveTo(t,a-r),e.quadraticCurveTo(t+.18*r,a-.18*r,t+r,a),e.quadraticCurveTo(t+.18*r,a+.18*r,t,a+r),e.quadraticCurveTo(t-.18*r,a+.18*r,t-r,a),e.quadraticCurveTo(t-.18*r,a-.18*r,t,a-r),e.fill()}async function p(e){const{img:t,url:a}=await g(e);try{const e=112,a=256,r=document.createElement('canvas');r.width=e,r.height=e;const o=r.getContext('2d'),s=Math.min(t.width,t.height);o.drawImage(t,(t.width-s)/2,Math.max(0,(t.height-s)/2-.04*s),s,s,0,0,e,e);const l=o.getImageData(0,0,e,e),n=l.data,i=[];for(let e=0;ee-t),c=d[Math.floor(.04*d.length)],g=d[Math.floor(.96*d.length)]||255;for(let t=0;t{const a=document.createElement('input');a.type='file',a.accept='image/*',e&&a.setAttribute('capture','user'),a.onchange=()=>t(a.files?.[0]??null),a.click()})}},919,[12,178,104,245,109,791,898,1089,799,1131,6]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"isUuid",{enumerable:!0,get:function(){return t}});const x=()=>globalThis.crypto&&'randomUUID'in globalThis.crypto?globalThis.crypto.randomUUID():'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,x=>{const t=16*Math.random()|0;return('x'===x?t:3&t|8).toString(16)}),t=x=>'string'==typeof x&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(x)},920,[]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"RID",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return d}}),_e.nextStatus=function(e){return'new'===e.status||'acknowledged'===e.status?{to:'preparing',label:'Start preparing'}:'preparing'===e.status?{to:'ready',label:'takeaway'===e.type?'Mark ready (notify customer)':'Mark ready'}:'ready'===e.status?'takeaway'===e.type?{to:'collected',label:'Collected'}:{to:'served',label:'Served'}:null},Object.defineProperty(_e,"LIVE",{enumerable:!0,get:function(){return a}}),_e.busyLevel=b,_e.restOfDayLevel=function(e,r){const t=e.hours.filter(r=>!e.nextHour||r.hour>=e.nextHour.hour).reduce((e,r)=>!e||r.covers>e.covers?r:e,void 0);return{level:b(t?.covers??0,r.settings.capacityPerHour),peak:t}},_e.Tile=function({label:e,value:n,sub:c,onPress:u,accent:d,children:a}){const b=(0,s.jsxs)(t.default,{style:{flexGrow:1,flexBasis:150,backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{size:13,weight:"medium",colour:o.colours.muted,children:e}),(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}),c?(0,s.jsx)(l.T,{size:13,colour:o.colours.muted,children:c}):null,a]});return u?(0,s.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:e,onPress:u,style:{flexGrow:1,flexBasis:150},children:b}):b},_e.SectionHead=function({title:e,right:r,sub:n}){return(0,s.jsxs)(t.default,{style:{gap:2,marginTop:6},children:[(0,s.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,children:e}),r]}),n?(0,s.jsx)(l.Muted,{children:n}):null]})},_e.AlertBox=function({colour:e,title:r,children:n}){return(0,s.jsxs)(t.default,{style:{backgroundColor:o.colours.surface2,borderRadius:12,padding:10,borderLeftWidth:6,borderLeftColor:e,gap:6},children:[(0,s.jsx)(l.T,{weight:"bold",colour:e,children:r}),n]})},_e.Bars=function({data:e,max:r,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const u=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(t.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:u?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(t.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(t.default,{style:{height:Math.max(0,e.b/r*c),backgroundColor:u?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(t.default,{style:{height:Math.max(d?2:0,e.a/r*c),backgroundColor:u?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:u?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return f}}),_r(_d[0]);var r=e(_r(_d[1])),t=e(_r(_d[2])),l=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),s=_r(_d[6]);const c=n.VENUE_RID,u=e=>'new'===e?'red':'ready'===e?'green':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const a=e=>!['collected','served','closed','cancelled'].includes(e.status);function b(e,r){const t=r?e/r:0;return t<.35?{label:'Quiet',colour:o.colours.green,pct:t}:t<.6?{label:'Steady',colour:o.colours.blue,pct:t}:t<.85?{label:'Busy',colour:o.colours.amber,pct:t}:{label:'Very busy',colour:o.colours.red,pct:t}}const f=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},921,[12,245,109,791,799,856,6]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"venueInfo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"useVenueInfo",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(t,n)=>{const r=n?.name??'Your venue',u=n?.location??'';return{rid:t,name:r,place:u,address:n?.address??[r,u].filter(Boolean).join(', '),tag:'#'+r.replace(/[^A-Za-z0-9]/g,'')}},s=s=>{const o=s??n.useOwner.getState().site??r.VENUE_RID;return u(o,t.useStore.getState().restaurants.find(t=>t.id===o))},o=s=>{const o=(0,n.useOwner)(t=>t.site),c=s??o??r.VENUE_RID,f=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,f)}},922,[855,813,856]); +__d(function(g,_r,i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.gamesOn=function(){const e=y.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.usePlayable=k,Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return j}}),_e.gameBase=function(){const e=y.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return j(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:r,now:n}){const s=(0,y.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,t.useState)(!1),u=k(e,n);return s?(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"\u2615 Break room"}),(0,w.jsx)(c.T,{size:13,colour:u?b.colours.green:b.colours.muted,children:u?'Open':'Opens on your break'})]}),(0,w.jsx)(c.Muted,{children:"Lenny\u2019s Kitchen Chaos, with the team as characters and a shared leaderboard. Playable on a break or when you\u2019re not clocked in."}),(0,w.jsx)(c.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(S,{staffId:e,name:r,playable:u,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return x}}),_e.BreakRoom=S;var t=_r(_d[0]),r=e(t),n=e(_r(_d[1]));_r(_d[2]);var s=e(_r(_d[3])),o=e(_r(_d[4])),l=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),y=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),h=_r(_d[13]),b=_r(_d[14]),w=_r(_d[15]);function k(e,t){const r=(0,d.useOwner)(e=>e.attendance);if(!e)return!0;const n=(0,d.openShiftOf)(r,e,t);return!n||(0,d.isOnBreak)(n)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',j=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function I(e){if('undefined'==typeof window)return null;const t=new URL(e);for(const e of['demo','unlock','name','staffId'])t.searchParams.delete(e);return t.searchParams.set('host','covercharge'),t.searchParams.set('hostOrigin',window.location.origin),{src:t.toString(),origin:t.origin}}const x=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function S({staffId:e,name:k,playable:S,onClose:R}){const E=(0,d.useOwner)(e=>e.staff),C=(0,u.useAvatars)(e=>e.photos),P=(0,f.useSetup)(e=>e.looks),O=(0,t.useRef)(null),[T,M]=(0,t.useState)({}),[U,L]=(0,t.useState)(!1),[_,B]=(0,t.useState)(null),N=(0,y.useStore)(e=>j(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),D=(0,t.useMemo)(()=>I(N),[N]),$=D?.origin??'',q=(0,h.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),A=!(!q||!e||q===e),z=A?null:q??e??null,V=x(k),[H,G]=(0,t.useState)(''),W=(0,t.useRef)(null),F=(0,t.useRef)(0),K=(0,t.useRef)(null),Y=(0,t.useRef)(S);Y.current=S;const J=(0,t.useMemo)(()=>E.filter(e=>e.active&&!e.name.includes('(example)')),[E]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const t of J){const r=document.getElementById(`cc-av-${t.id}`)?.querySelector('svg');r&&(e[t.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r.outerHTML.includes('xmlns')?r.outerHTML:r.outerHTML.replace('clearTimeout(e)},[J,P]);const Q=(0,t.useMemo)(()=>J.map(e=>{const t=C[e.id]?.dataUrl??T[e.id],r={id:e.id,name:x(e.name),role:e.job||e.level||e.role};return t&&(r.avatarUrl=t),r}),[J,C,T]),X=(0,t.useCallback)(e=>{try{$&&O.current?.contentWindow?.postMessage(e,$)}catch{}},[$]);return(0,t.useEffect)(()=>{const e=async e=>{if(!$||e.origin!==$||e.source!==O.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return B('string'==typeof t.version?String(t.version).slice(0,12):null),void L(!0);const r=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&X({type:'lenny:scores:result',reqId:t.reqId,result:await(0,m.listScores)(r,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!z||'string'==typeof e.staffId&&e.staffId!==z)return void X({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,m.listScores)(r,10),id:null}});const n='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;X({type:'lenny:scores:result',reqId:t.reqId,result:await(0,m.submitScore)(r,{score:Number(e.score)||0,stars:Number(e.stars)||0,badges:Array.isArray(e.badges)?e.badges.map(String).slice(0,30):[],stats:'object'==typeof e.stats&&e.stats?e.stats:{},characterId:n,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:z,name:V})})}'lenny:roundAbandoned'===t.type&&G('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&G(''),'lenny:progress'===t.type&&z&&t.staffId===z&&(0,m.saveProgress)(z,t.progress)};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[X,z,V,$]),(0,t.useEffect)(()=>{L(!1),W.current=null,K.current=null},[D?.src]),(0,t.useEffect)(()=>{if(!U)return;const e=e=>{K.current!==e&&(K.current=e,X({type:'lenny:setPlayable',playable:e}))},t=A?null:`${z??''}|${V}`;if(t&&W.current===t)return void e(S);const r=++F.current;W.current=null,K.current&&e(!1),t&&(0,m.loadProgress)(z).catch(()=>null).then(n=>{r===F.current&&(X({type:'lenny:setPlayer',name:V,staffId:z,...n?{progress:n}:{}}),W.current=t,e(Y.current))})},[U,A,z,V,S,X]),(0,t.useEffect)(()=>{U&&X({type:'lenny:setRoster',staff:Q})},[U,Q,X]),(0,w.jsx)(n.default,{visible:!0,animationType:"slide",onRequestClose:R,children:(0,w.jsxs)(o.default,{testID:"break-room",style:{flex:1,backgroundColor:'#000'},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:b.colours.bg},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"\u2615 Break room"}),(0,w.jsx)(o.default,{testID:S&&!A?'break-playable':'break-locked',accessibilityLabel:_?`Game version ${_}`:void 0,children:(0,w.jsx)(c.T,{size:13,colour:S?b.colours.green:b.colours.gold,children:A?'Switching player\u2026':S?'On your break: enjoy!':'Back to work! Start a break to play.'})}),(0,w.jsx)(s.default,{testID:"break-room-close",accessibilityRole:"button",onPress:R,style:{padding:6},children:(0,w.jsx)(c.T,{weight:"semibold",colour:b.colours.gold,children:"Close"})})]}),H?(0,w.jsx)(o.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:b.colours.surface},children:(0,w.jsx)(c.T,{size:13,colour:b.colours.muted,children:H})}):null,D?r.default.createElement('iframe',{ref:O,src:D.src,key:D.src,title:'Lenny\u2019s Kitchen Chaos','data-testid':'break-game',allow:'autoplay; fullscreen',style:{flex:1,width:'100%',height:'100%',border:0,background:'#000'}}):(0,w.jsx)(o.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(o.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:J.map(e=>(0,w.jsx)(o.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(l.AvatarArt,{spec:null!=P[e.id]?(0,l.specFor)(`${e.id}#look${P[e.id]}`):(0,l.specFor)(e.id,e.name),size:96})},e.id))})]})})}},923,[12,238,104,245,109,898,791,1089,813,1090,855,856,1123,798,799,6]); +__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return n.useStore}}),_e.useNow=function(e=1e4){const r=(0,n.useStore)(e=>e.clock),[,u]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=setInterval(()=>u(e=>e+1),e);return()=>clearInterval(t)},[e]),(0,n.nowFrom)(r)},Object.defineProperty(_e,"useRestaurant",{enumerable:!0,get:function(){return a}}),_e.useRecipeCards=c,_e.useAllMenu=f,_e.useMenu=function(e){const r=f(e);return(0,t.useMemo)(()=>r.filter(e=>!e.hidden),[r])},Object.defineProperty(_e,"useCustomer",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useBasket",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useOrders",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"useOrderAtTable",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useOrder",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"useBookings",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useWaitlist",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useEvents",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"useStampCard",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"useGiftCards",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useRatings",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"useAudit",{enumerable:!0,get:function(){return v}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),n=_r(_d[3]),u=_r(_d[4]),s=_r(_d[5]),o=_r(_d[6]);_r(_d[7]);const a=e=>(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)),l=e=>(0,o.recipeCards)().subscribe(e),d=[];function c(e){return(0,t.useSyncExternalStore)(l,()=>e?(0,o.recipeCards)().list(e):d,()=>e?(0,o.recipeCards)().list(e):d)}function f(e){const u=(0,n.useStore)((0,r.useShallow)(t=>t.menu.filter(t=>t.restaurantId===e))),o=c(e);return(0,t.useMemo)(()=>(0,s.resolveMenu)(u),[u,o])}const b=()=>(0,n.useStore)(e=>e.customer),S=()=>(0,n.useStore)(e=>e.basket),g=(e,t)=>'table'!==t.type||(0,u.orderAtTableOn)(e.restaurants.find(e=>e.id===t.restaurantId)),m=e=>(0,n.useStore)((0,r.useShallow)(t=>t.orders.filter(r=>(!e||r.restaurantId===e)&&g(t,r)))),p=e=>(0,n.useStore)(t=>(0,u.orderAtTableOn)(t.restaurants.find(t=>t.id===e))),O=e=>(0,n.useStore)(t=>t.orders.find(t=>t.id===e)),y=e=>(0,n.useStore)((0,r.useShallow)(t=>e?t.bookings.filter(t=>t.restaurantId===e):t.bookings)),w=e=>(0,n.useStore)((0,r.useShallow)(t=>t.waitlist.filter(t=>t.restaurantId===e))),I=[],j=u=>{const s=(0,n.useStore)((0,r.useShallow)(e=>e.events.filter(e=>null===e.restaurantId||e.restaurantId===u))),o=(0,n.useStore)(e=>e.restaurants.find(e=>e.id===u)),a=o?(0,e.regularEventsOf)(o):I,l=(new Date).toISOString().slice(0,7);return(0,t.useMemo)(()=>{if(!u||!a.length)return s;const t=new Date,r=new Date(t.getFullYear(),t.getMonth()-2,1),n=new Date(t.getFullYear()+1,t.getMonth()+1,0),o=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`;return[...s,...(0,e.expandEvents)(u,a,o(r),o(n))]},[s,a,u,l])},P=e=>(0,n.useStore)(t=>t.stampCards.find(r=>r.restaurantId===e&&r.customerId===t.customer.id)),h=e=>(0,n.useStore)((0,r.useShallow)(t=>t.giftCards.filter(r=>(!e||r.restaurantId===e)&&r.ownerId===t.customer.id))),M=e=>(0,n.useStore)((0,r.useShallow)(t=>t.ratings.filter(t=>t.restaurantId===e))),v=e=>(0,n.useStore)((0,r.useShallow)(t=>t.audit.filter(t=>t.restaurantId===e)))},924,[789,12,857,855,1022,978,808,1023]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getCameraPermissionsAsync=l,_e.getMediaLibraryPermissionsAsync=y,_e.requestCameraPermissionsAsync=f,_e.requestMediaLibraryPermissionsAsync=b,Object.defineProperty(_e,"useMediaLibraryPermissions",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"useCameraPermissions",{enumerable:!0,get:function(){return w}}),_e.getPendingResultAsync=async function(){if(s.default.getPendingResultAsync)return s.default.getPendingResultAsync();return null},_e.launchCameraAsync=async function(e={}){if(!s.default.launchCameraAsync)throw new n.UnavailabilityError('ImagePicker','launchCameraAsync');const t=(0,o.mapDeprecatedOptions)(e);return await s.default.launchCameraAsync(c(t))},_e.launchImageLibraryAsync=async function(e={}){const t=(0,o.mapDeprecatedOptions)(e);if(!s.default.launchImageLibraryAsync)throw new n.UnavailabilityError('ImagePicker','launchImageLibraryAsync');t?.allowsEditing&&t.allowsMultipleSelection&&console.warn("[expo-image-picker] `allowsEditing` is not supported when `allowsMultipleSelection` is enabled and will be ignored.Disable either 'allowsEditing' or 'allowsMultipleSelection' in 'launchImageLibraryAsync' to fix this warning.");return await s.default.launchImageLibraryAsync(t)},Object.defineProperty(_e,"PermissionStatus",{enumerable:!0,get:function(){return n.PermissionStatus}});var e,n=r(d[0]),t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),u=r(d[3]);function c(e){const{aspect:t,quality:s,videoMaxDuration:o}=e;if(null!=t){const[e,s]=t;if(e<=0||s<=0)throw new n.CodedError('ERR_INVALID_ARGUMENT',`Invalid aspect ratio values ${e}:${s}. Provide positive numbers.`)}if(s&&(s<0||s>1))throw new n.CodedError('ERR_INVALID_ARGUMENT',`Invalid 'quality' value ${s}. Provide a value between 0 and 1.`);if(o&&o<0)throw new n.CodedError('ERR_INVALID_ARGUMENT',`Invalid 'videoMaxDuration' value ${o}. Provide a non-negative number.`);return e}async function l(){return s.default.getCameraPermissionsAsync()}async function y(e=!1){return s.default.getMediaLibraryPermissionsAsync(e)}async function f(){return s.default.requestCameraPermissionsAsync()}async function b(e=!1){return(0,s.default.requestMediaLibraryPermissionsAsync)(e)}Object.keys(u).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return u[e]}})});const P=(0,n.createPermissionHook)({getMethod:e=>y(e?.writeOnly),requestMethod:e=>b(e?.writeOnly)}),w=(0,n.createPermissionHook)({getMethod:l,requestMethod:f})},925,[552,1144,1146,1145]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_ROLES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return l}});var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[1]),c=r(d[2]);const p=['owner','manager','staff','chef','display'],f={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (basic: team chat, my shift, specials)',chef:'Head Chef app',display:'Main Display'},o=(0,s.create)()((0,c.persist)(e=>({enabled:{},micExplained:!1,speakAnswers:!0,setEnabled:(n,t,s)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:s}}})),setMicExplained:n=>e({micExplained:n}),setSpeak:n=>e({speakAnswers:n})}),{name:'covercharge-voice-v1',version:1,storage:(0,c.createJSONStorage)(()=>t.default)})),l=(e,n,t)=>!1!==e[n]?.[t]},973,[975,974,976]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},974,[1010,1011]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAsyncStorage",{enumerable:!0,get:function(){return n.useAsyncStorage}}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return o}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=u.default},975,[1005,1009]); +__d(function(g,_r,i,_a3,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"combine",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"createJSONStorage",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"devtools",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"persist",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"redux",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"subscribeWithSelector",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"unstable_ssrSafe",{enumerable:!0,get:function(){return S}});const e=(e,t)=>(n,r,o)=>(o.dispatch=t=>(n(n=>e(n,t),!1,t),t),o.dispatchFromDevtools=!0,{dispatch:(...e)=>o.dispatch(...e),...t}),t=e=>!!e.dispatchFromDevtools&&"function"==typeof e.dispatch,n=new Map,r=e=>{const t=n.get(e);return t?Object.fromEntries(Object.entries(t.stores).map(([e,t])=>[e,t.getState()])):{}},o=(e,t,r)=>{if(void 0===e)return{type:"untracked",connection:t.connect(r)};const o=n.get(r.name);if(o)return{type:"tracked",store:e,...o};const s={connection:t.connect(r),stores:{}};return n.set(r.name,s),{type:"tracked",store:e,...s}},s=(e,t,r)=>{if(void 0===t)return;const o=n.get(e);(null==o?void 0:o.stores[t])===r&&(delete o.stores[t],0===Object.keys(o.stores).length&&n.delete(e))},a=/^at (?:new |async )?(.+?) \(/,l=/^([^@]+)@/;function c(e){var t,n,r;if(!e)return;const o=e.split("\n"),s=o.findIndex(e=>e.includes("api.setState"));if(s<0)return;const c=(null==(t=o[s+1])?void 0:t.trim())||"";return(null==(n=a.exec(c))?void 0:n[1])||(null==(r=l.exec(c))?void 0:r[1])}const u=(e,a={})=>(l,u,p)=>{const{enabled:f,anonymousActionType:y,store:h,...b}=a;let S;try{S=(null!=f?f:"production"!==(globalThis.__ExpoImportMetaRegistry.env?globalThis.__ExpoImportMetaRegistry.env.MODE:void 0))&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!S)return e(l,u,p);const{connection:O,..._}=o(h,S,b);let w,E=!0;p.setState=(e,t,n)=>{const o=l(e,t);if(!E)return o;const s=void 0===n?{type:y||c((new Error).stack)||"anonymous"}:"string"==typeof n?{type:n}:n;return void 0===h?(null==O||O.send(s,u()),o):(null==O||O.send({...s,type:`${h}/${s.type}`},{...r(b.name),[h]:p.getState()}),o)},p.devtools={cleanup:()=>{null==w||w(),w=void 0,s(b.name,h,p),void 0!==h&&n.has(b.name)||!O||"function"!=typeof O.unsubscribe||O.unsubscribe()}};const I=(...e)=>{const t=E;E=!1,l(...e),E=t},j=e(p.setState,u,p);if("untracked"===_.type?null==O||O.init(j):(_.stores[_.store]=p,null==O||O.init(Object.fromEntries(Object.entries(_.stores).map(([e,t])=>[e,e===_.store?j:t.getState()])))),t(p)){let e=!1;const t=p.dispatch;p.dispatch=(...n)=>{"production"===(globalThis.__ExpoImportMetaRegistry.env?globalThis.__ExpoImportMetaRegistry.env.MODE:void 0)||"__setState"!==n[0].type||e||(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),e=!0),t(...n)}}return w=O.subscribe(e=>{var n;const o="object"==typeof b.serialize?b.serialize.reviver:void 0;switch(e.type){case"ACTION":return"string"!=typeof e.payload?void console.error("[zustand devtools middleware] Unsupported action format"):v(e.payload,o,e=>{if("__setState"===e.type){if(void 0===h)return void I(e.state);1!==Object.keys(e.state).length&&console.error("\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n ");const t=e.state[h];if(null==t)return;return void(JSON.stringify(p.getState())!==JSON.stringify(t)&&I(t))}t(p)&&p.dispatch(e)});case"DISPATCH":switch(e.payload.type){case"RESET":return I(j),void 0===h?null==O?void 0:O.init(p.getState()):null==O?void 0:O.init(r(b.name));case"COMMIT":return void 0===h?void(null==O||O.init(p.getState())):null==O?void 0:O.init(r(b.name));case"ROLLBACK":return v(e.state,o,e=>{if(void 0===h)return I(e),void(null==O||O.init(p.getState()));I(e[h]),null==O||O.init(r(b.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return v(e.state,o,e=>{void 0!==h?JSON.stringify(p.getState())!==JSON.stringify(e[h])&&I(e[h]):I(e)});case"IMPORT_STATE":{const{nextLiftedState:t}=e.payload,r=null==(n=t.computedStates.slice(-1)[0])?void 0:n.state;if(!r)return;return I(void 0===h?r:r[h]),void(null==O||O.send(null,t))}case"PAUSE_RECORDING":return E=!E}return}}),j},v=(e,t,n)=>{let r;try{r=JSON.parse(e,t)}catch(e){console.error("[zustand devtools middleware] Could not parse the received json",e)}void 0!==r&&n(r)},p=e=>(t,n,r)=>{const o=r.subscribe;r.subscribe=(e,t,n)=>{let s=e;if(t){const o=(null==n?void 0:n.equalityFn)||Object.is;let a=e(r.getState());s=n=>{const r=e(n);if(!o(a,r)){const e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return o(s)};return e(t,n,r)};function f(e,t){return(...n)=>Object.assign({},e,t(...n))}function y(e,t){let n;try{n=e()}catch(e){return}return{getItem:e=>{var r;const o=e=>null===e?null:JSON.parse(e,null==t?void 0:t.reviver),s=null!=(r=n.getItem(e))?r:null;return s instanceof Promise?s.then(o):o(s)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,null==t?void 0:t.replacer)),removeItem:e=>n.removeItem(e)}}const h=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>h(e)(n),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>h(t)(e)}}},b=(e,t)=>(n,r,o)=>{let s={storage:y(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},a=!1,l=0;const c=new Set,u=new Set;let v=s.storage;if(!v)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...e)},r,o);const p=()=>{const e=s.partialize({...r()});return v.setItem(s.name,{state:e,version:s.version})},f=o.setState;o.setState=(...e)=>(f(...e),p());const b=e((...e)=>(n(...e),p()),r,o);let S;o.getInitialState=()=>b;const O=()=>{var e,t;if(!v)return;const o=++l;a=!1,c.forEach(e=>{var t;return e(null!=(t=r())?t:b)});const f=(null==(t=s.onRehydrateStorage)?void 0:t.call(s,null!=(e=r())?e:b))||void 0;return h(v.getItem.bind(v))(s.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===s.version)return[!1,e.state];if(s.migrate){const t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(o!==l)return;const[a,c]=e;return S=s.merge(c,null!=(t=r())?t:b),n(S,!0),a?p():void 0}).then(()=>{o===l&&(null==f||f(r(),void 0),S=r(),a=!0,u.forEach(e=>e(S)))}).catch(e=>{o===l&&(null==f||f(void 0,e))})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(v=e.storage)},clearStorage:()=>{++l,null==v||v.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>O(),hasHydrated:()=>a,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(u.add(e),()=>{u.delete(e)})},s.skipHydration||O(),S||b};function S(e,t="undefined"==typeof window){return(n,r,o)=>{if(!t)return e(n,r,o);const s=()=>{throw new Error("Cannot set state of Zustand store in SSR")};return o.setState=s,e(s,r,o)}}},976,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ACCIDENT_CATEGORIES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return u}});var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},a=r(_d[1]),o=r(_d[2]),s=r(_d[3]);const d=['Near miss','Slip, trip or fall','Cut','Burn or scald','Manual handling','Struck by an object','Allergic reaction','Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days','Other'],c=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let l=0;const p=e=>`${e}-${Date.now().toString(36)}${(l++).toString(36)}`,f=(e,t,n)=>({id:e,when:t,location:'',person:'',personType:'Staff',category:'Near miss',what:'',injury:'None',firstAid:'None needed',witnesses:'',reportedBy:'',reportedById:'',app:'staff',createdAt:`${t}:00`,...n});function y(){const e=new Date,t=(t,n)=>{const a=new Date(e);return a.setDate(a.getDate()-t),`${a.toISOString().slice(0,10)}T${n}`};return[f('acc-ex1',t(3,'19:40'),{location:'Kitchen pass',person:'Server (example)',category:'Near miss',what:'Example: water on the floor by the pass after the glass washer leaked. Nobody slipped.',firstAid:'None needed',witnesses:'Bar (example)',reportedBy:'Server (example)',reportedById:'st-4',app:'staff'}),f('acc-ex2',t(6,'12:15'),{location:'Kitchen: fryer section',person:'Head Chef (example)',category:'Burn or scald',what:'Example: splash of hot oil on the back of the hand while changing the basket.',injury:'Small burn, back of left hand',firstAid:'Cooled under running water for 20 minutes, sterile dressing',witnesses:'None',reportedBy:'Head Chef (example)',reportedById:'st-3',app:'chef'})]}const u=(0,a.create)()((0,o.persist)(e=>({points:s.DEFAULT_POINTS,entries:[],accidents:y(),probes:[],diary:[],daySigns:[],weekly:[],addNote:t=>e(e=>({diary:[{...t,id:p('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:p('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:p('pr'),status:'not-connected'}]})),removeProbe:t=>e(e=>({probes:(e.probes??[]).filter(e=>e.id!==t)})),addEntries:t=>e(e=>({entries:[...t.map(e=>({...e,id:p('hc')})),...e.entries]})),setPoint:(t,n)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...n}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:p('cp')}]})),resetPoints:()=>e({points:s.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:p('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,n)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:n}:e)}))}),{name:'covercharge-safety-v1',storage:(0,o.createJSONStorage)(()=>n.default),version:2,migrate:(e,t)=>{if(e&&t<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...s.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e}}))},977,[975,974,976,980]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"setMenuCardBridge",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"menuCardBridge",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"resolveItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveMenu",{enumerable:!0,get:function(){return l}});var t=r(d[0]);let n=null;const u=t=>{n=t},o=()=>n,c=u=>(0,t.overlayItem)(u,n?.cardFor(u.id)),l=t=>t.map(c)},978,[1017]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(s,o,r,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,t.lastFoodOn)(s,m),d=f?new Date(`${m}T${f.time}:00`):null,c=t=>r.filter(a=>a.date===m&&'confirmed'===a.status&&(a.table??'').split('+').map(t=>t.trim()).includes(t)).map(t=>new Date(`${t.date}T${t.time}:00`)).filter(t=>t>=n(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],g=[],b=[];for(const r of Object.values(o)){const o=r.table.name,m=c(o);if('free'===r.status){(!m||m>n(l,60))&&g.push(o);continue}if(!a.includes(r.status)||!r.booking)continue;const f=r.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,t.dwellFor)(s,f.partySize,u);let w=n(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===r.status?(w=n(l,10),T='likely',p='bill requested'):'dessert'===r.status?(w=new Date(Math.min(w.getTime(),n(l,25).getTime())),T='likely',p='on dessert'):'mains'===r.status&&(w=new Date(Math.min(Math.max(w.getTime(),n(l,35).getTime()),n(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}b.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(o).filter(t=>'blocked'!==t.status).length,$=h>0&&g.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:g,list:b,waitFor:t=>b.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return s}}),e.nextFreeSentence=function(t,a){if(t.freeNow.length&&!t.full)return`There are ${t.freeNow.length} tables free now: ${t.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const n=t.list[0];if(!n)return t.freeNow.length?`Table ${t.freeNow[0]} is free now.`:'No table is due to free up before the bookings that follow; check the bookings list.';const o=Math.max(5,Math.round((n.at.getTime()-a.getTime())/6e4)),r=t.waitFor(2),l=t.waitFor(4);return`Next table free about ${s(n.at)} (table ${n.table}, ${n.seats} seats), ${n.confidence}, in about ${o} minutes.${r?` A table for 2: about ${s(r.at)}.`:''}${l?` A table for 4: about ${s(l.at)}.`:''}${n.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]);const a=['seated','mains','dessert','bill'],n=(t,a)=>new Date(t.getTime()+6e4*a);const s=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},979,[789]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"KIND_LABEL",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TEMP_KINDS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"isTempKind",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"SECTIONS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"SECTION_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"sectionOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return d}}),_e.inRange=u,_e.spokenNumber=p,_e.parseQuick=function(e,n){return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const r=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${r.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,l=0;for(const e of n)for(const n of[e.name.toLowerCase(),...e.aliases]){const t=n.replace(/-/g,' ').replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim();t&&o.includes(` ${t} `)&&t.length>l&&(a=e,l=t.length)}const s=p(r);return a?t(a.kind)?null==s?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:s}:{text:e,point:a,value:null}:{text:e,value:s,problem:'Not sure which check this is \u2014 pick it below or type it.'}})},_e.missedChecks=function(e,n,t){const r=new Date(t);r.setHours(0,0,0,0);const o=60*t.getHours()+t.getMinutes(),a=[];for(const l of e){const e=l.due.filter(e=>f(e)<=o);if(!e.length)continue;const s=e[e.length-1],c=r.getTime()+6e4*f(e[0])-108e5,d=n.filter(e=>e.pointId===l.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(y).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return C}}),_e.todayTasks=function(e,n,t){const r=new Date(t);r.setHours(0,0,0,0);const o=60*t.getHours()+t.getMinutes(),a=[];for(const l of e){const e=[...l.due].sort();if(!e.length)continue;const s=r.getTime()+6e4*f(e[0])-108e5,c=n.filter(e=>e.pointId===l.id&&new Date(e.at).getTime()>=s&&new Date(e.at).getTime()<=t.getTime()).reverse().sort((e,n)=>e.at.localeCompare(n.at));e.forEach((e,n)=>{const t=c[n],r=f(e),s=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${l.id}@${e}`,point:l,due:e,slot:C(e),status:s,entry:t})})}return a.sort((e,n)=>e.due.localeCompare(n.due)||e.point.name.localeCompare(n.point.name))},_e.unitStatus=function(e,n,t){const r=n.filter(n=>n.pointId===e.id&&null!=n.value).reverse().sort((e,n)=>e.at.localeCompare(n.at)),o=r[r.length-1];if(!o)return{rag:'none',history:r,why:'No readings yet'};const a=o.value;if(!u(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const l=new Date(t);if(l.setHours(0,0,0,0),new Date(o.at).getTime()e.max-1||null!=e.min&&an.includes(e),r=['cross','cleaning','chilling','cooking','management'],o={cross:'Cross-contamination',cleaning:'Cleaning',chilling:'Chilling',cooking:'Cooking',management:'Management'},a={fridge:'chilling',freezer:'chilling',cool:'chilling',delivery:'chilling',cook:'cooking',hothold:'cooking',cleaning:'cleaning',allergen:'cross',check:'management'},l=e=>e.section??a[e.kind],s=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:['09:00','16:00'],aliases:['walk in fridge','walkin fridge','walk in','walk-in','walkin','cold room']},{id:'cp-prep',name:'Prep fridge',kind:'fridge',max:5,due:['09:00','16:00'],aliases:['prep fridge','prep']},{id:'cp-bar',name:'Bar fridge',kind:'fridge',max:5,due:['16:00'],aliases:['bar fridge','bar']},{id:'cp-freezer',name:'Freezer',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:['freezer','chest freezer']},{id:'cp-cook',name:'Cooking: core temperature',kind:'cook',min:75,due:[],aliases:['core','cook','cooking','probe']},{id:'cp-cool',name:'Cooling: within 90 minutes',kind:'cool',max:8,due:[],aliases:['cooling','cool']},{id:'cp-hothold',name:'Hot hold: bain-marie',kind:'hothold',min:63,due:['18:00'],aliases:['hot hold','bain marie','bain-marie','hothold']},{id:'cp-del-chill',name:'Delivery: chilled',kind:'delivery',max:8,due:[],aliases:['chilled delivery','delivery chilled','delivery']},{id:'cp-del-frozen',name:'Delivery: frozen',kind:'delivery',max:-15,due:[],aliases:['frozen delivery','delivery frozen']},{id:'cp-clean',name:'Close-down clean signed off',kind:'cleaning',due:['23:00'],aliases:['cleaning','clean down','close down']},{id:'cp-allergen',name:'Allergen matrix checked against today\u2019s specials',kind:'allergen',due:['11:00'],aliases:['allergen','allergens']},{id:'cp-open-equip',name:'Fridges, freezers and other equipment working',kind:'check',section:'management',due:['09:00'],aliases:['equipment']},{id:'cp-open-staff',name:'Staff fit for work, in clean work clothes',kind:'check',section:'management',due:['09:00'],aliases:['staff fit']},{id:'cp-open-surfaces',name:'Prep areas, surfaces and utensils clean and disinfected',kind:'cleaning',due:['09:00'],aliases:['surfaces','prep areas']},{id:'cp-open-pests',name:'No signs of pests',kind:'check',section:'cleaning',due:['09:00'],aliases:['pests','pest']},{id:'cp-open-hands',name:'Hand-wash basins: hot water, soap and paper towels',kind:'check',section:'cross',due:['09:00'],aliases:['hand wash','handwash','soap']},{id:'cp-open-probe',name:'Probe thermometer working, probe wipes available',kind:'check',section:'management',due:['09:00'],aliases:['probe wipes','thermometer']},{id:'cp-mid-boards',name:'Raw and ready-to-eat kept apart; colour-coded boards in use',kind:'check',section:'cross',due:['12:00'],aliases:['boards','raw and ready to eat']},{id:'cp-close-stored',name:'Food covered, labelled, dated and put away',kind:'check',section:'chilling',due:['22:00'],aliases:['labelled','covered']},{id:'cp-close-useby',name:'Food past its use-by date thrown away',kind:'check',section:'chilling',due:['22:00'],aliases:['use by','use-by']},{id:'cp-close-waste',name:'Waste removed and bins relined',kind:'check',section:'cleaning',due:['22:00'],aliases:['waste','bins']}],d=e=>null!=e.min&&null!=e.max?`${e.min}\xb0C to ${e.max}\xb0C`:null!=e.max?`${e.max}\xb0C or colder`:null!=e.min?`${e.min}\xb0C or hotter`:'Done / not done';function u(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const m={zero:0,nought:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30,forty:40,fifty:50,sixty:60,seventy:70,eighty:80,ninety:90};function p(e){const n=e.toLowerCase().replace(/\u2212/g,'-').replace(/degrees?|\xb0c?|celsius|centigrade/g,' '),t=/\b(minus|negative)\b/.test(n),r=n.match(/-?\d+(?:[.,]\d+)?/);if(r){const e=Number(r[0].replace(',','.'));return t&&e>0?-e:e}const o=n.split(/[^a-z]+/).filter(Boolean);let a=null,l=null,s=!1;for(const e of o)if('point'!==e){if(e in m){if(s){l=m[e];break}a=(a??0)+m[e]}}else s=!0;if(null==a)return null;const c=null!=l?Number(`${a}.${l}`):a;return t?-c:c}const f=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const h=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',y=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},k=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function b(n,t){return n.map(n=>{const r=new Date(n.at),o=t.find(e=>e.id===n.pointId);return[r.toLocaleDateString('en-GB'),r.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),n.name,e[n.kind],h(n),o?d(o):'',n.ok?'OK':'OUT OF RANGE',n.corrective??'',n.note??'',n.by,'probe'===n.source?'Wireless probe':'voice'===n.source?'Voice (confirmed)':'Typed']})}const w=['opening','midday','closing'],v={opening:'Opening',midday:'Midday',closing:'Closing'},O={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},C=e=>{const n=f(e);return n<660?'opening':n<960?'midday':'closing'};const T=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,x=['Opening and closing checks were done every day (or the reason is in the diary)','Every out-of-range reading has a corrective action','Probe thermometers checked (iced water / boiling water) this week','Allergen information is up to date for menu and special changes','Cleaning schedule followed; no signs of pests','Staff trained on any changed safe methods']},980,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useKitchenExtra",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"isManagerish",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isHeadChef",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isKitchenStaff",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"kitchenByRule",{enumerable:!0,get:function(){return l}}),_e.inKitchen=b,_e.inChannel=function(e,t){return!!t&&(e.startsWith('dm:')?e.split(':').slice(1).includes(t.id):'all'===e||('kitchen'===e?b(t):'managers'===e?o(t):'foh'===e&&(o(t)||/front|bar|server|waiting/i.test(t.job))))},Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return h}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},c=r(d[1]),a=r(d[2]);const u=(0,c.create)()((0,a.persist)(e=>({extra:{},set:(t,n)=>e(e=>{const c={...e.extra};return null==n?delete c[t]:c[t]=n,{extra:c}})}),{name:'covercharge-kitchen-chat-v1',version:1,storage:(0,a.createJSONStorage)(()=>n.default)})),o=e=>!!e&&'staff'!==e.role,s=e=>!!e&&/head chef/i.test((e.level??'')+' '+e.job),f=e=>!!e&&(/^kitchen$/i.test(e.dept??'')||/chef|kitchen|\bkp\b|porter/i.test(e.job)),l=e=>!!e&&(o(e)||s(e)||f(e));function b(e){if(!e||!e.active)return!1;return u.getState().extra[e.id]??l(e)}const h=(e,t)=>`dm:${[e,t].sort().join(':')}`},981,[975,974,976]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},982,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var u in n)Object.defineProperty(t,u,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,u).get})})(e,{get Badge(){return x.Badge},get DarkTheme(){return y.DarkTheme},get DefaultTheme(){return _.DefaultTheme},get ErrorBoundary(){return v.ErrorBoundary},get ExperimentalStack(){return U.ExperimentalStack},get ExpoRoot(){return c.ExpoRoot},get Icon(){return x.Icon},get IsWithinNativeNavigator(){return B.IsWithinNativeNavigator},get Label(){return x.Label},get LocaleProvider(){return I.LocaleProvider},get NativeStackView(){return E.NativeStackView},get NavigationAwareActivity(){return R.NavigationAwareActivity},get Navigator(){return t.Navigator},get RouterActionHandling(){return C.RouterActionHandling},get Sitemap(){return b.Sitemap},get Slot(){return t.Slot},get SplashScreen(){return S},get StackRouter(){return C.StackRouter},get SuspenseFallback(){return f.SuspenseFallback},get TabRouter(){return C.TabRouter},get Tabs(){return M.Tabs},get ThemeProvider(){return T.ThemeProvider},get Unmatched(){return l.Unmatched},get VectorIcon(){return x.VectorIcon},get attachRouteState(){return C.attachRouteState},get createBaseStackProps(){return j.createBaseStackProps},get createBaseTabProps(){return D.createBaseTabProps},get createNativeStackProps(){return W.createNativeStackProps},get createStandardRouterNavigator(){return B.createStandardRouterNavigator},get enableLegacyHeaderAppearance(){return F.enableLegacyHeaderAppearance},get extendRouter(){return C.extendRouter},get extendRouterActions(){return C.extendRouterActions},get integrateWithRouter(){return B.integrateWithRouter},get isActionHandled(){return C.isActionHandled},get router(){return u.router},get unstable_PerformanceObserver(){return G.unstable_PerformanceObserver},get unstable_createStandardRouterNavigator(){return B.unstable_createStandardRouterNavigator},get unstable_enablePerformanceIntegration(){return G.unstable_enablePerformanceIntegration},get unstable_integrateWithRouter(){return B.unstable_integrateWithRouter},get unstable_performance(){return G.unstable_performance},get unstable_useIsNavigating(){return o.useIsNavigating},get unstable_useReconcileTabHistory(){return H.useReconcileTabHistory},get useCanGoBack(){return n.useCanGoBack},get useCurrentRouteInfo(){return n.useCurrentRouteInfo},get useFocusEffect(){return h.useFocusEffect},get useGlobalSearchParams(){return n.useGlobalSearchParams},get useIsFocused(){return N.useIsFocused},get useLoaderData(){return n.useLoaderData},get useLocalSearchParams(){return n.useLocalSearchParams},get useNavigation(){return P.useNavigation},get useNavigationContainerRef(){return n.useNavigationContainerRef},get usePathname(){return n.usePathname},get usePreventRemove(){return L.usePreventRemove},get useRootNavigation(){return n.useRootNavigation},get useRootNavigationState(){return n.useRootNavigationState},get useRoute(){return A.useRoute},get useRoutePath(){return O.useRoutePath},get useRouter(){return n.useRouter},get useScrollToTop(){return w.useScrollToTop},get useSegments(){return n.useSegments},get useSitemap(){return p.useSitemap},get useTheme(){return k.useTheme},get useUnstableGlobalHref(){return n.useUnstableGlobalHref},get withLayoutContext(){return s.withLayoutContext}});const t=r(d[0]),n=r(d[1]),u=r(d[2]),o=r(d[3]),s=r(d[4]),c=r(d[5]),l=r(d[6]),b=r(d[7]),p=r(d[8]),v=r(d[9]),f=r(d[10]),R=r(d[11]),S=q(r(d[12])),P=r(d[13]),h=r(d[14]),N=r(d[15]),y=r(d[16]),_=r(d[17]),T=r(d[18]),k=r(d[19]),I=r(d[20]),O=r(d[21]),w=r(d[22]),A=r(d[23]),L=r(d[24]),x=r(d[25]),B=r(d[26]),H=r(d[27]),j=r(d[28]),D=r(d[29]),W=r(d[30]),C=r(d[31]),E=r(d[32]),F=r(d[33]),G=r(d[34]),M=r(d[35]),U=r(d[36]);function V(t){if("function"!=typeof WeakMap)return null;var n=new WeakMap,u=new WeakMap;return(V=function(t){return t?u:n})(t)}function q(t,n){if(!n&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var u=V(n);if(u&&u.has(t))return u.get(t);var o={__proto__:null},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in t)if("default"!==c&&Object.prototype.hasOwnProperty.call(t,c)){var l=s?Object.getOwnPropertyDescriptor(t,c):null;l&&(l.get||l.set)?Object.defineProperty(o,c,l):o[c]=t[c]}return o.default=t,u&&u.set(t,o),o}},983,[676,401,494,984,694,14,748,739,742,985,646,644,649,515,519,524,463,465,429,430,986,470,471,460,458,506,693,639,707,987,706,340,685,690,360,988,991]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"useIsNavigating",{enumerable:!0,get:function(){return u}});const t=r(d[1]);function u(){return(0,n().use)(t.NavigationPendingContext)}},984,[12,357]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){const o=r(d[0]);return t=function(){return o},o}function o(){const t=r(d[1]);return o=function(){return t},t}function n(){const t=r(d[2]);return n=function(){return t},t}function l(){const t=r(d[3]);return l=function(){return t},t}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"ErrorBoundary",{enumerable:!0,get:function(){return f}});r(d[4]);const s=r(d[5]),c=r(d[6]),u=r(d[7]);function h({error:o}){return(0,t().jsxs)(n().View,{style:{marginBottom:12,gap:4,flexWrap:'wrap'},children:[(0,t().jsx)(n().Text,{role:"heading","aria-level":1,style:y.title,children:"Something went wrong"}),(0,t().jsxs)(n().Text,{testID:"router_error_message",role:"heading","aria-level":2,style:y.errorMessage,children:["Error: ",o.message]})]})}function f({error:f,retry:x}){const w=(0,o().use)(s.BottomTabBarHeightContext)?n().View:l().SafeAreaView,S=f instanceof c.ReactServerError;return(0,t().jsx)(n().View,{style:y.container,children:(0,t().jsxs)(w,{style:{flex:1,gap:8,maxWidth:720,marginHorizontal:'auto'},children:[S?(0,t().jsx)(b,{error:f}):(0,t().jsx)(h,{error:f}),(0,t().jsx)(n().View,{style:{flex:1}}),!1,(0,t().jsx)(u.Pressable,{testID:"router_error_retry",onPress:x,children:({hovered:o,pressed:l})=>(0,t().jsx)(n().View,{style:[y.buttonInner,(o||l)&&{backgroundColor:'white'}],children:(0,t().jsx)(n().Text,{style:[y.buttonText,{color:o||l?'black':'white'}],children:"Retry"})})})]})})}const x={404:'NOT_FOUND',500:'INTERNAL_SERVER_ERROR',503:'SERVICE_UNAVAILABLE',504:'GATEWAY_TIMEOUT'};function b({error:o}){let l=String(o.statusCode);l+=': '+(x[o.statusCode]??'Server Error');const s=o.headers.get('cf-ray'),c=o.headers.get('Date');return(0,t().jsxs)(n().View,{style:{padding:12,gap:8},children:[(0,t().jsx)(n().Text,{selectable:!0,allowFontScaling:!0,style:{fontSize:n().Platform.select({web:24,default:16}),fontWeight:'bold',marginBottom:4,color:'white'},children:l}),(0,t().jsx)(n().ScrollView,{style:{borderColor:'rgba(255,255,255,0.5)',borderTopWidth:n().StyleSheet.hairlineWidth,borderBottomWidth:n().StyleSheet.hairlineWidth,maxHeight:150},contentContainerStyle:{paddingVertical:4},children:(0,t().jsx)(n().Text,{testID:"router_error_message",selectable:!0,allowFontScaling:!0,style:{color:'white'},children:o.message})}),(0,t().jsx)(w,{title:"Code",right:o.statusCode}),s&&(0,t().jsx)(w,{title:"ID",right:s}),c&&(0,t().jsx)(w,{title:"Date",right:c}),o.url&&(0,t().jsx)(n().Text,{selectable:!0,allowFontScaling:!0,style:{fontSize:14,opacity:.5,color:'white'},children:o.url})]})}function w({title:o,right:l}){const s={fontSize:16,color:'white'};return(0,t().jsxs)(n().View,{style:{flexDirection:'row',justifyContent:'space-between'},children:[(0,t().jsx)(n().Text,{selectable:!0,allowFontScaling:!0,style:s,children:o}),l&&(0,t().jsx)(n().Text,{selectable:!0,allowFontScaling:!0,style:[s,y.code],children:l})]})}const y=n().StyleSheet.create({container:{flex:1,backgroundColor:'black',padding:24,alignItems:'stretch',justifyContent:'center'},title:{color:'white',fontSize:n().Platform.select({web:32,default:24}),fontWeight:'bold'},buttonText:{fontSize:18,fontWeight:'bold',color:'black',...n().Platform.select({web:{transitionDuration:'100ms'}})},buttonInner:{...n().Platform.select({web:{transitionDuration:'100ms'}}),paddingVertical:12,paddingHorizontal:24,borderColor:'white',borderWidth:2,marginLeft:8,justifyContent:'center',alignItems:'center'},code:{fontFamily:n().Platform.select({default:'Courier',ios:'Courier New',android:'monospace'}),fontWeight:'500'},errorMessage:{color:'white',fontSize:16},subtitle:{color:'white',fontSize:14,marginBottom:12},link:{color:'rgba(255,255,255,0.4)',textDecorationStyle:'solid',textDecorationLine:'underline',fontSize:14,textAlign:'center'}})},985,[6,12,15,271,490,527,648,741]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"LocaleProvider",{enumerable:!0,get:function(){return o}});const t=r(d[1]);function o({direction:o,children:c}){return(0,n().jsx)(t.LocaleDirContext.Provider,{value:o,children:c})}},986,[6,411]); +__d(function(g,r,i,a,m,e,d){"use strict";function t({dispatch:t,isPreloaded:o,isRemovalPrevented:n,state:s}){return{isPreloaded:o,isRemovalPrevented:n,routeNames:s.routeNames,preload:o=>t({type:'PRELOAD',payload:{name:o}})}}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"createBaseTabProps",{enumerable:!0,get:function(){return t}})},987,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),(function(t,o){for(var n in o)Object.defineProperty(t,n,{enumerable:!0,get:Object.getOwnPropertyDescriptor(o,n).get})})(e,{get BottomTabBar(){return n.BottomTabBar},get BottomTabBarHeightCallbackContext(){return n.BottomTabBarHeightCallbackContext},get BottomTabBarHeightContext(){return n.BottomTabBarHeightContext},get BottomTabView(){return n.BottomTabView},get SceneStyleInterpolators(){return u},get Tabs(){return n.default},get TransitionPresets(){return c},get TransitionSpecs(){return f},get createJSTabsProps(){return n.createJSTabsProps},get createStandardBottomTabNavigator(){return n.createStandardBottomTabNavigator},get default(){return s},get useBottomTabBarHeight(){return n.useBottomTabBarHeight}});const t=r(d[0]),o=r(d[1]),n=b(r(d[2])),u=b(r(d[3])),c=b(r(d[4])),f=b(r(d[5]));function l(t){if("function"!=typeof WeakMap)return null;var o=new WeakMap,n=new WeakMap;return(l=function(t){return t?n:o})(t)}function b(t,o){if(!o&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=l(o);if(n&&n.has(t))return n.get(t);var u={__proto__:null},c=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var b=c?Object.getOwnPropertyDescriptor(t,f):null;b&&(b.get||b.set)?Object.defineProperty(u,f,b):u[f]=t[f]}return u.default=t,n&&n.set(t,u),u}n.default.Screen=o.Screen,n.default.Protected=t.Protected;const s=n.default},988,[700,701,989,528,529,530]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}function n(){const t=r(d[1]);return n=function(){return t},t}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var o in n)Object.defineProperty(t,o,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,o).get})})(e,{get createJSTabsProps(){return h},get default(){return y}});const o=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),f=r(d[7]);var l,b;function h(t){const{dispatch:n,state:o}=t;return{...(0,f.createBaseTabProps)(t),popNestedStackToTop:t=>{const s=o.routes.find(n=>n.key===t)?.state;s?.key&&n({...c.StackActions.popToTop(),target:s.key})}}}l=r(d[8]),b=e,Object.keys(l).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(b,t)||Object.defineProperty(b,t,{enumerable:!0,get:function(){return l[t]}})});const y=(0,u.integrateWithRouter)(s.createStandardBottomTabNavigator,c.TabRouter,{activityDefaultThreshold:1,processDescriptors:p.appendMissingPlaceholderTabDescriptors,processState:p.appendMissingPlaceholderTabRoutes,createProps:h,processScreens:s=>s.map(s=>{if('function'!=typeof s.options&&void 0!==s.options?.href){const{href:c,...u}=s.options;if(u.tabBarButton)throw new Error('Cannot use `href` and `tabBarButton` together.');return null===c?{...s,options:{...u,hidden:!0}}:{...s,options:{...u,tabBarButton:s=>{const u='web'===n().Platform.OS?s.children:(0,t().jsx)(n().Pressable,{children:s.children});return(0,t().jsx)(o.Link,{...s,style:[{display:'flex'},s.style],href:c,asChild:'web'!==n().Platform.OS,children:u})}}}}return s})})},989,[6,15,490,634,409,693,990,987,527]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){const s=n.routeNames.filter(t=>!n.routes.some(n=>n.name===t));if(0===s.length)return t;const u=s.reduce((t,n)=>(t[n]=o({key:void 0,name:n}),t),{});return{...t,...u}}function n(t,n){if(!t.routeNames.some(n=>!t.routes.some(t=>t.name===n)))return t;const s=t.routes[t.index]?.key,u=t.routeNames.map(s=>{const u=t.routes.find(t=>t.name===s);return u||o(s,n)}),c=Math.max(0,u.findIndex(t=>t.key===s));return{...t,index:c,routes:u}}function o(t,n){const o=n[t];if(!o)throw new Error(`Could not find a descriptor for route "${t}". This is most likely a bug in expo-router. Please report it at https://github.com/expo/expo/issues.`);return{...o.route,key:t,name:t}}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var o in n)Object.defineProperty(t,o,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,o).get})})(e,{get appendMissingPlaceholderTabDescriptors(){return t},get appendMissingPlaceholderTabRoutes(){return n}})},990,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var u in n)Object.defineProperty(t,u,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,u).get})})(e,{get ExperimentalStack(){return c},get default(){return o}});const n=u(r(d[1]));function u(t){return t&&t.__esModule?t:{default:t}}const c=Object.assign(u=>(0,t().jsx)(n.default,{...u}),{Screen:n.default.Screen,Protected:n.default.Protected}),o=c},991,[6,992]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),(function(t,u){for(var n in u)Object.defineProperty(t,n,{enumerable:!0,get:Object.getOwnPropertyDescriptor(u,n).get})})(e,{get Stack(){return t.default},get default(){return l}});const t=c(r(d[0])),u=r(d[1]),n=r(d[2]);function c(t){return t&&t.__esModule?t:{default:t}}t.default.Screen=u.StackScreen,t.default.Header=u.StackHeader,t.default.Title=u.StackTitle,t.default.Toolbar=n.StackToolbar;const l=t.default},992,[677,710,715]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.default}});const t=o((n=r(d[0]),u=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(u,t)||Object.defineProperty(u,t,{enumerable:!0,get:function(){return n[t]}})}),n));var n,u;function o(t){return t&&t.__esModule?t:{default:t}}},993,[992]); +__d(function(g,r,i,a,m,e,d){"use strict";var t,n;Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var o in n)Object.defineProperty(t,o,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,o).get})})(e,{get useIsPreview(){return s.useIsPreview},get usePreventZoomTransitionDismissal(){return o.usePreventZoomTransitionDismissal}}),t=r(d[0]),n=e,Object.keys(t).forEach(function(o){"default"===o||Object.prototype.hasOwnProperty.call(n,o)||Object.defineProperty(n,o,{enumerable:!0,get:function(){return t[o]}})});const o=r(d[1]),s=r(d[2])},994,[490,995,403]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(n){}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"usePreventZoomTransitionDismissal",{enumerable:!0,get:function(){return n}})},995,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Color",{enumerable:!0,get:function(){return y}});r(d[0]);function t(t,n){return Object.keys(t).forEach(function(u){"default"===u||Object.prototype.hasOwnProperty.call(n,u)||Object.defineProperty(n,u,{enumerable:!0,get:function(){return t[u]}})}),t}t(r(d[1]),e),t(r(d[2]),e),t(r(d[3]),e),t(r(d[4]),e),t(r(d[5]),e);const n=new Proxy({},{get:(t,n)=>null}),u=new Proxy({},{get:(t,n)=>null}),o=new Proxy({},{get:(t,n)=>null}),l=new Proxy({},{get:(t,n)=>null}),c=new Proxy({get attr(){return u},get material(){return o},get dynamic(){return l}},{get:(t,n)=>n in t?t[n]:null}),y={get ios(){return n},get android(){return c}}},996,[997,998,999,1000,1001,1002]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return null}function n(t){return null}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var o in n)Object.defineProperty(t,o,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,o).get})})(e,{get Material3Color(){return n},get Material3DynamicColor(){return t}})},997,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},999,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1000,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1001,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1002,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.SplitFlap=function({value:t,height:e=52,colour:o="#F5F1E8",min:i=2,sound:n,testID:u}){const s=String(Math.max(0,Math.round(t))).padStart(i,' '),h=Math.round(.68*e);return(0,c.jsx)(l.default,{testID:u,accessible:!0,accessibilityLabel:String(Math.max(0,Math.round(t))),style:{flexDirection:'row',gap:3},children:s.split('').map((t,i)=>(0,c.jsx)(x,{ch:' '===t?'':t,h:e,colour:o,size:h,sound:n&&i===s.length-1},s.length-i))})};var e=r(d[0]),o=t(r(d[1])),i=t(r(d[2])),n=t(r(d[3])),l=t(r(d[4])),u=r(d[5]),s=r(d[6]),c=r(d[7]);let h=!1;o.default.isReduceMotionEnabled?.().then(t=>{h=!!t}).catch(()=>{}),o.default.addEventListener?.('reduceMotionChanged',t=>{h=!!t});const f='#1B1A1D',p='#201F22';function b({ch:t,h:e,w:o,colour:n,part:u,size:h}){return(0,c.jsx)(l.default,{style:{height:e/2,width:o,overflow:'hidden',backgroundColor:'top'===u?p:f,borderTopLeftRadius:'top'===u?8:0,borderTopRightRadius:'top'===u?8:0,borderBottomLeftRadius:'bottom'===u?8:0,borderBottomRightRadius:'bottom'===u?8:0},children:(0,c.jsx)(i.default.Text,{allowFontScaling:!1,style:{position:'absolute',left:0,right:0,top:'top'===u?0:-e/2,height:e,lineHeight:e,textAlign:'center',fontSize:h,fontFamily:s.fonts.bold,color:n,includeFontPadding:!1},children:t})})}function x({ch:t,h:o,colour:s,size:f,sound:p}){const x=Math.round(.7*o),[j,v]=(0,e.useState)(t),[w,R]=(0,e.useState)(t),y=(0,e.useRef)(new i.default.Value(0)).current,M=(0,e.useRef)(new i.default.Value(1)).current,V=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(V.current)return V.current=!1,v(t),void R(t);if(t!==j){if(h)return R(t),void v(t);R(j),v(t),y.setValue(0),M.setValue(1),p&&(0,u.flapClick)(),i.default.sequence([i.default.timing(y,{toValue:1,duration:210,easing:n.default.in(n.default.quad),useNativeDriver:!0}),i.default.timing(M,{toValue:0,duration:210,easing:n.default.out(n.default.quad),useNativeDriver:!0})]).start(()=>R(t))}},[t]);const z=o/4,F=y.interpolate({inputRange:[0,1],outputRange:['0deg','-90deg']}),S=M.interpolate({inputRange:[0,1],outputRange:['0deg','90deg']}),D=w!==j;return(0,c.jsxs)(l.default,{style:{width:x,height:o},children:[(0,c.jsx)(b,{ch:j,h:o,w:x,colour:s,part:"top",size:f}),(0,c.jsx)(b,{ch:D?w:j,h:o,w:x,colour:s,part:"bottom",size:f}),D?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(i.default.View,{style:{position:'absolute',top:0,left:0,transform:[{perspective:400},{translateY:z},{rotateX:F},{translateY:-z}],backfaceVisibility:'hidden'},children:(0,c.jsx)(b,{ch:w,h:o,w:x,colour:s,part:"top",size:f})}),(0,c.jsx)(i.default.View,{style:{position:'absolute',top:o/2,left:0,transform:[{perspective:400},{translateY:-z},{rotateX:S},{translateY:z}],backfaceVisibility:'hidden'},children:(0,c.jsx)(b,{ch:j,h:o,w:x,colour:s,part:"bottom",size:f})})]}):null,(0,c.jsx)(l.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:o/2-.5,height:1,backgroundColor:'rgba(0,0,0,0.75)'}})]})}},1003,[12,100,102,206,109,880,799,6]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"localRepositories",{enumerable:!0,get:function(){return s}});var e=_r(d[0]);const a=()=>e.useStore.getState(),t=e=>Promise.resolve(e),s={customers:{update:async e=>a().updateCustomer(e),setAllergy:async(e,t)=>a().setAllergy(e,t)},menu:{updateItem:async(e,t)=>a().updateMenuItem(e,t),setSignOff:async(e,t)=>a().setSignOff(e,t)},orders:{placeFromBasket:e=>t(a().placeOrder(e)),accept:async(e,t,s)=>a().acceptOrder(e,t,s),setStatus:async(e,t,s)=>a().setOrderStatus(e,t,s),acknowledgeAllergy:async(e,t)=>a().ackOrderAllergy(e,t),acknowledgeReadiness:async(e,t,s)=>a().ackReadiness(e,t,s),recordHandoverCheck:async(e,t)=>a().handoverCheck(e,t),signAllergyStep:async(e,t,s)=>a().signAllergyStep(e,t,s),customerSignal:async(e,t)=>a().customerSignal(e,t),setSplit:async(e,t,s)=>a().setSplit(e,t,s),payTable:async(e,t)=>a().payTable(e,t)},bookings:{create:e=>t(a().createBooking(e)),setStatus:async(e,t)=>a().setBookingStatus(e,t),decide:async(e,t,s)=>a().decideBooking(e,t,s),acknowledgeAllergy:async(e,t)=>a().ackBookingAllergy(e,t),seatWalkIn:(e,s,n,c)=>t(a().seatWalkIn(e,s,n,c)),assignTable:async(e,t)=>a().setBookingTable(e,t),undoWalkIn:async e=>a().undoWalkIn(e),update:async(e,t)=>a().updateBooking(e,t)},waitlist:{join:(e,s,n,c)=>t(a().joinWaitlist(e,s,n,c)),setStatus:async(e,t)=>a().setWaitlistStatus(e,t),addWalkIn:async(e,t)=>a().addWalkIn(e,t)},loyalty:{addStamp:async(e,t,s)=>a().addStamp(e,t,s),redeemReward:async(e,t)=>a().redeemReward(e,t)},giftCards:{purchase:(e,s,n,c)=>t(a().buyGiftCard(e,s,n,c))},calendar:{addEvent:async e=>a().addEvent(e)},feedback:{add:async e=>a().addRating(e)},restaurants:{updateSettings:async(e,t)=>a().updateSettings(e,t)},alerts:{acknowledge:async(e,t)=>a().ackAlert(e,t)}}},1004,[855]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return i}});var e,t=r(d[0]);const o=((e=t)&&e.__esModule?e:{default:e}).default.bind({concatArrays:!0,ignoreUndefined:!0});function n(e,t){const n=window.localStorage.getItem(e);if(n){const l=JSON.parse(n),c=JSON.parse(t),s=JSON.stringify(o(l,c));window.localStorage.setItem(e,s)}else window.localStorage.setItem(e,t)}function l(e,t){return new Promise((o,n)=>{try{const n=e();t?.(null,n),o(n)}catch(e){t?.(e),n(e)}})}function c(e,t,o){return Promise.all(e).then(e=>{const n=o?.(e)??null;return t?.(null,n),Promise.resolve(n)},e=>(t?.(e),Promise.reject(e)))}const s={getItem:(e,t)=>l(()=>window.localStorage.getItem(e),t),setItem:(e,t,o)=>l(()=>window.localStorage.setItem(e,t),o),removeItem:(e,t)=>l(()=>window.localStorage.removeItem(e),t),mergeItem:(e,t,o)=>l(()=>n(e,t),o),clear:e=>l(()=>window.localStorage.clear(),e),getAllKeys:e=>l(()=>{const e=window.localStorage.length,t=[];for(let o=0;o{},multiGet:(e,t)=>c(e.map(e=>s.getItem(e)),t,t=>t.map((t,o)=>[e[o],t])),multiSet:(e,t)=>c(e.map(e=>s.setItem(e[0],e[1])),t),multiRemove:(e,t)=>c(e.map(e=>s.removeItem(e)),t),multiMerge:(e,t)=>c(e.map(e=>s.mergeItem(e[0],e[1])),t)};var i=s},1005,[1006]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),u=((e=t)&&e.__esModule?e:{default:e}).default},1006,[1007]); +__d(function(g,r,i,a,m,e,d){'use strict';const t=r(d[0]),{hasOwnProperty:n}=Object.prototype,{propertyIsEnumerable:o}=Object,c=(t,n,o)=>Object.defineProperty(t,n,{value:o,writable:!0,enumerable:!0,configurable:!0}),s=this,f={concatArrays:!1,ignoreUndefined:!1},l=t=>{const c=[];for(const o in t)n.call(t,o)&&c.push(o);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(t);for(const s of n)o.call(t,s)&&c.push(s)}return c};function u(n){return Array.isArray(n)?y(n):t(n)?p(n):n}function y(t){const n=t.slice(0,0);return l(t).forEach(o=>{c(n,o,u(t[o]))}),n}function p(t){const n=null===Object.getPrototypeOf(t)?Object.create(null):{};return l(t).forEach(o=>{c(n,o,u(t[o]))}),n}const b=(t,n,o,s)=>(o.forEach(o=>{void 0===n[o]&&s.ignoreUndefined||(o in t&&t[o]!==Object.getPrototypeOf(t)?c(t,o,h(t[o],n[o],s)):c(t,o,u(n[o])))}),t),O=(t,o,s)=>{let f=t.slice(0,0),y=0;return[t,o].forEach(o=>{const p=[];for(let s=0;s!p.includes(t)),s)}),f};function h(n,o,c){return c.concatArrays&&Array.isArray(n)&&Array.isArray(o)?O(n,o,c):t(o)&&t(n)?b(n,o,l(o),c):u(o)}m.exports=function(...n){const o=h(u(f),this!==s&&this||{},f);let c={_:{}};for(const s of n)if(void 0!==s){if(!t(s))throw new TypeError('`'+s+'` is not an Option Object');c=h(c,{_:s},o)}return c._}},1007,[1008]); +__d(function(g,r,i,a,m,e,d){'use strict';m.exports=t=>{if('[object Object]'!==Object.prototype.toString.call(t))return!1;const o=Object.getPrototypeOf(t);return null===o||o===Object.prototype}},1008,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useAsyncStorage=function(e){return{getItem:(...t)=>u.default.getItem(e,...t),setItem:(...t)=>u.default.setItem(e,...t),mergeItem:(...t)=>u.default.mergeItem(e,...t),removeItem:(...t)=>u.default.removeItem(e,...t)}};var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1009,[1005]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"createStore",{enumerable:!0,get:function(){return n}});const t=t=>{let n;const c=new Set,o=(t,o)=>{const s="function"==typeof t?t(n):t;if(!Object.is(s,n)){const t=n;n=(null!=o?o:"object"!=typeof s||null===s)?s:Object.assign({},n,s),c.forEach(c=>c(n,t))}},s=()=>n,u={setState:o,getState:s,getInitialState:()=>l,subscribe:t=>(c.add(t),()=>c.delete(t))},l=n=t(o,s,u);return u},n=n=>n?t(n):t},1010,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"create",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return o}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},u=r(d[1]);const c=e=>e;function o(e,t=c){const u=n.default.useSyncExternalStore(e.subscribe,n.default.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return n.default.useDebugValue(u),u}const s=e=>{const t=(0,u.createStore)(e),n=e=>o(t,e);return Object.assign(n,t),n},l=e=>e?s(e):s},1011,[12,1010]); +__d(function(g,_r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return s}}),e.defaultSimStart=function(t=new Date){const r=new Date(t),n=(5-r.getDay()+7)%7;return r.setDate(r.getDate()+n),r.setHours(17,30,0,0),r},e.buildSeed=function(o){const d=(0,i.ymd)(o),l=t=>t.toISOString(),c=n.restaurants.map(r=>'anchorage'===r.id?{...r,sections:t.ANCHORAGE_SECTIONS}:r),u={id:s,name:'Alex Morgan',email:'alex.demo@example.com',phone:'07700 900123',allergies:[{allergen:'crustaceans',severity:'anaphylaxis'},{allergen:'mustard',severity:'allergy'}],allergyConsent:!0,referralCode:'ALEX-7K2Q',marketingOptIn:{anchorage:!0}},p=(t,r,n,s,c={})=>({id:t,ref:`BK-${t.slice(-3).toUpperCase()}`,restaurantId:'anchorage',customerId:null,name:r,partySize:n,date:d,time:s,allergies:[],notes:'',status:'confirmed',security:n>=6?'saved-card':'none',depositPaid:0,createdAt:l((0,i.addMins)(o,-4320)),...c}),h=[p('bk-101','Campbell',2,'17:00',{table:'12',status:'seated',seatedAt:l((0,i.addMins)(o,-28)),tags:['Regular']}),p('bk-102','Fraser',4,'17:30',{table:'10',tags:['VIP']}),p('bk-103','McLeod',2,'18:00',{table:'11',allergies:[{allergen:'gluten',severity:'coeliac'}],notes:'Anniversary',occasion:'anniversary'}),p('bk-104','Kerr',6,'18:00',{table:'18'}),p('bk-105','Wallace',3,'18:30',{table:'13'}),p('bk-106','Boyd',8,'19:00',{table:'1+2',dog:!0,allergies:[{allergen:'peanuts',severity:'anaphylaxis'}],notes:'Birthday \u2014 bringing a dog',occasion:'birthday'}),p('bk-107','Hamilton',2,'19:00',{table:'5'}),p('bk-108','Stewart',4,'19:30',{table:'19',tags:['Regular']}),p('bk-109','Murray',2,'20:00',{table:'16'})],y=[{id:'wl-1',restaurantId:'anchorage',number:1,name:'Paterson',partySize:2,joinedAt:l((0,i.addMins)(o,-12)),status:'waiting'},{id:'wl-2',restaurantId:'anchorage',number:2,name:'Duncan',partySize:4,joinedAt:l((0,i.addMins)(o,-4)),status:'waiting'}],b=(0,i.atTime)(o,'17:45'),I=[{id:'ord-seed-1',ref:'T-1041',restaurantId:'anchorage',customerId:'cust-other',customerName:'R. Gilmour',type:'takeaway',slotTime:l(b),lines:[{itemId:'a-fishsupper',name:'Fish Supper',qty:2,unitPrice:1800,choices:['Beer-battered'],notes:'',contains:[],may:[],overridden:!1,prepMins:12},{itemId:'a-chips',name:'Triple-Cooked Chips (V)',qty:1,unitPrice:450,choices:[],notes:'Extra salt',contains:[],may:[],overridden:!1,prepMins:6}],subtotal:4050,tip:0,giftCardApplied:0,total:4050,paid:4050,status:'acknowledged',createdAt:l((0,i.addMins)(o,-50)),allergies:[],readiness:{}},{id:'ord-seed-2',ref:'Q-2017',restaurantId:'anchorage',customerId:'cust-other2',customerName:'Table 3 guest',type:'table',tableNo:'3',lines:[{itemId:'a-moules',name:'Moules Marini\xe8re',qty:1,unitPrice:2200,choices:['Main 500g with triple-cooked chips (\xa322.00)'],notes:'',contains:[],may:[],overridden:!1,prepMins:10},{itemId:'a-claymore',name:'The Claymore Burger',qty:1,unitPrice:1800,choices:[],notes:'No gherkins',contains:[],may:[],overridden:!1,prepMins:14}],subtotal:4e3,tip:0,giftCardApplied:0,total:4e3,paid:0,status:'preparing',createdAt:l((0,i.addMins)(o,-18)),allergies:[],readiness:{}}],k=[{restaurantId:'anchorage',customerId:s,stamps:5,rewardsAvailable:0,history:[{at:'2026-08-15',source:'Dine-in (staff scan)'},{at:'2026-08-29',source:'Takeaway'},{at:'2026-09-12',source:'Table QR bill'},{at:'2026-10-02',source:'Takeaway'},{at:'2026-10-16',source:'Referral \u2014 friend\u2019s first visit'}]},{restaurantId:'saltmarsh',customerId:s,stamps:2,rewardsAvailable:0,history:[{at:'2026-09-01',source:'Dine-in'},{at:'2026-10-01',source:'Dine-in'}]}],v=[{id:'gc-1',code:'ANC-G7QX-4M2P-9TRE',restaurantId:'anchorage',initial:5e3,balance:2500,ownerId:s,recipientName:'Alex',message:'Happy birthday! (example)',createdAt:'2026-09-20'},{id:'gc-2',code:'WIX-OLD-10-EXAMPLE',restaurantId:'anchorage',initial:1e3,balance:1e3,ownerId:'legacy',recipientName:'Legacy Wix voucher (example)',message:'',createdAt:'2026-06-01',legacy:!0}],x=[...r.SCOTTISH_BANK_HOLIDAYS.map((t,n)=>({id:`bh-${n}`,restaurantId:null,date:t.date,title:t.title+(t.notes&&!/substitute/i.test(t.notes)?` (${t.notes.toLowerCase()})`:''),kind:'bank-holiday',description:'Scottish bank holiday',example:!1,source:r.BANK_HOLIDAY_SOURCE})),{id:'ev-halloween',restaurantId:'anchorage',date:(0,i.ymd)(new Date(o.getFullYear(),9,31)),title:'Halloween weekend (example)',kind:'event',description:'Example event \u2014 busy weekend flag for the forecast.',example:!0},{id:'ev-xmas-party',restaurantId:'anchorage',date:'2026-12-04',title:'Christmas party nights begin (example)',kind:'event',description:'Example: festive set menu, deposit required for parties of 8+.',example:!0},{id:'ev-hogmanay',restaurantId:null,date:'2026-12-31',title:'Hogmanay',kind:'occasion',description:'Key dining date.',example:!1},{id:'ev-burns',restaurantId:'anchorage',date:'2027-01-25',title:'Burns Night Supper (example)',kind:'event',description:'EXAMPLE event: haggis, neeps & tatties, address to the haggis, set menu \xa348pp. Booking opens via the app.',example:!0},{id:'ev-valentines',restaurantId:null,date:'2027-02-14',title:"Valentine's Day",kind:'occasion',description:'Key dining date.',example:!1},{id:'ev-mothering',restaurantId:null,date:'2027-03-07',title:'Mothering Sunday (UK)',kind:'occasion',description:'Key dining date.',example:!1},{id:'ev-live',restaurantId:'anchorage',date:'2026-11-14',title:'Live acoustic music (example)',kind:'event',description:'EXAMPLE: local folk duo from 7pm.',example:!0},{id:'ev-school-xmas',restaurantId:null,date:'2026-12-23',title:'South Ayrshire schools close for Christmas',kind:'school-holiday',description:'23 Dec 2026 \u2013 4 Jan 2027',example:!1},{id:'ev-salt-quiz',restaurantId:'saltmarsh',date:'2026-11-05',title:'Quiz night (fictional)',kind:'event',description:'Fictional demo restaurant event.',example:!0}];return{restaurants:c,menu:[...t.anchorageMenu,...n.demoMenus],customer:u,bookings:h,waitlist:y,orders:I,stampCards:k,giftCards:v,events:x,ratings:[{id:'rt-1',restaurantId:'anchorage',customerId:'cust-x1',customerName:'Fiona (example)',stars:5,comment:'Best fish supper on the coast, and the staff were brilliant with my son\u2019s nut allergy.',createdAt:l((0,i.addMins)(o,-1560)),context:'Takeaway T-1032'},{id:'rt-2',restaurantId:'anchorage',customerId:'cust-x2',customerName:'Iain (example)',stars:4,comment:'Lovely langoustines. Bit of a wait for a table at 7.',createdAt:l((0,i.addMins)(o,-3e3)),context:'Dine-in, Table 6'},{id:'rt-3',restaurantId:'anchorage',customerId:'cust-x3',customerName:'Morag (example)',stars:2,comment:'Chips were cold by the time we collected.',createdAt:l((0,i.addMins)(o,-4320)),context:'Takeaway T-1019'}],audit:[],alertAcks:{},walkIns:{anchorage:6},basket:{restaurantId:null,mode:'takeaway',lines:[]},counters:{order:1042,table:2018,booking:110}}};var t=_r(_d[0]),r=_r(_d[1]),n=_r(_d[2]),i=_r(_d[3]);const s='cust-demo'},1012,[1013,1014,1015,796]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ANCHORAGE_SECTIONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"anchorageMenu",{enumerable:!0,get:function(){return l}});const i={by:'Example sign-off (demo)',at:'2026-10-26'},s=i=>({id:i,name:'Served with',required:!0,multi:!1,choices:[{id:`${i}-custard`,label:'Custard',priceDelta:0,allergens:{milk:'contains',eggs:'contains'}},{id:`${i}-icecream`,label:'Ice cream',priceDelta:0,allergens:{milk:'contains'}},{id:`${i}-cream`,label:'Cream',priceDelta:0,allergens:{milk:'contains'}},{id:`${i}-vegan`,label:'Vegan ice cream (ask server)',priceDelta:0,allergens:{soya:'may'}}]}),n=(i,s,n)=>({id:i,name:'Portion',required:!0,multi:!1,choices:[{id:`${i}-starter`,label:'Starter',priceDelta:0},{id:`${i}-main`,label:n,priceDelta:s}]}),t=[{id:'a-soup',section:'Starters',name:"Chef's Soup of the Day",description:'A heartwarming bowl of seasonal homemade soup, served with warm crusty bread and butter.',price:600,dietary:[],allergens:{gluten:'contains',milk:'contains',celery:'contains'},allergenNotes:'Recipe changes daily \u2014 check the day\u2019s soup.',prepMins:5},{id:'a-skink',section:'Starters',name:'Cullen Skink',description:'Traditional creamy soup made with locally smoked haddock, potatoes and leeks, served with warm crusty bread and butter.',price:900,dietary:[],allergens:{fish:'contains',milk:'contains',gluten:'contains',celery:'may'},prepMins:6},{id:'a-salmon',section:'Starters',name:'Scottish Smoked Salmon Roulade',description:'Delicate Scottish smoked salmon rolled with herb-infused cream cheese, served with garlic & herb crostini and dressed salad.',price:900,dietary:[],allergens:{fish:'contains',milk:'contains',gluten:'contains',mustard:'may',sulphites:'may'},prepMins:5},{id:'a-haggis',section:'Starters',name:'Haggis Bon Bons',description:'Crisp golden panko-fried haggis balls, finished with a velvety Scotch whisky sauce and caramelised apple gel.',price:800,dietary:[],allergens:{gluten:'contains',eggs:'contains',milk:'contains',celery:'contains',mustard:'may',sulphites:'may'},allergenNotes:'Shared fryer (example).',prepMins:8},{id:'a-crabcakes',section:'Starters',name:'Spiced Crab Cakes',description:'Golden crab cakes, delicately seasoned with herbs and spices, served with crisp seasonal salad and house-made Marie Rose sauce.',price:900,dietary:[],allergens:{crustaceans:'contains',gluten:'contains',eggs:'contains',mustard:'contains',fish:'may'},allergenNotes:'Shared fryer (example).',prepMins:8},{id:'a-tempura',section:'Starters',name:'Deluxe Mixed Tempura',description:"King prawns, chicken and lion's mane mushrooms in a light, crispy tempura batter, served with a dressed seasonal salad and house dipping sauce.",price:1e3,dietary:[],allergens:{crustaceans:'contains',gluten:'contains',soya:'contains',sesame:'may',eggs:'may'},allergenNotes:'Shared fryer (example).',prepMins:9,optionGroups:[n('tempura',900,'Main with triple-cooked chips (\xa319.00)')]},{id:'a-kingoyster',section:'Starters',name:"Pan-Seared King Oyster Mushroom 'Scallops' (VG)",description:"King oyster mushroom 'scallops' prepared with the chef's special recipe of the day. Ask your server or see our specials board for today's garnish and accompaniments.",price:1e3,dietary:['VG'],allergens:{soya:'may',sulphites:'may'},allergenNotes:'Garnish changes daily \u2014 sign-off needed for each version.',prepMins:10,special:!0,unsigned:!0,optionGroups:[n('kingoyster',800,'Main (\xa318.00)')]},{id:'a-fishsupper',section:'Mains',name:'Fish Supper',description:'Locally landed haddock, available beer-battered or breaded, served with buttered peas, triple-cooked chips and homemade tartare sauce.',price:1800,dietary:['GF option'],allergens:{fish:'contains',gluten:'contains',eggs:'contains',milk:'contains',mustard:'may',crustaceans:'may'},allergenNotes:'Shared fryer with seafood (example).',prepMins:12,optionGroups:[{id:'fs-coat',name:'Coating',required:!0,multi:!1,choices:[{id:'fs-batter',label:'Beer-battered',priceDelta:0},{id:'fs-bread',label:'Breaded',priceDelta:0}]}]},{id:'a-lionsmane',section:'Mains',name:"Southern Fried Lion's Mane Burger (VG)",description:"Crispy southern fried lion's mane mushroom, layered with vegan cheese and garlic aioli, served with triple-cooked chips and golden onion rings.",price:1800,dietary:['VG'],allergens:{gluten:'contains',soya:'contains',mustard:'may',sesame:'may'},prepMins:12},{id:'a-pie',section:'Mains',name:'Steak & Ale Pie',description:'Slow-braised beef in a rich ale jus beneath golden all-butter puff pastry, served with buttered seasonal vegetables.',price:1800,dietary:[],allergens:{gluten:'contains',milk:'contains',eggs:'contains',celery:'contains',sulphites:'contains'},prepMins:10,optionGroups:[{id:'pie-side',name:'Served with',required:!0,multi:!1,choices:[{id:'chips',label:'Triple-cooked chips',priceDelta:0},{id:'creamed',label:'Creamed potatoes',priceDelta:0,allergens:{milk:'contains'}}]}]},{id:'a-bananablossom',section:'Mains',name:"Beer-Battered Banana Blossom 'Fish' Goujons (VG)",description:'Crisp beer-battered banana blossom goujons, dusted with locally foraged truffle seaweed seasoning, served with triple-cooked chips, garden peas and vegan tartare sauce.',price:1700,dietary:['VG'],allergens:{gluten:'contains',soya:'may',mustard:'may',fish:'may'},allergenNotes:'Shared fryer with fish (example).',prepMins:11},{id:'a-chicken',section:'Mains',name:'Roasted Breast of Chicken',description:'Golden pan-roasted chicken breast, served with creamed potatoes, buttered seasonal greens, and a fragrant lemon & thyme bouillon.',price:1900,dietary:[],allergens:{milk:'contains',celery:'contains',sulphites:'may'},prepMins:16},{id:'a-maccheese',section:'Mains',name:'Macaroni Cheese (V)',description:'Rich mature Cheddar macaroni finished with a golden cheese glaze, served with two slices of garlic bread.',price:1700,dietary:['V'],allergens:{gluten:'contains',milk:'contains',mustard:'contains',eggs:'may'},prepMins:10},{id:'a-penne',section:'Mains',name:'Cajun Chicken & Chorizo Penne Pasta',description:'Tender Cajun-spiced chicken strips, mixed peppers, red onion and smoky chorizo, tossed in a bold, creamy Cajun sauce, served with two slices of garlic bread.',price:1700,dietary:[],allergens:{gluten:'contains',milk:'contains',celery:'may',sulphites:'may'},prepMins:11},{id:'a-caesar',section:'Mains',name:'Chicken Caesar Salad',description:'Tender pan-roasted chicken breast served on a bed of baby gem lettuce with golden garlic croutons, Parmesan and a classic Caesar dressing.',price:1800,dietary:[],allergens:{gluten:'contains',milk:'contains',eggs:'contains',fish:'contains',mustard:'contains'},allergenNotes:'Caesar dressing contains anchovy (example).',prepMins:12,optionGroups:[{id:'caesar-add',name:'Optional extras',required:!1,multi:!0,choices:[{id:'caesar-bacon',label:'Add smoked Ayrshire bacon',priceDelta:150}]}]},{id:'a-moules',section:'Mains',name:'Moules Marini\xe8re',description:'Fresh Scottish mussels, steamed to perfection in a rich, creamy white wine and garlic sauce.',price:1200,dietary:[],allergens:{molluscs:'contains',milk:'contains',sulphites:'contains',celery:'may'},prepMins:10,optionGroups:[n('moules',1e3,'Main 500g with triple-cooked chips (\xa322.00)')]},{id:'a-fillet',section:'From the Grill',name:'8oz Fillet Steak',description:'Prime 8oz fillet steak served with truffled woodland mushrooms, seasonal greens, golden onion rings and triple-cooked chips.',price:3800,dietary:[],allergens:{gluten:'contains',milk:'may',sulphites:'may'},prepMins:18,optionGroups:[{id:'steak-sauce',name:'Sauce',required:!1,multi:!1,choices:[{id:'sauce-pepper',label:'Peppercorn sauce',priceDelta:0,allergens:{milk:'contains',sulphites:'contains'}},{id:'sauce-garlic',label:'Garlic butter',priceDelta:0,allergens:{milk:'contains'}}]},{id:'steak-surf',name:'Surf & turf add-on',required:!1,multi:!1,choices:[{id:'surf-prawns',label:'Garlic prawns',priceDelta:800,allergens:{crustaceans:'contains',milk:'contains'}},{id:'surf-scallops',label:'Scottish West Coast scallops',priceDelta:1e3,allergens:{molluscs:'contains',milk:'contains'}}]}]},{id:'a-claymore',section:'From the Grill',name:'The Claymore Burger',description:'One juicy 6oz homemade Scottish beef burger in a brioche bun with baby gem lettuce, tomato and gherkins, topped with cheese, smoked Ayrshire bacon and onion rings. Served with triple-cooked chips.',price:1800,dietary:[],allergens:{gluten:'contains',milk:'contains',eggs:'contains',sesame:'may',mustard:'may',sulphites:'may'},prepMins:14,optionGroups:[{id:'claymore-add',name:'Optional extras',required:!1,multi:!0,choices:[{id:'claymore-haggis',label:'Add haggis and whisky sauce',priceDelta:150,allergens:{celery:'contains',gluten:'contains'}}]}]},{id:'a-langoustines',section:"Captain's Table",name:'Whole Scottish Grilled Langoustines',description:'Locally caught whole Scottish langoustines grilled in garlic butter, served with a vibrant side salad and burnt lemon.',price:1700,dietary:[],allergens:{crustaceans:'contains',milk:'contains'},prepMins:12,optionGroups:[n('lang',1200,'Main 500g with triple-cooked chips (\xa329.00)')]},{id:'a-scallops',section:"Captain's Table",name:'Pan-Seared West Coast Scallops',description:"Scottish West Coast scallops prepared to the chef's recipe of the day. Starter and main portions \u2014 see price on Specials Board.",price:null,priceNote:'See specials board',dietary:[],allergens:{molluscs:'contains',milk:'may'},prepMins:10,special:!0,unsigned:!0},{id:'a-lobster',section:"Captain's Table",name:'Grilled Dunure Lobster',description:'Fresh Dunure lobster, caught locally by "Kitty Fisher", finished in rich garlic butter and served with a vibrant side salad, triple-cooked chips and burnt lemon. When available.',price:3500,dietary:[],allergens:{crustaceans:'contains',milk:'contains'},prepMins:20,optionGroups:[{id:'lobster-size',name:'Size',required:!0,multi:!1,choices:[{id:'lob-half',label:'Half',priceDelta:0},{id:'lob-whole',label:'Whole (\xa365.00)',priceDelta:3e3}]}]},{id:'a-crab',section:"Captain's Table",name:'Grilled Dunure Crab',description:'Freshly landed Dunure brown crab, caught locally by "Kitty Fisher", finished in rich garlic butter and served with a vibrant side salad, triple-cooked chips and burnt lemon. When available.',price:4e3,dietary:[],allergens:{crustaceans:'contains',milk:'contains'},prepMins:20,soldOut:!0},{id:'a-smorgasbord',section:'Platters',name:'Seafood Smorgasbord (serves one)',description:"250g langoustines, 3 pan-seared West Coast scallops, 250g fresh mussels, 6 garlic prawns and a roll of Scottish smoked salmon, with dressed side salad and warm crusty bread.",price:5e3,dietary:[],allergens:{crustaceans:'contains',molluscs:'contains',fish:'contains',milk:'contains',gluten:'contains',sulphites:'contains'},prepMins:22},{id:'a-deluxe',section:'Platters',name:'Deluxe Seafood Platter (serves two)',description:'One whole Dunure lobster, one whole Dunure crab, 500g whole langoustines, 500g moules marini\xe8re, pan-seared scallops, Scottish smoked salmon and 6 garlic prawns, with two portions of chips, side salad and warm crusty bread.',price:16500,dietary:[],allergens:{crustaceans:'contains',molluscs:'contains',fish:'contains',milk:'contains',gluten:'contains',sulphites:'contains'},prepMins:30},{id:'a-onionrings',section:'Sides',name:'House Beer-Battered Onion Rings (V)',description:'Crisp house beer-battered onion rings, served golden and crunchy.',price:450,dietary:['V'],allergens:{gluten:'contains',fish:'may',crustaceans:'may'},allergenNotes:'Shared fryer (example).',prepMins:6},{id:'a-garlicbread',section:'Sides',name:'Garlic Bread (V)',description:'Warm toasted garlic bread, finished with garlic & parsley butter.',price:450,dietary:['V'],allergens:{gluten:'contains',milk:'contains'},prepMins:5,optionGroups:[{id:'gb-add',name:'Optional extras',required:!1,multi:!0,choices:[{id:'gb-cheese',label:'Add cheese',priceDelta:100}]}]},{id:'a-chips',section:'Sides',name:'Triple-Cooked Chips (V)',description:'Golden triple-cooked chips, lightly tossed in Maldon sea salt.',price:450,dietary:['V'],allergens:{gluten:'may',fish:'may',crustaceans:'may'},allergenNotes:'Shared fryer (example).',prepMins:6,optionGroups:[{id:'chips-add',name:'Optional extras',required:!1,multi:!0,choices:[{id:'chips-cajun',label:'Add Cajun seasoning',priceDelta:0,allergens:{celery:'may',mustard:'may'}}]}]},{id:'a-truffle',section:'Sides',name:'Parmesan & Truffle Fries (V)',description:'Crispy fries topped with finely grated parmesan and tossed in a winter truffle infused oil.',price:500,dietary:['V'],allergens:{milk:'contains',gluten:'may',fish:'may',crustaceans:'may'},allergenNotes:'Shared fryer (example).',prepMins:6},{id:'a-salad',section:'Sides',name:'Side Salad (VG)',description:'Seasonal mixed leaves with cucumber, red onion and mixed peppers, finished with a light vinaigrette.',price:450,dietary:['VG'],allergens:{mustard:'contains',sulphites:'contains'},prepMins:3},{id:'a-brulee',section:'Desserts',name:"Chef's Cr\xe8me Br\xfbl\xe9e of the Day (V)",description:"Smooth Madagascan custard with a delicately caramelised sugar crust. Ask your server or see our specials board for today's flavour.",price:800,dietary:['V'],allergens:{milk:'contains',eggs:'contains',treenuts:'may'},prepMins:4},{id:'a-crumble',section:'Desserts',name:'Seasonal Fruit Crumble (V)',description:'Slow-cooked seasonal fruit topped with a golden buttery crumble.',price:800,dietary:['V'],allergens:{gluten:'contains',milk:'contains',treenuts:'may'},prepMins:6,optionGroups:[s('crumble')]},{id:'a-stp',section:'Desserts',name:'Sticky Toffee Pudding (V)',description:'A rich, homemade steamed date pudding, drenched in our signature homemade butterscotch sauce.',price:800,dietary:['V'],allergens:{gluten:'contains',milk:'contains',eggs:'contains',sulphites:'may'},prepMins:5,optionGroups:[s('stp')]},{id:'a-cheesecake',section:'Desserts',name:'Cheesecake of the Day (V)',description:'A smooth, creamy cheesecake on a buttery biscuit base. Gluten-free and vegan options available.',price:800,dietary:['V'],allergens:{gluten:'contains',milk:'contains',eggs:'may',treenuts:'may'},prepMins:3,optionGroups:[s('cheesecake')]},{id:'a-affogato',section:'Desserts',name:'Affogato (V)',description:'Two scoops of creamy vanilla ice cream with a freshly brewed shot of Italian espresso poured over. Vegan options available.',price:800,dietary:['V'],allergens:{milk:'contains',eggs:'may'},prepMins:3},{id:'a-mini',section:'Mini Anchors (under 12s)',name:'Mini Anchors meal',description:'Under 12s only. Served with peas or beans. Includes a diluting juice drink & 2 scoops of ice cream. GF options available.',price:900,dietary:['GF option'],allergens:{gluten:'contains',milk:'contains'},prepMins:10,optionGroups:[{id:'mini-main',name:'Choose a meal',required:!0,multi:!1,choices:[{id:'mini-burger',label:'Cheeseburger & chips',priceDelta:0,allergens:{sesame:'may',eggs:'may'}},{id:'mini-fish',label:'Fish goujons & chips',priceDelta:0,allergens:{fish:'contains',eggs:'may'}},{id:'mini-mac',label:"Mac 'n' cheese & chips (V)",priceDelta:0,allergens:{mustard:'may'}},{id:'mini-chicken',label:'Chicken goujons & chips',priceDelta:0,allergens:{eggs:'may'}}]},{id:'mini-veg',name:'With',required:!0,multi:!1,choices:[{id:'mini-peas',label:'Peas',priceDelta:0},{id:'mini-beans',label:'Beans',priceDelta:0}]}]}],o=['Starters','Mains','From the Grill',"Captain's Table",'Platters','Sides','Desserts','Mini Anchors (under 12s)'],l=t.map(({unsigned:s,soldOut:n,...t})=>({...t,restaurantId:"anchorage",soldOut:!!n,signOff:s?null:i}))},1013,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SCOTTISH_BANK_HOLIDAYS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"BANK_HOLIDAY_SOURCE",{enumerable:!0,get:function(){return n}});const t=[{date:"2026-11-30",title:"St Andrew\u2019s Day",notes:""},{date:"2026-12-25",title:"Christmas Day",notes:""},{date:"2026-12-28",title:"Boxing Day",notes:"Substitute day"},{date:"2027-01-01",title:"New Year\u2019s Day",notes:""},{date:"2027-01-04",title:"2nd January",notes:"Substitute day"},{date:"2027-03-26",title:"Good Friday",notes:""},{date:"2027-05-03",title:"Early May bank holiday",notes:""},{date:"2027-05-31",title:"Spring bank holiday",notes:""},{date:"2027-08-02",title:"Summer bank holiday",notes:""},{date:"2027-11-30",title:"St Andrew\u2019s Day",notes:""},{date:"2027-12-27",title:"Christmas Day",notes:"Substitute day"},{date:"2027-12-28",title:"Boxing Day",notes:"Substitute day"},{date:"2028-01-03",title:"New Year\u2019s Day",notes:"Substitute day"},{date:"2028-01-04",title:"2nd January",notes:"Substitute day"},{date:"2028-04-14",title:"Good Friday",notes:""},{date:"2028-05-01",title:"Early May bank holiday",notes:""},{date:"2028-05-29",title:"Spring bank holiday",notes:""},{date:"2028-08-07",title:"Summer bank holiday",notes:""},{date:"2028-11-30",title:"St Andrew\u2019s Day",notes:""},{date:"2028-12-25",title:"Christmas Day",notes:""},{date:"2028-12-26",title:"Boxing Day",notes:""}],n='gov.uk/bank-holidays.json (Scotland)'},1014,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ANCHORAGE_PAY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ANCHORAGE_KITCHEN",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_KITCHEN_OLD",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"restaurants",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"demoMenus",{enumerable:!0,get:function(){return h}});const t={slotMinutes:15,slotCap:3,bufferMins:5,leadMins:20,takeawayPaused:!1,bookingCoversPerSlot:16,savedCardFromParty:6,depositFromParty:10,depositPerHead:1e3,noShowFeePerHead:1500,stampTarget:8,stampReward:'Free dessert',stampMinSpend:1e3,capacityPerHour:48,walkInShare:.35,turnMins:75,orderAtTable:!0},n={tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},o={0:['12:30','19:00'],1:null,2:null,3:['12:00','19:00'],4:['12:00','19:00'],5:['12:00','20:00'],6:['12:00','20:00']},s={0:['12:30','20:00'],1:null,2:null,3:['12:00','19:00'],4:['12:00','19:00'],5:['12:00','20:30'],6:['12:00','20:30']},l=[{id:'anchorage',name:'The Anchorage',tagline:'Harbourside seafood & Scottish produce',location:'Harbour View, Dunure, South Ayrshire',fictional:!1,phone:'01292 502826',website:'anchoragedunure.com',kitchenHours:o,hoursNote:'Kitchen (food) hours from Gordon, 30 Oct 2026: closed Mon\u2013Tue. The closing time is last food orders. Bar hours not set.',settings:{...t,orderAtTable:!1,pay:n},sections:[]},{id:'saltmarsh',name:'The Venue',tagline:'FICTIONAL demo restaurant \u2014 shows multi-tenancy',location:'Port Ailsa (fictional town)',fictional:!0,kitchenHours:{0:['12:00','20:00'],1:['12:00','20:00'],2:['12:00','20:00'],3:['12:00','20:00'],4:['12:00','21:00'],5:['12:00','21:00'],6:['12:00','21:00']},settings:{...t,slotCap:4,stampTarget:6,stampReward:'Free side',capacityPerHour:30},sections:['Small plates','Mains','Puddings']},{id:'brae',name:'Brae Bakehouse',tagline:'FICTIONAL demo caf\xe9 \u2014 shows multi-tenancy',location:'Kilbrae (fictional village)',fictional:!0,kitchenHours:{0:['09:00','16:00'],1:['09:00','16:00'],2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},settings:{...t,slotCap:5,slotMinutes:15,stampTarget:10,stampReward:'Free coffee & cake',capacityPerHour:24,bookingCoversPerSlot:10},sections:['Bakes','Lunch','Hot drinks']}],c={by:'Fictional demo',at:'2026-10-26'},u=(t,n,o,s,l,u,h,f,p=[])=>({id:n,restaurantId:t,section:o,name:s,description:l,price:u,allergens:h,prepMins:f,dietary:p,soldOut:!1,signOff:c}),h=[u('saltmarsh','s-beets','Small plates','Roast beetroot & whipped feta','Fictional dish for the demo.',750,{milk:'contains',treenuts:'may'},6,['V']),u('saltmarsh','s-squid','Small plates','Salt & pepper squid','Fictional dish for the demo.',850,{molluscs:'contains',gluten:'contains'},7),u('saltmarsh','s-hake','Mains','Pan-roast hake, mussel broth','Fictional dish for the demo.',1950,{fish:'contains',molluscs:'contains',milk:'contains',celery:'contains'},15),u('saltmarsh','s-risotto','Mains','Wild mushroom risotto','Fictional dish for the demo.',1600,{milk:'contains',celery:'contains',sulphites:'contains'},16,['V']),u('saltmarsh','s-cranachan','Puddings','Cranachan','Fictional dish for the demo.',700,{milk:'contains',gluten:'contains'},3,['V']),u('brae','b-scone','Bakes','Cheese scone','Fictional dish for the demo.',350,{gluten:'contains',milk:'contains',eggs:'contains'},2,['V']),u('brae','b-caramel','Bakes','Millionaire\u2019s shortbread','Fictional dish for the demo.',300,{gluten:'contains',milk:'contains',soya:'may'},1,['V']),u('brae','b-toastie','Lunch','Ham & mustard toastie','Fictional dish for the demo.',750,{gluten:'contains',milk:'contains',mustard:'contains'},6),u('brae','b-soup','Lunch','Lentil soup & bread','Fictional dish for the demo.',600,{gluten:'contains',celery:'contains'},4,['VG']),u('brae','b-flat','Hot drinks','Flat white','Fictional dish for the demo.',330,{milk:'contains'},2,['V'])]},1015,[]); +__d(function(e,a,l,r,o,t,h){o.exports={venue:"The Anchorage",note:"From Gordon 28 Oct 2026; layout from Gordon's floor-plan photo 29 Oct 2026 (positions, sizes, shapes, labels scaled from the photo, one scale for all areas). Photo shows MT12 and no MT8: table 8 replaced by 12. Gordon confirmed 29 Oct: no table 8; MT11 and MT12 both exist, MT11 keeps 2 seats, MT12 = 2 seats. No tables 4 or 8. No joined tables: Gordon confirmed 29 Oct that DT1 and DT2 are not joined.",areas:[{name:"Public Bar",label:"Dog friendly area (Public Bar), Area 1",colour:"#CFA45F",server:"BR",dogFriendly:!0,tables:[[1,4],[2,4],[3,5],[5,2],[6,4]],layout:{1:{label:"DT1",shape:"rect",x:600,y:125,w:205,h:90},2:{label:"DT2",shape:"rect",x:395,y:130,w:100,h:190},3:{label:"DT3",shape:"rect",x:205,y:120,w:110,h:245},5:{label:"DT5",shape:"square",x:500,y:395,w:105,h:105},6:{label:"DT6",shape:"rect",x:195,y:395,w:205,h:110}}},{name:"Main Restaurant",label:"Main restaurant (no pets)",colour:"#8EC5FF",server:"SV",dogFriendly:!1,tables:[[7,5],[9,7],[10,4],[11,2],[12,2],[13,4],[14,4],[15,4],[16,2]],layout:{7:{label:"MT7",shape:"rect",x:590,y:410,w:225,h:115},9:{label:"MT9",shape:"rect",x:560,y:105,w:260,h:110},10:{label:"MT10",shape:"square",x:430,y:400,w:130,h:130},11:{label:"MT11",shape:"rect",x:545,y:270,w:115,h:90},12:{label:"MT12",shape:"rect",x:400,y:270,w:120,h:95},13:{label:"MT13",shape:"rect",x:400,y:100,w:90,h:115},14:{label:"MT14",shape:"rect",x:185,y:420,w:230,h:100},15:{label:"MT15",shape:"rect",x:190,y:220,w:165,h:145},16:{label:"MT16",shape:"rect",x:185,y:105,w:125,h:80}}},{name:"Sitooterie",label:"Sitooterie (fully covered conservatory, no pets)",colour:"#C79BE8",server:"DM",dogFriendly:!1,tables:[[17,2],[18,6],[19,4],[20,6],[21,4],[22,4],[23,4]],layout:{17:{label:"ST17",shape:"square",x:760,y:325,w:110,h:110},18:{label:"ST18",shape:"rect",x:605,y:135,w:270,h:115},19:{label:"ST19",shape:"rect",x:460,y:160,w:105,h:150},20:{label:"ST20",shape:"rect",x:135,y:125,w:265,h:120},21:{label:"ST21",shape:"rect",x:120,y:305,w:110,h:175},22:{label:"ST22",shape:"rect",x:255,y:310,w:115,h:175},23:{label:"ST23",shape:"rect",x:410,y:350,w:110,h:155}}},{name:"Beer Garden",label:"Outdoor beer garden (weather permitting, no shelter, pets allowed)",colour:"#7BD88F",server:"GD",dogFriendly:!0,outdoor:!0,weatherDependent:!0,tables:[[24,4],[25,4],[26,4],[27,6],[28,6],[29,4],[30,4],[31,4]],layout:{24:{label:"BGT24",shape:"round",x:740,y:70,w:130,h:130},25:{label:"BGT25",shape:"round",x:515,y:50,w:135,h:135},26:{label:"BGT26",shape:"round",x:310,y:50,w:135,h:135},27:{label:"BGT27",shape:"rect",x:560,y:235,w:280,h:115},28:{label:"BGT28",shape:"rect",x:245,y:235,w:270,h:110},29:{label:"BGT29",shape:"rect",x:210,y:365,w:190,h:60},30:{label:"BGT30",shape:"rect",x:180,y:445,w:190,h:55},31:{label:"BGT31",shape:"rect",x:130,y:520,w:215,h:60}}}],photoScale:1.8,joins:[]}},1016,[]); +__d(function(_g,_r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canEditCards",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canSignOffCards",{enumerable:!0,get:function(){return i}}),e.suggestForIngredient=a,e.suggestAllergens=o,Object.defineProperty(e,"suggestedBy",{enumerable:!0,get:function(){return l}}),e.unresolved=c,e.applySuggestions=function(n){const t={...n.allergens};for(const i of c(n))t[i]='contains';return t},Object.defineProperty(e,"cardState",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"STATE_LABEL",{enumerable:!0,get:function(){return f}}),e.signOffBlock=function(n){if(!n.dish.trim())return'Give the dish a name first.';const t=c(n);return t.length?`Check the suggested allergens first: ${t.map(g).join(', ')}.`:n.allergensConfirmed?null:'Confirm the allergen list first.'},Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"CONTENT_FIELDS",{enumerable:!0,get:function(){return p}}),e.editCard=function(n,t,i,r){const{confirmAllergens:s,...a}=t,l=Object.keys(a).filter(t=>!h(a[t],n[t]));let u={...n};for(const n of l)u[n]=a[n];const f=l.some(n=>'allergens'===n||'dismissed'===n||'ingredients'===n);f&&!h(o(u.ingredients),o(n.ingredients))&&(u.allergensConfirmed=void 0);f&&(l.includes('allergens')||l.includes('dismissed'))&&(u.allergensConfirmed=void 0);let g=!1;!s||u.allergensConfirmed||c(u).length||(u.allergensConfirmed={by:i,at:r},g=!0);const m=l.length>0||g,p=l.length>0&&!!n.signOff;if(!m)return{card:n,changed:!1,resetSignOff:!1};l.length&&(u={...u,signOff:null,version:n.version+1});return{card:{...u,updatedAt:r,updatedBy:i},changed:m,resetSignOff:p}},e.signOffCard=function(n,t,i){return{...n,signOff:{by:t,at:i},wasLive:!0,updatedAt:i,updatedBy:t}},e.overlayItem=function(n,t){return t?{...n,name:t.dish,section:t.section,price:t.price,allergens:t.allergens,allergenNotes:t.allergenNotes,signOff:t.signOff?{by:t.signOff.by,at:t.signOff.at.slice(0,10)}:null,hidden:n.hidden||!t.signOff&&!t.wasLive,recipeCardId:t.id}:n},e.dishesFor=function(n,t){const i=n.filter(n=>!n.hidden),r=i.filter(n=>t.some(t=>'contains'===n.allergens[t])),s=i.filter(n=>!r.includes(n)&&t.some(t=>'may'===n.allergens[t])),a=i.filter(n=>!r.includes(n)&&!s.includes(n));return{contains:r,may:s,free:a}},e.filterCards=function(n,t,i,r="free-from"){const s=t.toLowerCase().split(/\s+/).filter(Boolean);return n.filter(n=>{const t=[n.dish,n.section,...n.ingredients.map(n=>n.name)].join(' ').toLowerCase();return!!s.every(n=>t.includes(n))&&(!i.length||('free-from'===r?i.every(t=>!n.allergens[t]):i.some(t=>!!n.allergens[t])))})},e.uuid=function(){const n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();const t=Array.from({length:16},()=>Math.floor(256*Math.random()));t[6]=15&t[6]|64,t[8]=63&t[8]|128;const i=t.map(n=>n.toString(16).padStart(2,'0')).join('');return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`},e.uuidFrom=function(n){let t='';for(let i=0;i<4;i++){let r=2166136261^2654435761*i;for(let t=0;t>>0;t+=r.toString(16).padStart(8,'0')}const i=t.slice(0,12)+'4'+t.slice(13,16)+(3&parseInt(t[16],16)|8).toString(16)+t.slice(17,32);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20,32)}`},Object.defineProperty(e,"RECIPE_CARD_EXTRA_COLUMNS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STEP_SEP",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"photoPath",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RECIPE_PHOTO_BUCKET",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"RECIPE_CARD_TABLE",{enumerable:!0,get:function(){return v}}),e.cardToRow=function(n,t){return{row:{id:n.id,venue_id:t,dish:n.dish,ingredients:n.ingredients.map(({name:n,qty:t,unit:i,allergens:r})=>({name:n,qty:t,unit:i,...r?.length?{allergens:r}:{}})),method:n.steps.join(y),allergens:m(n.allergens,'contains'),may_contain:m(n.allergens,'may'),photo_url:!n.photo||n.photo.startsWith('local:')||n.photo.startsWith('asset:')?null:n.photo,signed_off_by:n.signOff?.by??null,signed_off_at:n.signOff?.at??null,updated_at:n.updatedAt},extra:{menu_item_id:n.menuItemId,section:n.section,price_pence:n.price,dismissed:n.dismissed,allergen_notes:n.allergenNotes??null,allergens_confirmed_by:n.allergensConfirmed?.by??null,allergens_confirmed_at:n.allergensConfirmed?.at??null,was_live:n.wasLive,origin:n.origin,version:n.version,updated_by:n.updatedBy}}},e.rowToCard=function(n,t,i={}){const r={};n.may_contain.forEach(n=>{r[n]='may'}),n.allergens.forEach(n=>{r[n]='contains'});const s=n.updated_at??(new Date).toISOString();return{id:n.id,restaurantId:t,menuItemId:i.menu_item_id??n.id,dish:n.dish,section:i.section??'Mains',price:i.price_pence??null,photo:n.photo_url??void 0,ingredients:n.ingredients.map((t,i)=>({id:`${n.id}-i${i}`,...t})),steps:n.method?n.method.split(y).filter(n=>n.trim()):[],allergens:r,dismissed:i.dismissed??[],allergenNotes:i.allergen_notes??void 0,allergensConfirmed:i.allergens_confirmed_by?{by:i.allergens_confirmed_by,at:i.allergens_confirmed_at}:void 0,signOff:n.signed_off_by&&n.signed_off_at?{by:n.signed_off_by,at:n.signed_off_at}:null,wasLive:i.was_live??!!n.signed_off_by,origin:i.origin??'new',version:i.version??1,createdAt:s,updatedAt:s,updatedBy:i.updated_by??''}};var n=_r(d[0]);const t=n=>'head-chef'===n||'manager'===n||'owner'===n,i=n=>'head-chef'===n,r=[[/\b(flour(?!y)|wheat|bread|crumb|panko|pastry|brioche|buns?\b|crouton|crostini|batter|beer|ale\b|lager|stout|barley|malt|rye|spelt|oat|couscous|semolina|pasta|penne|macaroni|spaghetti|noodle|biscuit|sponge|crumble|roux|tempura|digestive|self.raising)/i,['gluten']],[/\b(prawn|langoustine|lobster|crab|shrimp|crayfish|scampi|shellfish)/i,['crustaceans']],[/\b(mussel|scallop|clam|cockle|squid|calamari|octopus|whelk|winkle|oyster(?! mushroom)|oyster sauce)/i,['molluscs']],[/\b(egg|mayonnaise|mayo|aioli|tartare|hollandaise|meringue|custard|brioche|bearnaise)/i,['eggs']],[/\b(fish(?!er)|haddock|cod|salmon|hake|anchov|tuna|mackerel|trout|sea bass|monkfish|pollock|halibut|kipper|worcester|fish sauce|caesar)/i,['fish']],[/\b(peanut|groundnut|satay)/i,['peanuts']],[/\b(almond|hazelnut|walnut|cashew|pecan|pistachio|macadamia|brazil nut|praline|frangipane|marzipan|pesto)/i,['treenuts']],[/\b(soy|soya|tofu|edamame|miso|tamari|tempeh)/i,['soya']],[/\b(milk|butter(?!nut)|cream|cheese|cheddar|parmesan|mozzarella|brie|yoghurt|yogurt|cr[e\xe8]me|ghee|ice cream|custard|butterscotch|toffee|fudge|buttermilk|mascarpone|ricotta|whey)/i,['milk']],[/\b(celery|celeriac|stock cube|beef stock|chicken stock|veg(etable)? stock)/i,['celery']],[/\b(mustard|dijon|vinaigrette|piccalilli)/i,['mustard']],[/\b(sesame|tahini|hummus|houmous)/i,['sesame']],[/\b(wine|vinegar|dried apricot|dried fruit|sulphite|sulfite|prosecco|cider|port\b|sherry|dates?\b|raisin|sultana)/i,['sulphites']],[/\blupin/i,['lupin']]],s=[[/gluten.free|\bgf\b/i,'gluten'],[/dairy.free|vegan (butter|cheese|cream)|oat milk|plant.based/i,'milk'],[/egg.free|vegan mayo/i,'eggs']];function a(t){const i=new Set(t.allergens??[]);for(const[n,s]of r)n.test(t.name)&&s.forEach(n=>i.add(n));for(const[n,r]of s)n.test(t.name)&&!(t.allergens??[]).includes(r)&&i.delete(r);return n.ALLERGENS.map(n=>n.id).filter(n=>i.has(n))}function o(t){const i=new Set(t.flatMap(a));return n.ALLERGENS.map(n=>n.id).filter(n=>i.has(n))}const l=(n,t)=>n.filter(n=>a(n).includes(t)).map(n=>n.name);function c(n){return o(n.ingredients).filter(t=>!n.allergens[t]&&!n.dismissed.includes(t))}const u=n=>n.signOff?'signed-off':'awaiting',f={'signed-off':'Signed off',awaiting:'Awaiting sign-off'};const g=t=>n.ALLERGENS.find(n=>n.id===t)?.short??t,m=(t,i)=>n.ALLERGENS.filter(n=>i?t[n.id]===i:!!t[n.id]).map(n=>n.id),p=['dish','section','price','photo','ingredients','steps','allergens','dismissed','allergenNotes'],h=(n,t)=>JSON.stringify(n??null)===JSON.stringify(t??null);const b={menu_item_id:'text',section:'text',price_pence:'integer null',dismissed:'text[]',allergen_notes:'text',allergens_confirmed_by:'text',allergens_confirmed_at:'timestamptz',was_live:'boolean',origin:'text',version:'integer',updated_by:'text'},y='\n',_=(n,t)=>`${n}/${t.id}-v${t.version}.jpg`,O='recipe-photos',v='recipe_cards'},1017,[792]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MESSAGING_CONFIG",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"previewProvider",{enumerable:!0,get:function(){return t}}),_e.relayProvider=n,Object.defineProperty(_e,"isLive",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"activeProvider",{enumerable:!0,get:function(){return s}});const e={mode:'preview',endpoint:'',smsService:'Twilio',emailService:'Postmark',smsSenderId:'ANCHORAGE',fromEmail:'bookings@your-venue.co.uk'},t={id:'preview',label:'Preview mode (nothing is sent)',live:!1,deliver:async()=>({ok:!0})};function n(e){return{id:'relay',label:'Your messaging server',live:!0,deliver:async t=>{try{const n=await fetch(e,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({channel:t.channel,to:t.to,subject:t.subject,body:t.body,html:t.html,ref:t.ref,kind:t.kind,restaurantId:t.restaurantId})});if(!n.ok)return{ok:!1,error:`Server said ${n.status}`};return{ok:!0,providerId:(await n.json().catch(()=>({}))).id}}catch(e){return{ok:!1,error:e?.message??'Network error'}}}}}const o=()=>'live'===e.mode&&!!e.endpoint,s=()=>o()?n(e.endpoint):t},1018,[]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEFAULT_TEMPLATES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PLACEHOLDERS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"teamName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"longDate",{enumerable:!0,get:function(){return u}}),e.bookingVars=function(n,r){const o=n.allergies.map(n=>`${(0,t.allergenLabel)(n.allergen).toLowerCase()}`).join(', '),a=n.allergies.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity).toLowerCase()})`).join(', '),i=`${n.partySize} ${1===n.partySize?'person':'people'}`,s={...c(r),first:l(n.name),name:n.name.trim(),date:u(n.date),time:n.time,covers:i,ref:n.ref};return{sms:{...s,allergy:n.allergies.length?` We\u2019ve noted the allergy (${o}) and the team will check it with you when you arrive.`:'',note:'',details:''},email:{...s,allergy:n.allergies.length?`Thank you for telling us about: ${a}. Our team will go through this with you when you arrive, and every dish for your table is checked at each step, from the kitchen to your table.`:'',note:n.notes.trim()?`Your note to us: "${n.notes.trim()}". We\u2019ll make sure the team sees it.`:'',details:[`Date: ${u(n.date)}`,`Time: ${n.time}`,`Table for: ${i}`,`Reference: ${n.ref}`].join('\n')}}},e.orderVars=function(r,o){const a=r.lines.reduce((t,n)=>t+n.qty,0),i=r.readyBy??r.slotTime,s=i?`at ${m(i)}`:'time to be confirmed',d=r.allergies.map(n=>(0,t.allergenLabel)(n.allergen).toLowerCase()).join(', '),u=r.allergies.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity).toLowerCase()})`).join(', '),y={...c(o),first:l(r.customerName),name:r.customerName,ref:r.ref,items:`${a} ${1===a?'item':'items'}`,total:(0,n.gbp)(r.total),collect:s,date:'',time:i?m(i):'',covers:''};return{sms:{...y,allergy:r.allergies.length?` We\u2019ve noted your allergy (${d}); the kitchen checks every item.`:'',itemList:'',details:'',note:''},email:{...y,allergy:r.allergies.length?`You told us about: ${u}. The kitchen signs off every item against it before your order leaves the pass.`:'',itemList:r.lines.map(t=>`${t.qty} \xd7 ${t.name}${t.choices.length?` (${t.choices.join(', ')})`:''}`).join('\n'),details:[`Order: ${r.ref}`,`Collection: ${i?m(i):'time to be confirmed'}`,`Items: ${a}`,`Total: ${(0,n.gbp)(r.total)}`].join('\n'),note:''}}},e.fill=y,Object.defineProperty(e,"fillEmailText",{enumerable:!0,get:function(){return h}}),e.emailHtml=function(t,n){const r=n.accent??'#B8893E',o=t.split(/\n{2,}/).map(t=>{const n=t.split('\n');return n.length>1&&n.every(t=>/^[^:]{2,22}:\s.+/.test(t))?`${n.map(t=>{const n=t.indexOf(':');return``}).join('')}
${p(t.slice(0,n))}${p(t.slice(n+1).trim())}
`:n.length>1&&n.every(t=>/^\d+ \xd7/.test(t))?`
    ${n.map(t=>`
  • ${p(t)}
  • `).join('')}
`:`

${n.map(p).join('
')}

`}).join('');return`${p(n.preheader??'')}
${p(n.venue.toUpperCase())}
${o}
You\u2019re getting this because you made a booking or order with ${p(n.venue)}. It\u2019s about your booking only, not marketing.
`},e.smsParts=function(t){const n=b(t),r=!f.test(n),o=n.length,a=r?o<=70?1:Math.ceil(o/67):o<=160?1:Math.ceil(o/153);return{chars:o,parts:a,unicode:r}},Object.defineProperty(e,"toGsm",{enumerable:!0,get:function(){return b}});var t=_r(_d[0]),n=_r(_d[1]);const r={booking:{title:'Booking confirmed',when:'Every booking: online, phone or in person (and when you confirm a request)'},request:{title:'Booking request received',when:'Online bookings that need you to confirm them first'},declined:{title:'Booking request declined',when:'When you decline a booking request'},order:{title:'Takeaway order confirmed',when:'Every takeaway order from the app (and phone orders with a number)'}},o={booking:{sms:'Hi {first}, you\u2019re booked in at {venue}: {date} at {time}, {covers}. Ref {ref}.{allergy} Need to change or cancel? Just call {venuePhone}. See you soon, {team}',subject:'You\u2019re booked in at {venue}: {date} at {time}',body:'Hi {first},\n\nThank you for booking with us. We\u2019re really looking forward to welcoming you.\n\n{details}\n\n{allergy}\n\n{note}\n\nIf your plans change, just give us a ring on {venuePhone} and we\u2019ll happily move or cancel it for you. Please quote {ref}.\n\nYou\u2019ll find us at {address}.\n\nWarm wishes,\n{team}'},request:{sms:'Hi {first}, thanks for your booking request at {venue} for {date} at {time}, {covers}. We\u2019ll text you shortly to confirm. Ref {ref}. Questions? Call {venuePhone}. {team}',subject:'We\u2019ve got your booking request for {date}',body:'Hi {first},\n\nThank you for your booking request. A member of the team will look at it and confirm with you very shortly.\n\n{details}\n\n{allergy}\n\n{note}\n\nIf you have any questions in the meantime, call us on {venuePhone} and quote {ref}.\n\nWarm wishes,\n{team}'},declined:{sms:'Hi {first}, we\u2019re so sorry, we can\u2019t fit {covers} in on {date} at {time}. Please call {venuePhone} and we\u2019ll do our best to find another time. {team}',subject:'About your booking request for {date}',body:'Hi {first},\n\nThank you for asking to book with us. We\u2019re really sorry, but we can\u2019t fit your party in on {date} at {time}.\n\nWe\u2019d love to find another time that works. Give us a ring on {venuePhone} and we\u2019ll do our best.\n\nWith apologies and warm wishes,\n{team}'},order:{sms:'Hi {first}, thanks for your order {ref} from {venue}: {items}, {total}. Collection {collect}.{allergy} Questions? Call {venuePhone}. {team}',subject:'Your {venue} order {ref}',body:'Hi {first},\n\nThank you for your order. The kitchen has it and we\u2019ll have it ready for you.\n\n{details}\n\n{itemList}\n\n{allergy}\n\nAny questions, or need to change something? Call us on {venuePhone} and quote {ref}.\n\nYou\u2019ll find us at {address}.\n\nEnjoy!\n{team}'}},a=[{key:'first',what:'Guest\u2019s first name'},{key:'name',what:'Name on the booking'},{key:'venue',what:'Venue name'},{key:'date',what:'Day and date'},{key:'time',what:'Time'},{key:'covers',what:'e.g. 4 people'},{key:'ref',what:'Reference'},{key:'venuePhone',what:'Venue phone'},{key:'address',what:'Venue address'},{key:'team',what:'e.g. The Anchorage team'},{key:'allergy',what:'Allergy reassurance (only if one was noted)'},{key:'note',what:'Their note (email only)'},{key:'details',what:'Details box (email only)'},{key:'items',what:'Orders: e.g. 3 items'},{key:'total',what:'Orders: total'},{key:'collect',what:'Orders: collection time'},{key:'itemList',what:'Orders: list of items (email)'}],i=t=>/^the\s/i.test(t.trim())?`${t.trim()} team`:`The ${t.trim()} team`,l=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||'there',s=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=['January','February','March','April','May','June','July','August','September','October','November','December'],u=t=>{const[n,r,o]=t.split('-').map(Number),a=new Date(n,r-1,o,12);return`${s[a.getDay()]} ${o} ${d[r-1]}`},m=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`};function c(t){return{venue:t.name,venuePhone:t.phone||'the restaurant',address:t.address||t.location,team:i(t.name)}}function y(t,n){return t.replace(/\{(\w+)\}/g,(t,r)=>r in n?n[r]:t).replace(/[ \t]{2,}/g,' ').replace(/ +([.,])/g,'$1').trim()}const h=(t,n)=>y(t,n).split(/\n{2,}/).map(t=>t.trim()).filter(Boolean).join('\n\n'),p=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"');const f=/^[A-Za-z0-9 \r\n@\xa3$\xa5\xe8\xe9\xf9\xec\xf2\xc7\xd8\xf8\xc5\xe5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\xc6\xe6\xdf\xc9!"#\xa4%&'()*+,\-./:;<=>?\xa1\xc4\xd6\xd1\xdc\xa7\xbf\xe4\xf6\xf1\xfc\xe0^{}\\[~\]|\u20ac]*$/;const b=t=>t.replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').replace(/[\u2013\u2014]/g,'-').replace(/\u2026/g,'...').replace(/\xd7/g,'x')},1019,[792,794]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.ukPhone=function(t){const s=(t??'').trim();if(!s)return{ok:!1,error:'A phone number is needed so we can send the confirmation.'};let l=s.replace(/[\s\-().]/g,'');l.startsWith('+44')?l='0'+l.slice(3):l.startsWith('0044')?l='0'+l.slice(4):/^44\d{10}$/.test(l)&&(l='0'+l.slice(2));l.startsWith('0(0)')&&(l=l.replace('0(0)','0'));l.startsWith('00')&&(l=l.slice(1));if(!/^0\d+$/.test(l))return{ok:!1,error:'Please use numbers only, for example 07700 900123.'};const n=/^07\d{9}$/.test(l),o=/^0[1238]\d{8,9}$/.test(l);if(!n&&!o)return{ok:!1,error:'That doesn\u2019t look like a UK mobile or landline. For example 07700 900123 or 01292 502826.'};const c=n?`${l.slice(0,5)} ${l.slice(5)}`:/^02/.test(l)?`${l.slice(0,3)} ${l.slice(3,7)} ${l.slice(7)}`:/^0(3|8)/.test(l)?`${l.slice(0,4)} ${l.slice(4,7)} ${l.slice(7)}`:`${l.slice(0,5)} ${l.slice(5)}`;return{ok:!0,e164:'+44'+l.slice(1),pretty:c,kind:n?'mobile':'landline'}},e.emailOk=function(t){const s=(t??'').trim();return!s||/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(s)}},1020,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shallow",{enumerable:!0,get:function(){return c}});const t=t=>Symbol.iterator in t,n=t=>"entries"in t,o=(t,n)=>{const o=t instanceof Map?t:new Map(t.entries()),s=n instanceof Map?n:new Map(n.entries());if(o.size!==s.size)return!1;for(const[t,n]of o)if(!s.has(t)||!Object.is(n,s.get(t)))return!1;return!0},s=(t,n)=>{const o=t[Symbol.iterator](),s=n[Symbol.iterator]();let c=o.next(),u=s.next();for(;!c.done&&!u.done;){if(!Object.is(c.value,u.value))return!1;c=o.next(),u=s.next()}return!!c.done&&!!u.done};function c(c,u){return!!Object.is(c,u)||"object"==typeof c&&null!==c&&"object"==typeof u&&null!==u&&(Object.getPrototypeOf(c)===Object.getPrototypeOf(u)&&(t(c)&&t(u)?n(c)&&n(u)?o(c,u):s(c,u):o({entries:()=>Object.entries(c)},{entries:()=>Object.entries(u)})))}},1021,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"orderAtTableOn",{enumerable:!0,get:function(){return t}});const t=t=>!!t&&(t.settings.orderAtTable??!0)},1022,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCardStore",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"photoStorageFull",{enumerable:!0,get:function(){return y}}),_e.setStoragePhotoResolver=function(e){M=e},_e.cachePhotoAs=function(e,t){if(O.getState().photos[e]===t)return;O.setState(r=>({photos:{...r.photos,[e]:t}}))},Object.defineProperty(_e,"readLocalPhoto",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"localRecipeCards",{enumerable:!0,get:function(){return k}}),_e.ensureCards=_;var e,t=_r(d[0]),r=(e=t)&&e.__esModule?e:{default:e};_r(d[1]);var n=_r(d[2]),s=_r(d[3]),o=_r(d[4]),a=_r(d[5]),c=_r(d[6]),u=_r(d[7]),f=_r(d[8]);const l='covercharge-recipecards-v1',m='covercharge-recipephotos-v1',h=()=>{try{return(0,f.nowFrom)(f.useStore.getState().clock)}catch{return new Date}},p=(0,n.create)()((0,s.persist)(()=>({cards:[],removed:[],log:[]}),{name:l,storage:(0,s.createJSONStorage)(()=>r.default),version:1}));let S=!1;const I={getItem:e=>r.default.getItem(e),setItem:async(e,t)=>{try{await r.default.setItem(e,t),S=!1}catch{S=!0}},removeItem:e=>r.default.removeItem(e)},y=()=>S,O=(0,n.create)()((0,s.persist)(()=>({photos:{}}),{name:m,storage:(0,s.createJSONStorage)(()=>I),version:1})),w={lobster:_r(d[9]),skink:_r(d[10]),fishsupper:_r(d[11]),moules:_r(d[12]),stp:_r(d[13])};let b=0;const v=(e,t,r)=>{const n={id:`cl-${Date.now().toString(36)}${(b++).toString(36)}`,cardId:e.id,rid:e.restaurantId,at:h().toISOString(),by:t,text:r};p.setState(e=>({log:[n,...e.log].slice(0,300)}));try{f.useStore.getState().addAudit(e.restaurantId,'menu',`Recipe card: ${e.dish}: ${r} (${t})`)}catch{}},C=e=>p.setState(t=>({cards:t.cards.some(t=>t.id===e.id)?t.cards.map(t=>t.id===e.id?e:t):[...t.cards,e]}));let P=null;function A(){const e=p.getState().cards;if(P?.cards!==e){const t=new Map,r=new Map;for(const n of e)t.set(n.restaurantId,[...t.get(n.restaurantId)??[],n]),r.set(n.menuItemId,n);P={cards:e,byRid:t,byItem:r}}return P}const E=[];function j(e){if(!(0,o.canEditCards)(e.role))throw new Error('Only the head chef and managers can edit recipe cards.')}let M=null;const $=e=>O.getState().photos[e],k={mode:'local',list:e=>A().byRid.get(e)??E,get:e=>A().cards.find(t=>t.id===e),byMenuItem:e=>A().byItem.get(e),subscribe:e=>{const t=p.subscribe(e),r=O.subscribe(e);return()=>{t(),r()}},async create(e,t,r){j(r);const n=h().toISOString();R=!0;let s=t.menuItemId;try{s||(s=f.useStore.getState().addMenuItem({restaurantId:e,section:t.section,name:t.dish,description:t.description??'',price:t.price,dietary:[],allergens:t.allergens??{},prepMins:12,soldOut:!1,signOff:null}));const a={id:t.id??(0,o.uuid)(),restaurantId:e,menuItemId:s,dish:t.dish,section:t.section,price:t.price,photo:t.photo,ingredients:t.ingredients??[],steps:t.steps??[],allergens:t.allergens??{},dismissed:t.dismissed??[],allergenNotes:t.allergenNotes,signOff:null,wasLive:!1,origin:'new',version:1,createdAt:n,updatedAt:n,updatedBy:r.name};return p.setState(e=>({cards:[...e.cards.filter(e=>e.menuItemId!==a.menuItemId),a]})),v(a,r.name,'card created, awaiting sign-off'),a}finally{R=!1}},async update(e,t,r){j(r);const n=k.get(e);if(!n)throw new Error('Card not found');const s=(0,o.editCard)(n,t,r.name,h().toISOString());return s.changed&&(C(s.card),v(s.card,r.name,s.resetSignOff?'edited, sign-off reset to Awaiting sign-off':t.confirmAllergens&&1===Object.keys(t).length?'allergens confirmed':'edited')),s.card},async signOff(e,t){if(!(0,o.canSignOffCards)(t.role))throw new Error('Only the head chef can sign off a recipe card.');const r=k.get(e);if(!r)throw new Error('Card not found');const n=(0,o.signOffBlock)(r);if(n)throw new Error(n);const s=(0,o.signOffCard)(r,t.name,h().toISOString());return C(s),v(s,t.name,'signed off'),s},async remove(e,t){j(t);const r=k.get(e);r&&(p.setState(t=>({cards:t.cards.filter(t=>t.id!==e),removed:[...t.removed,r.menuItemId]})),f.useStore.setState(e=>({menu:e.menu.map(e=>e.id===r.menuItemId?{...e,hidden:!0}:e)})),v(r,t.name,'card removed (dish hidden from the menu)'))},async savePhoto(e,t,r){const n=`local:${t}:${Date.now().toString(36)}`;return O.setState(e=>({photos:{...Object.fromEntries(Object.entries(e.photos).filter(([e])=>!e.startsWith(`local:${t}:`))),[n]:r.dataUrl}})),n},photoSource(e){if(!e)return null;if(e.startsWith('asset:'))return w[e.slice(6)]??null;if(e.startsWith('local:')){const t=O.getState().photos[e];return t?{uri:t}:null}if(/^(https?:|data:)/.test(e))return{uri:e};const t=O.getState().photos[e];if(t)return{uri:t};const r=M?.(e);return r?{uri:r}:null}};let R=!1,B=!1;function _(){if(R)return;const e=f.useStore.getState().menu,{cards:t,removed:r}=p.getState(),n=new Set(t.map(e=>e.menuItemId)),s=e.filter(e=>!n.has(e.id)&&!r.includes(e.id));if(!s.length)return;const o=h().toISOString(),a=(0,u.exampleCards)(s),c=new Set(a.map(e=>e.menuItemId)),l=[...a,...s.filter(e=>!c.has(e.id)).map(e=>(0,u.importedCard)(e,o))];p.setState(e=>({cards:[...e.cards,...l]}))}(0,c.setMenuCardBridge)({cardFor:e=>A().byItem.get(e),menuItemAdded:e=>{if(R||!B)return;const t=h().toISOString(),r={...(0,u.importedCard)(e,t),id:(0,o.uuid)(),signOff:null,allergensConfirmed:void 0,wasLive:!1,origin:'new',updatedBy:'Added to the menu'};C(r),v(r,r.updatedBy,'card created from the menu, awaiting sign-off')},menuEdited:(e,t,r,n)=>{const s=A().byItem.get(e);if(!s)return;let a=(0,o.editCard)(s,t,r,h().toISOString()).card;n&&a.signOff&&(a={...a,signOff:null,version:a.version+1,updatedAt:h().toISOString(),updatedBy:r}),a!==s&&(C(a),v(a,r,s.signOff&&!a.signOff?'edited from the menu, sign-off reset':'edited from the menu'))},signOff:(e,t)=>{const r=A().byItem.get(e);r&&k.signOff(r.id,{name:t,role:'head-chef'}).catch(()=>{})}}),(0,a.setRecipeCardRepository)(k);const F=e=>new Promise(t=>{e.hasHydrated()?t():e.onFinishHydration(()=>t())});Promise.all([F(f.useStore.persist),F(p.persist)]).then(()=>{B=!0,_(),f.useStore.subscribe((e,t)=>{e.menu!==t.menu&&_()})}),'undefined'!=typeof window&&window.addEventListener('storage',e=>{e.key===l&&p.persist.rehydrate(),e.key===m&&O.persist.rehydrate()})},1023,[975,104,974,976,1017,808,978,1024,855,1025,1026,1027,1028,1029]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"EXAMPLE_TAG",{enumerable:!0,get:function(){return t}}),_e.exampleCards=function(t){return l.flatMap(l=>{const h=t.find(e=>e.id===l.menuItemId);if(!h)return[];return[{id:(0,e.uuidFrom)(`card:${h.restaurantId}:${h.id}`),restaurantId:h.restaurantId,menuItemId:h.id,dish:h.name,section:h.section,price:h.price,photo:l.photo,ingredients:o(l.menuItemId,l.ings),steps:l.steps,allergens:l.allergens,dismissed:l.dismissed??[],allergenNotes:l.notes,allergensConfirmed:{by:s.by,at:s.at},signOff:l.awaiting?null:s,wasLive:!0,origin:'example',version:l.awaiting?2:1,createdAt:n,updatedAt:l.awaiting?'2026-10-28T15:20:00.000Z':n,updatedBy:l.awaiting?'Example edit (demo)':s.by}]})},_e.importedCard=function(t,s){return{id:(0,e.uuidFrom)(`card:${t.restaurantId}:${t.id}`),restaurantId:t.restaurantId,menuItemId:t.id,dish:t.name,section:t.section,price:t.price,ingredients:[],steps:[],allergens:{...t.allergens},dismissed:[],allergenNotes:t.allergenNotes,allergensConfirmed:t.signOff?{by:t.signOff.by,at:t.signOff.at}:void 0,signOff:t.signOff?{by:t.signOff.by,at:t.signOff.at}:null,wasLive:!t.hidden||!!t.signOff,origin:'imported',version:1,createdAt:s,updatedAt:s,updatedBy:'Imported from the menu'}};var e=r(d[0]);const t='Example data',s={by:'Example sign-off (demo)',at:'2026-10-26T10:00:00.000Z'},n='2026-10-26T09:00:00.000Z',o=(e,t)=>t.map(([t,s,n],o)=>({id:`${e}-i${o}`,qty:t,unit:s,name:n})),l=[{menuItemId:'a-lobster',photo:'asset:lobster',ings:[['1','whole','Live Dunure lobster (c. 600 g, Kitty Fisher)'],['60','g','Garlic butter'],['\xbd','','Lemon, charred'],['60','g','Mixed leaves, cucumber and red onion'],['15','ml','House vinaigrette (Dijon mustard)'],['200','g','Triple-cooked chips']],steps:['Chill the lobster for 20 minutes, then dispatch humanely and split lengthways. Remove the stomach sac and the intestinal tract.','Crack the claws. Season the flesh and spoon over half the garlic butter.','Grill flesh side up for 6\u20138 minutes until just opaque; baste with the rest of the butter.','Char the lemon on the grill. Dress the salad at the pass.','Plate on the long board: lobster, claws alongside, salad, chips in the cone, lemon and a pot of the pan butter.'],allergens:{crustaceans:'contains',milk:'contains',mustard:'contains',gluten:'may',fish:'may'},notes:'Chips are cooked in a shared fryer (gluten, fish, crustaceans may be present).'},{menuItemId:'a-skink',photo:'asset:skink',ings:[['120','g','Smoked haddock, undyed'],['200','ml','Whole milk'],['20','g','Butter'],['60','g','Leek, sliced'],['40','g','Onion, diced'],['120','g','Floury potato, diced'],['1','tbsp','Parsley, chopped'],['1','slice','Crusty bread'],['10','g','Butter (portion)']],steps:['Poach the haddock in the milk for 5 minutes. Lift out, flake and keep the milk.','Sweat the leek and onion in the butter until soft, with no colour.','Add the potato and the poaching milk; simmer for 15 minutes until the potato breaks down.','Crush a third of the potato for body, return the haddock and season with pepper.','Serve in the warm bowl, parsley on top, bread and butter on the side.'],allergens:{fish:'contains',milk:'contains',gluten:'contains'}},{menuItemId:'a-fishsupper',photo:'asset:fishsupper',ings:[['200','g','Haddock fillet, locally landed'],['80','g','Self-raising flour'],['100','ml','Beer (lager)'],['250','g','Triple-cooked chips'],['80','g','Garden peas'],['10','g','Butter'],['40','g','Tartare sauce (mayonnaise, capers, gherkins)'],['\xbc','','Lemon']],steps:['Whisk the flour and cold beer to a thick batter; rest for 10 minutes.','Dust the haddock in flour, dip in the batter and lower into the fryer at 180 \xb0C for 5\u20136 minutes.','Fry the chips at 190 \xb0C until golden.','Warm the peas with the butter.','Plate the fish on the chips, peas in the ramekin, tartare and lemon on the side.'],allergens:{fish:'contains',gluten:'contains',eggs:'contains',milk:'contains',mustard:'may',crustaceans:'may',sulphites:'may'},notes:'Shared fryer. Tartare is made with mayonnaise (egg, may contain mustard). The beer in the batter may contain sulphites.'},{menuItemId:'a-moules',photo:'asset:moules',ings:[['500','g','Scottish rope mussels, cleaned'],['30','g','Butter'],['1','','Shallot, finely diced'],['2','cloves','Garlic, sliced'],['100','ml','Dry white wine'],['60','ml','Double cream'],['1','tbsp','Parsley, chopped'],['2','slices','Crusty bread']],steps:['Check every mussel: discard any that are cracked or stay open when tapped.','Sweat the shallot and garlic in the butter for 2 minutes.','Add the mussels and wine, cover and steam on a high heat for 3\u20134 minutes until they open.','Discard any that stay shut. Stir in the cream and parsley.','Serve in the deep bowl with the bread and an empty-shell bowl.'],allergens:{molluscs:'contains',milk:'contains',sulphites:'contains',gluten:'contains'}},{menuItemId:'a-stp',photo:'asset:stp',awaiting:!0,ings:[['30','g','Medjool dates, chopped'],['40','ml','Boiling water'],['25','g','Butter'],['30','g','Dark muscovado sugar'],['1','','Egg (\xbd per portion)'],['35','g','Self-raising flour'],['60','ml','Butterscotch sauce (butter, cream, brown sugar)']],steps:['Soak the dates in the boiling water for 10 minutes, then blitz.','Cream the butter and sugar, beat in the egg, fold in the flour and the dates.','Steam in buttered moulds for 35 minutes.','Warm the butterscotch sauce.','Turn out, pour over the sauce and serve with the guest\u2019s choice of custard, ice cream or cream.'],allergens:{gluten:'contains',milk:'contains',eggs:'contains',sulphites:'may'},notes:'Dried dates may contain sulphites. Accompaniments are chosen at order (see the dish options).'}]},1024,[1017]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg",width:800,height:600,toString(){return this.uri}}},1025,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg",width:800,height:600,toString(){return this.uri}}},1026,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg",width:800,height:600,toString(){return this.uri}}},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg",width:800,height:600,toString(){return this.uri}}},1028,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg",width:800,height:600,toString(){return this.uri}}},1029,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png",width:512,height:512,toString(){return this.uri}}},1030,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png",width:512,height:512,toString(){return this.uri}}},1031,[]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png",width:512,height:512,toString(){return this.uri}}},1032,[]); +__d(function(t,s,r,e,i,a,f){"use strict";i.exports={uri:"/staff-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png",width:1024,height:1024,toString(){return this.uri}}},1033,[]); +__d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShellStore",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"localShellfish",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"shellfish",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useStockItems",{enumerable:!0,get:function(){return S}}),_e.venueCounts=k,_e.useShellfish=function(e,t,n){const s=S(e),i=v(t=>!!t.server[e]),d=v((0,o.useShallow)(t=>t.events.filter(n=>n.rid===e&&(!t.server[e]||O(n))))),u=v((0,o.useShallow)(t=>k(t,e))),l=(0,a.lastUndoable)(d),c=e=>s.find(t=>t.key===e);return{items:s,events:d,counts:u,undoable:l,synced:i,itemOf:c,isLow:e=>(0,a.isLowItem)(c(e),u[e]??0),sell:(s,i=!1)=>{const o=i?.5:1;return!((u[s]??0){i>0&&y.append({rid:e,kind:s,delta:i,reason:'delivery',by:t,app:n})},recount:(s,i)=>{const o=i-(u[s]??0);o&&y.append({rid:e,kind:s,delta:o,reason:'count',by:t,app:n})},undoLast:()=>{l&&y.append({rid:e,kind:l.kind,delta:-l.delta,reason:'undo',by:t,app:n,undoes:l.id})}}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};r(_d[1]);var s=r(_d[2]),i=r(_d[3]),o=r(_d[4]),a=r(_d[5]),d=r(_d[6]),u=r(_d[7]);const l=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}},c='covercharge-shellfish-v1',p='anchorage',f=()=>{const e=new Date(l().getTime()-18e6).toISOString();return[{id:'sf-seed-crab',rid:p,kind:'crab',delta:9,reason:'count',by:'Opening count (example)',app:'chef',at:e},{id:'sf-seed-lob',rid:p,kind:'lobster',delta:6,reason:'count',by:'Opening count (example)',app:'chef',at:e}]},v=(0,s.create)()((0,i.persist)(e=>({events:f(),items:{[p]:a.ANCHORAGE_STOCK.map(e=>({...e}))},server:{},saveItem:(t,n)=>e(e=>{const s=e.items[t]??[];return{items:{...e.items,[t]:s.some(e=>e.key===n.key)?s.map(e=>e.key===n.key?n:e):[...s,n]}}}),removeItem:(t,n)=>e(e=>({items:{...e.items,[t]:(e.items[t]??[]).filter(e=>e.key!==n)}}))}),{name:c,storage:(0,i.createJSONStorage)(()=>n.default),version:2,partialize:e=>({events:e.events,items:e.items,server:e.server}),migrate:e=>{const t=e??{};return{events:t.events??f(),items:t.items??{[p]:a.ANCHORAGE_STOCK.map(e=>({...e}))},server:t.server??{}}}})),b={list:e=>v.getState().events.filter(t=>t.rid===e),append:e=>{const t={...e,id:(0,d.uuid)(),at:e.at??l().toISOString()};return v.setState(e=>({events:[t,...e.events].slice(0,500)})),t},subscribe:e=>v.subscribe(e)},y=b;'undefined'!=typeof window&&window.addEventListener('storage',e=>{e.key===c&&v.persist.rehydrate()});const h=[],S=(e,t=!1)=>{const n=v(t=>t.items[e])??h;return t?n:n.filter(e=>e.active).sort((e,t)=>e.sort-t.sort)},O=e=>!e.id.startsWith('sf-');function k(e,t){const n=e.items[t]??[],s=e.server[t],i=e.events.filter(e=>e.rid===t);if(!s)return(0,a.countsOf)(i,n);const o=new Set(s.seen);return(0,a.countsOf)(i.filter(e=>O(e)&&!o.has(e.id)),n,s.counts)}},1034,[975,104,974,976,857,1035,920,855]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return t}}),_e.countsOf=function(e,t=[],o={}){const s={...o};for(const e of t)s[e.key]=s[e.key]??0;for(const t of e)s[t.kind]=(s[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(s).map(([e,t])=>[e,n(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return s}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),s=(t?.plural??`${e.kind}s`).toLowerCase(),i=o(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${i} ${1===Math.abs(e.delta)?n:s}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${i} ${1===Math.abs(e.delta)?n:s}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${i} ${n})`:`Count: ${i} ${s}`};const e=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],t=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',n=(e,t)=>Math.max(0,'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const o=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},s=(e,t)=>t<=(e?.lowAt??4)},1035,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:e,today:o,by:h,app:y}){const f=(0,a.useBookings)(e).filter(e=>e.date===o&&(0,l.ACTIVE)(e)).sort((e,o)=>e.time.localeCompare(o.time)),j=f.reduce((e,o)=>e+(o.diet?.vegan??0),0),p=f.reduce((e,o)=>e+(o.diet?.vegetarian??0),0);return(0,b.jsxs)(t.default,{style:{gap:12},testID:"todays-bookings",children:[(0,b.jsx)(c.CoversToday,{rid:e}),(0,b.jsx)(u.PlattersBooked,{rid:e,date:o,label:"Platters booked today"}),j||p?(0,b.jsxs)(s.T,{colour:n.colours.green,children:["\ud83c\udf31 ",j?`${j} vegan`:'',j&&p?' \xb7 ':'',p?`${p} vegetarian`:''," today"]}):null,(0,b.jsx)(u.KitchenSignoffs,{rid:e,today:o,by:h,app:y,showAll:!0}),f.length?f.map(e=>(0,b.jsxs)(t.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:n.colours.hairline,backgroundColor:n.colours.surface},children:[(0,b.jsxs)(s.T,{weight:"semibold",children:[e.time," \xb7 ",e.walkIn?`Walk-in ${e.ref}`:e.name," \xb7 ",e.partySize," covers",e.table?` \xb7 T${e.table}`:'']}),(0,b.jsx)(u.BookingNeeds,{b:e}),'seated'===e.status?(0,b.jsx)(s.Muted,{children:"Seated"}):'finished'===e.status?(0,b.jsx)(s.Muted,{children:"Finished"}):null]},e.id)):(0,b.jsx)(s.Muted,{children:"No bookings today yet."})]})},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),a=r(d[3]),l=r(d[4]),n=r(d[5]),u=r(d[6]),c=r(d[7]),b=r(d[8])},1036,[12,109,791,797,805,799,894,876,6]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getSupabase=function(){if(_)return _;if(!(0,u.isSupabaseConfigured)())throw new Error('Supabase is not configured: set EXPO_PUBLIC_SUPABASE_URL and EXPO_PUBLIC_SUPABASE_ANON_KEY in .env.local');return _=(0,s.createClient)(u.SUPABASE_URL,u.SUPABASE_ANON_KEY,{auth:{storage:n.default,persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!1,storageKey:`${(0,o.syncNamespace)()}auth`},realtime:{params:{eventsPerSecond:10}}}),_},_e.setSupabaseClient=function(e){_=e};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),u=r(d[2]),o=r(d[3]);let _=null},1037,[975,1038,1080,1081]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FunctionRegion",{enumerable:!0,get:function(){return e.FunctionRegion}}),Object.defineProperty(_e,"FunctionsError",{enumerable:!0,get:function(){return e.FunctionsError}}),Object.defineProperty(_e,"FunctionsFetchError",{enumerable:!0,get:function(){return e.FunctionsFetchError}}),Object.defineProperty(_e,"FunctionsHttpError",{enumerable:!0,get:function(){return e.FunctionsHttpError}}),Object.defineProperty(_e,"FunctionsRelayError",{enumerable:!0,get:function(){return e.FunctionsRelayError}}),Object.defineProperty(_e,"PostgrestError",{enumerable:!0,get:function(){return t.PostgrestError}}),Object.defineProperty(_e,"StorageApiError",{enumerable:!0,get:function(){return r.StorageApiError}}),Object.defineProperty(_e,"SupabaseClient",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"createClient",{enumerable:!0,get:function(){return N}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]);Object.keys(n).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return n[e]}})});var r=_r(d[3]),s=_r(d[4]);Object.keys(s).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return s[e]}})});let o,i="";var c;if("undefined"!=typeof Deno)i="deno",o=null===(c=Deno.version)||void 0===c?void 0:c.deno;else if("undefined"!=typeof document)i="web";else if("undefined"!=typeof navigator&&"ReactNative"===navigator.product)i="react-native";else{var u;i="node",o="undefined"!=typeof process?null===(u=process.version)||void 0===u?void 0:u.replace(/^v/,""):void 0}const l=[`runtime=${i}`];o&&l.push(`runtime-version=${o}`);const h={headers:{"X-Client-Info":`supabase-js/2.109.0; ${l.join("; ")}`}},f={schema:"public"},p={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},b={},v={enabled:!1,respectSamplingDecision:!0};let y=null;function w(){return e=this,t=void 0,r=function*(){try{const e=yield(null===y&&(y=import("@opentelemetry/api").catch(()=>null)),y);if(!e||!e.propagation||!e.context)return null;const t={};e.propagation.inject(e.context.active(),t);const n=t.traceparent;return n?{traceparent:n,tracestate:t.tracestate,baggage:t.baggage}:null}catch(e){return null}},new((n=void 0)||(n=Promise))(function(s,o){function i(e){try{u(r.next(e))}catch(e){o(e)}}function c(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,c)}u((r=r.apply(e,t||[])).next())});var e,t,n,r}function k(e){if(!e||"string"!=typeof e)return null;const t=e.split("-");if(4!==t.length)return null;const[n,r,s,o]=t;if(2!==n.length||32!==r.length||16!==s.length||2!==o.length)return null;const i=/^[0-9a-f]+$/i;return i.test(n)&&i.test(r)&&i.test(s)&&i.test(o)?"00000000000000000000000000000000"===r||"0000000000000000"===s?null:{version:n,traceId:r,parentId:s,traceFlags:o,isSampled:!(1&~parseInt(o,16))}:null}function O(e,t){if(!e||!t||0===t.length)return!1;let n;if(e instanceof URL)n=e;else try{n=new URL(e)}catch(e){return!1}for(const e of t)try{if("string"==typeof e){if(T(n.hostname,e))return!0}else if(e instanceof RegExp){if(e.test(n.hostname))return!0}else if("function"==typeof e&&e(n))return!0}catch(e){continue}return!1}function T(e,t){if(t===e)return!0;if(t.startsWith("*.")){const n=t.slice(2);if(e.endsWith(n)&&(e===n||e.endsWith("."+n)))return!0}return!1}function P(e){const t=[];try{const n=new URL(e);t.push(n.hostname)}catch(e){}return t.push("*.supabase.co","*.supabase.in"),t.push("localhost","127.0.0.1","[::1]"),t}function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function j(e,t){if("object"!=S(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=S(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function E(e){var t=j(e,"string");return"symbol"==S(t)?t:t+""}function U(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function A(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;te?(...t)=>e(...t):(...e)=>fetch(...e),F=(e,t,n,r,s)=>{const o=C(r),i=Headers,c=!0===(null==s?void 0:s.enabled),u=!1!==(null==s?void 0:s.respectSamplingDecision),l=c?P(t):null;return async(t,r)=>{var s;const c=null!==(s=await n())&&void 0!==s?s:e;let h=new i(null==r?void 0:r.headers);if(h.has("apikey")||h.set("apikey",e),h.has("Authorization")||h.set("Authorization",`Bearer ${c}`),l){const e=await _(t,l,u);e&&(e.traceparent&&!h.has("traceparent")&&h.set("traceparent",e.traceparent),e.tracestate&&!h.has("tracestate")&&h.set("tracestate",e.tracestate),e.baggage&&!h.has("baggage")&&h.set("baggage",e.baggage))}return o(t,R(R({},r),{},{headers:h}))}};async function _(e,t,n){if(!O("string"==typeof e||e instanceof URL?e:e.url,t))return null;const r=await w();if(!r||!r.traceparent)return null;if(n){const e=k(r.traceparent);if(e&&!e.isSampled)return null}return r}function L(e){return"boolean"==typeof e?{enabled:e}:e}function I(e,t){var n,r,s,o,i,c;const{db:u,auth:l,realtime:h,global:f}=e,{db:p,auth:b,realtime:v,global:y}=t,w=L(e.tracePropagation),k=L(t.tracePropagation),O={db:R(R({},p),u),auth:R(R({},b),l),realtime:R(R({},v),h),storage:{},global:R(R(R({},y),f),{},{headers:R(R({},null!==(n=null==y?void 0:y.headers)&&void 0!==n?n:{}),null!==(r=null==f?void 0:f.headers)&&void 0!==r?r:{})}),tracePropagation:{enabled:null!==(s=null!==(o=null==w?void 0:w.enabled)&&void 0!==o?o:null==k?void 0:k.enabled)&&void 0!==s&&s,respectSamplingDecision:null===(i=null!==(c=null==w?void 0:w.respectSamplingDecision)&&void 0!==c?c:null==k?void 0:k.respectSamplingDecision)||void 0===i||i},accessToken:async()=>""};return e.accessToken?O.accessToken=e.accessToken:delete O.accessToken,O}function D(e){const t=null==e?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL((n=t).endsWith("/")?n:n+"/")}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}var n}var K=class extends s.AuthClient{constructor(e){super(e)}},x=class{constructor(e,n,s){var o,i;this.supabaseUrl=e,this.supabaseKey=n;const c=D(e);if(!n)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",c),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",c),this.storageUrl=new URL("storage/v1",c),this.functionsUrl=new URL("functions/v1",c);const u=`sb-${c.hostname.split(".")[0]}-auth-token`,l=I(null!=s?s:{},{db:f,realtime:b,auth:R(R({},p),{},{storageKey:u}),global:h,tracePropagation:v});var y;(this.settings=l,this.storageKey=null!==(o=l.auth.storageKey)&&void 0!==o?o:"",this.headers=null!==(i=l.global.headers)&&void 0!==i?i:{},l.accessToken)?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!==(y=l.auth)&&void 0!==y?y:{},this.headers,l.global.fetch);this.fetch=F(n,e,this._getAccessToken.bind(this),l.global.fetch,l.tracePropagation),this.realtime=this._initRealtimeClient(R({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new t.PostgrestClient(new URL("rest/v1",c).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new r.StorageClient(this.storageUrl.href,this.headers,this.fetch,null==s?void 0:s.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new e.FunctionsClient(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,n)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e,t,n=this;if(n.accessToken)return await n.accessToken();const{data:r}=await n.auth.getSession();return null!==(e=null===(t=r.session)||void 0===t?void 0:t.access_token)&&void 0!==e?e:n.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:r,userStorage:s,storageKey:o,flowType:i,lock:c,debug:u,throwOnError:l,experimental:h,lockAcquireTimeout:f,skipAutoInitialize:p},b,v){const y={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new K({url:this.authUrl.href,headers:R(R({},y),b),storageKey:o,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:r,userStorage:s,flowType:i,lock:c,debug:u,throwOnError:l,experimental:h,fetch:v,lockAcquireTimeout:f,skipAutoInitialize:p,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new n.RealtimeClient(this.realtimeUrl.href,R(R({},e),{},{params:R(R({},{apikey:this.supabaseKey}),null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,n){"TOKEN_REFRESHED"!==e&&"SIGNED_IN"!==e||this.changedAccessToken===n?"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0):(this.changedAccessToken=n,this.realtime.setAuth(n))}};const N=(e,t,n)=>new x(e,t,n);(function(){if("undefined"!=typeof window)return!1;const e=globalThis.process;if(!e)return!1;const t=e.version;if(null==t)return!1;const n=t.match(/^v(\d+)\./);return!!n&&parseInt(n[1],10)<=18})()&&console.warn("\u26a0\ufe0f Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217")},1038,[1039,1044,1045,1060,1062]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FunctionsClient",{enumerable:!0,get:function(){return n.FunctionsClient}}),Object.defineProperty(e,"FunctionsError",{enumerable:!0,get:function(){return t.FunctionsError}}),Object.defineProperty(e,"FunctionsFetchError",{enumerable:!0,get:function(){return t.FunctionsFetchError}}),Object.defineProperty(e,"FunctionsHttpError",{enumerable:!0,get:function(){return t.FunctionsHttpError}}),Object.defineProperty(e,"FunctionsRelayError",{enumerable:!0,get:function(){return t.FunctionsRelayError}}),Object.defineProperty(e,"FunctionRegion",{enumerable:!0,get:function(){return t.FunctionRegion}});var n=r(d[0]),t=r(d[1])},1039,[1040,1043]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FunctionsClient",{enumerable:!0,get:function(){return s}});var t=r(d[0]),n=r(d[1]),o=r(d[2]);class s{constructor(t,{headers:s={},customFetch:c,region:l=o.FunctionRegion.Any}={}){this.url=t,this.headers=s,this.region=l,this.fetch=(0,n.resolveFetch)(c)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(n){return(0,t.__awaiter)(this,arguments,void 0,function*(t,n={}){var s;let c,l;try{const{headers:u,method:f,body:h,signal:p,timeout:y}=n;let b={},{region:F}=n;F||(F=this.region);const v=new URL(`${this.url}/${t}`);let w;F&&'any'!==F&&(b['x-region']=F,v.searchParams.set('forceFunctionRegion',F));const j=!!u&&Object.keys(u).some(t=>'content-type'===t.toLowerCase());h&&!j?'undefined'!=typeof Blob&&h instanceof Blob||h instanceof ArrayBuffer?(b['Content-Type']='application/octet-stream',w=h):'string'==typeof h?(b['Content-Type']='text/plain',w=h):'undefined'!=typeof FormData&&h instanceof FormData?w=h:(b['Content-Type']='application/json',w=JSON.stringify(h)):w=!h||'string'==typeof h||'undefined'!=typeof Blob&&h instanceof Blob||h instanceof ArrayBuffer||'undefined'!=typeof FormData&&h instanceof FormData?h:JSON.stringify(h);let O=p;y&&(l=new AbortController,c=setTimeout(()=>l.abort(),y),p?(O=l.signal,p.addEventListener('abort',()=>l.abort())):O=l.signal);const x=yield this.fetch(v.toString(),{method:f||'POST',headers:Object.assign(Object.assign(Object.assign({},b),this.headers),u),body:w,signal:O}).catch(t=>{throw new o.FunctionsFetchError(t)}),B=x.headers.get('x-relay-error');if(B&&'true'===B)throw new o.FunctionsRelayError(x);if(!x.ok)throw new o.FunctionsHttpError(x);let C,T=(null!==(s=x.headers.get('Content-Type'))&&void 0!==s?s:'text/plain').split(';')[0].trim();return C='application/json'===T?yield x.json():'application/octet-stream'===T||'application/pdf'===T?yield x.blob():'text/event-stream'===T?x:'multipart/form-data'===T?yield x.formData():yield x.text(),{data:C,error:null,response:x}}catch(t){return{data:null,error:t,response:t instanceof o.FunctionsHttpError||t instanceof o.FunctionsRelayError?t.context:void 0}}finally{c&&clearTimeout(c)}})}}},1040,[1041,1042,1043]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return G}}),_e.__extends=t,Object.defineProperty(_e,"__assign",{enumerable:!0,get:function(){return r}}),_e.__rest=n,_e.__decorate=o,_e.__param=a,_e.__esDecorate=i,_e.__runInitializers=c,_e.__propKey=u,_e.__setFunctionName=s,_e.__metadata=f,_e.__awaiter=l,_e.__generator=p,Object.defineProperty(_e,"__createBinding",{enumerable:!0,get:function(){return y}}),_e.__exportStar=_,_e.__values=d,_e.__read=h,_e.__spread=b,_e.__spreadArrays=v,_e.__spreadArray=w,_e.__await=m,_e.__asyncGenerator=g,_e.__asyncDelegator=O,_e.__asyncValues=j,_e.__makeTemplateObject=P,_e.__importStar=x,_e.__importDefault=T,_e.__classPrivateFieldGet=I,_e.__classPrivateFieldSet=D,_e.__classPrivateFieldIn=R,_e.__addDisposableResource=k,_e.__disposeResources=F,_e.__rewriteRelativeImportExtension=C;var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=0;c--)(o=e[c])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function a(e,t){return function(r,n){t(r,n,e)}}function i(e,t,r,n,o,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var c,u=n.kind,s="getter"===u?"get":"setter"===u?"set":"value",f=!t&&e?n.static?e:e.prototype:null,l=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),p=!1,y=r.length-1;y>=0;y--){var _={};for(var d in n)_[d]="access"===d?{}:n[d];for(var d in n.access)_.access[d]=n.access[d];_.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var h=(0,r[y])("accessor"===u?{get:l.get,set:l.set}:l[s],_);if("accessor"===u){if(void 0===h)continue;if(null===h||"object"!=typeof h)throw new TypeError("Object expected");(c=i(h.get))&&(l.get=c),(c=i(h.set))&&(l.set=c),(c=i(h.init))&&o.unshift(c)}else(c=i(h))&&("field"===u?o.unshift(c):l[s]=c)}f&&Object.defineProperty(f,n.name,l),p=!0}function c(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function b(){for(var e=[],t=0;t1||c(e,t)})},t&&(n[e]=t(n[e])))}function c(e,t){try{(r=o[e](t)).value instanceof m?Promise.resolve(r.value.v).then(u,s):f(a[0][2],r)}catch(e){f(a[0][3],e)}var r}function u(e){c("next",e)}function s(e){c("throw",e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function O(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:m(e[n](t)),done:!1}:o?o(t):t}:o}}function j(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=d(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,a){o(n,a,(t=e[r](t)).done,t.value)})}}function o(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)}}function P(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var S=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},E=function(e){return E=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},E(e)};function x(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=E(e),n=0;nt?(...n)=>t(...n):(...t)=>fetch(...t)},1042,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FunctionsError",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"FunctionsFetchError",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FunctionsRelayError",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"FunctionsHttpError",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"FunctionRegion",{enumerable:!0,get:function(){return u}});class t extends Error{constructor(t,n="FunctionsError",s){super(t),this.name=n,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class n extends t{constructor(t){super('Failed to send a request to the Edge Function','FunctionsFetchError',t)}}class s extends t{constructor(t){super('Relay Error invoking the Edge Function','FunctionsRelayError',t)}}class o extends t{constructor(t){super('Edge Function returned a non-2xx status code','FunctionsHttpError',t)}}var u;!(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(u||(u={}))},1043,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PostgrestBuilder",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"PostgrestClient",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"PostgrestError",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"PostgrestFilterBuilder",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"PostgrestQueryBuilder",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"PostgrestTransformBuilder",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});const e=e=>Math.min(1e3*2**e,3e4),t=[520,503],r=["GET","HEAD","OPTIONS"];var s=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function n(e,t){return new Promise(r=>{if(null==t?void 0:t.aborted)return void r();const s=setTimeout(()=>{null==t||t.removeEventListener("abort",n),r()},e);function n(){clearTimeout(s),r()}null==t||t.addEventListener("abort",n)})}function i(e,s,n,i){return!(!i||n>=3)&&(!!r.includes(e)&&!!t.includes(s))}var l=class{constructor(e){var t,r,s,n,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,this.shouldStripNulls=null!==(s=e.shouldStripNulls)&&void 0!==s&&s,this.urlLengthLimit=null!==(n=e.urlLengthLimit)&&void 0!==n?n:8e3,this.retryEnabled=null===(i=e.retry)||void 0===i||i,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if("text/csv"===this.headers.get("Accept"))throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(t,s){var l=this;if(void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const e=this.headers.get("Accept");"application/vnd.pgrst.object+json"===e?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):e&&"application/json"!==e||this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const o=this.fetch;let h=(async()=>{let t=0;for(;;){const u={};let c;l.headers.forEach((e,t)=>{u[t]=e}),t>0&&(u["X-Retry-Count"]=String(t));try{c=await o(l.url.toString(),{method:l.method,headers:u,body:JSON.stringify(l.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:l.signal})}catch(s){if("AbortError"===(null==s?void 0:s.name)||"ABORT_ERR"===(null==s?void 0:s.code))throw s;if(!r.includes(l.method))throw s;if(l.retryEnabled&&t<3){const r=e(t);t++,await n(r,l.signal);continue}throw s}if(i(l.method,c.status,t,l.retryEnabled)){var s,h;const r=null!==(s=null===(h=c.headers)||void 0===h?void 0:h.get("Retry-After"))&&void 0!==s?s:null,i=null!==r?1e3*Math.max(0,parseInt(r,10)||0):e(t);await c.text(),t++,await n(i,l.signal);continue}return await l.processResponse(c)}})();return this.shouldThrowOnError||(h=h.catch(e=>{var t;let r="",s="",n="";const i=null==e?void 0:e.cause;if(i){var l,o,h,u;const t=null!==(l=null==i?void 0:i.message)&&void 0!==l?l:"",s=null!==(o=null==i?void 0:i.code)&&void 0!==o?o:"";r=`${null!==(h=null==e?void 0:e.name)&&void 0!==h?h:"FetchError"}: ${null==e?void 0:e.message}`,r+=`\n\nCaused by: ${null!==(u=null==i?void 0:i.name)&&void 0!==u?u:"Error"}: ${t}`,s&&(r+=` (${s})`),(null==i?void 0:i.stack)&&(r+=`\n${i.stack}`)}else{var c;r=null!==(c=null==e?void 0:e.stack)&&void 0!==c?c:""}const p=this.url.toString().length;return"AbortError"===(null==e?void 0:e.name)||"ABORT_ERR"===(null==e?void 0:e.code)?(n="",s="Request was aborted (timeout or manual cancellation)",p>this.urlLengthLimit&&(s+=`. Note: Your request URL is ${p} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):"HeadersOverflowError"!==(null==i?void 0:i.name)&&"UND_ERR_HEADERS_OVERFLOW"!==(null==i?void 0:i.code)||(n="",s="HTTP headers exceeded server limits (typically 16KB)",p>this.urlLengthLimit&&(s+=`. Your request URL is ${p} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError"}: ${null==e?void 0:e.message}`,details:r,hint:s,code:n},data:null,count:null,status:0,statusText:""}})),h.then(t,s)}async processResponse(e){var t=this;let r=null,n=null,i=null,l=e.status,o=e.statusText;if(e.ok){var h,u;if("HEAD"!==t.method){var c;const i=await e.text();if(""===i);else if("text/csv"===t.headers.get("Accept"))n=i;else if(t.headers.get("Accept")&&(null===(c=t.headers.get("Accept"))||void 0===c?void 0:c.includes("application/vnd.pgrst.plan+text")))n=i;else try{n=JSON.parse(i)}catch(e){if(r={message:i},n=null,t.shouldThrowOnError)throw new s({message:i,details:"",hint:"",code:""})}}const p=null===(h=t.headers.get("Prefer"))||void 0===h?void 0:h.match(/count=(exact|planned|estimated)/),f=null===(u=e.headers.get("content-range"))||void 0===u?void 0:u.split("/");p&&f&&f.length>1&&(i=parseInt(f[1])),t.isMaybeSingle&&Array.isArray(n)&&(n.length>1?(r={code:"PGRST116",details:`Results contain ${n.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},n=null,i=null,l=406,o="Not Acceptable"):n=1===n.length?n[0]:null)}else{const i=await e.text();try{r=JSON.parse(i),Array.isArray(r)&&404===e.status&&(n=[],r=null,l=200,o="OK")}catch(t){404===e.status&&""===i?(l=204,o="No Content"):r={message:i}}if(r&&t.shouldThrowOnError)throw new s(r)}return{success:null===r,error:r,data:n,count:i,status:l,statusText:o}}returns(){return this}overrideTypes(){return this}},o=class extends l{throwOnError(){return super.throwOnError()}select(e){let t=!1;const r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":("\""===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){const i=n?`${n}.order`:"order",l=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${l?`${l},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){const s=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:s=r}={}){const n=void 0===s?"offset":`${s}.offset`,i=void 0===s?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this.url.searchParams.set(i,""+(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:i="text"}={}){var l;const o=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),h=null!==(l=this.headers.get("Accept"))&&void 0!==l?l:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${h}"; options=${o};`),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};const h=new RegExp("[,()]");var u=class extends o{throwOnError(){return super.throwOnError()}eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){const r=Array.from(new Set(t)).map(e=>"string"==typeof e&&h.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}notIn(e,t){const r=Array.from(new Set(t)).map(e=>"string"==typeof e&&h.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`not.in.(${r})`),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let n="";"plain"===s?n="pl":"phrase"===s?n="ph":"websearch"===s&&(n="w");const i=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${n}fts${i}.${t}`),this}match(e){return Object.entries(e).filter(([e,t])=>void 0!==t).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){const s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}},c=class{constructor(e,{headers:t={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:i}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){const{head:r=!1,count:s}=null!=t?t:{},n=r?"HEAD":"GET";let i=!1;const l=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!i?"":("\""===e&&(i=!i),e)).join(""),{url:o,headers:h}=this.cloneRequestState();return o.searchParams.set("select",l),s&&h.append("Prefer",`count=${s}`),new u({method:n,url:o,headers:h,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e,{count:t,defaultToNull:r=!0}={}){var s;const{url:n,headers:i}=this.cloneRequestState();if(t&&i.append("Prefer",`count=${t}`),r||i.append("Prefer","missing=default"),Array.isArray(e)){const t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){const e=[...new Set(t)].map(e=>`"${e}"`);n.searchParams.set("columns",e.join(","))}}return new u({method:"POST",url:n,headers:i,schema:this.schema,body:e,fetch:null!==(s=this.fetch)&&void 0!==s?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var i;const{url:l,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&l.searchParams.set("on_conflict",t),s&&o.append("Prefer",`count=${s}`),n||o.append("Prefer","missing=default"),Array.isArray(e)){const t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){const e=[...new Set(t)].map(e=>`"${e}"`);l.searchParams.set("columns",e.join(","))}}return new u({method:"POST",url:l,headers:o,schema:this.schema,body:e,fetch:null!==(i=this.fetch)&&void 0!==i?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var r;const{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new u({method:"PATCH",url:s,headers:n,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:e}={}){var t;const{url:r,headers:s}=this.cloneRequestState();return e&&s.append("Prefer",`count=${e}`),new u({method:"DELETE",url:r,headers:s,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){if("object"!=p(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=p(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function y(e){var t=f(e,"string");return"symbol"==p(t)?t:t+""}function v(e,t,r){return(t=y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function P(e){for(var t=1;t0?(e,t)=>{const r=new AbortController,s=setTimeout(()=>r.abort(),n),i=null==t?void 0:t.signal;if(i){if(i.aborted)return clearTimeout(s),o(e,t);const n=()=>{clearTimeout(s),r.abort()};return i.addEventListener("abort",n,{once:!0}),o(e,P(P({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(s),i.removeEventListener("abort",n)})}return o(e,P(P({},t),{},{signal:r.signal})).finally(()=>clearTimeout(s))}:o,this.retry=l}from(e){if(!e||"string"!=typeof e||""===e.trim())throw new Error("Invalid relation name: relation must be a non-empty string.");return new c(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,t={},{head:r=!1,get:s=!1,count:n}={}){var i;let l;const o=new URL(`${this.url}/rpc/${e}`);let h;const c=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(c)),p=r&&Object.values(t).some(c);p?(l="POST",h=t):r||s?(l=r?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`]).forEach(([e,t])=>{o.searchParams.append(e,t)})):(l="POST",h=t);const f=new Headers(this.headers);return p?f.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&f.set("Prefer",`count=${n}`),new u({method:l,url:o,headers:f,schema:this.schemaName,body:h,fetch:null!==(i=this.fetch)&&void 0!==i?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}},w={PostgrestClient:$,PostgrestQueryBuilder:c,PostgrestFilterBuilder:u,PostgrestTransformBuilder:o,PostgrestBuilder:l,PostgrestError:s}},1044,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"RealtimePresence",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(_e,"RealtimeChannel",{enumerable:!0,get:function(){return E.default}}),Object.defineProperty(_e,"RealtimeClient",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(_e,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return n.RealtimePostgresFilterBuilder}}),Object.defineProperty(_e,"postgresChangesFilter",{enumerable:!0,get:function(){return n.postgresChangesFilter}}),Object.defineProperty(_e,"REALTIME_LISTEN_TYPES",{enumerable:!0,get:function(){return n.REALTIME_LISTEN_TYPES}}),Object.defineProperty(_e,"REALTIME_POSTGRES_CHANGES_LISTEN_EVENT",{enumerable:!0,get:function(){return n.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT}}),Object.defineProperty(_e,"REALTIME_PRESENCE_LISTEN_EVENTS",{enumerable:!0,get:function(){return u.REALTIME_PRESENCE_LISTEN_EVENTS}}),Object.defineProperty(_e,"REALTIME_SUBSCRIBE_STATES",{enumerable:!0,get:function(){return n.REALTIME_SUBSCRIBE_STATES}}),Object.defineProperty(_e,"REALTIME_CHANNEL_STATES",{enumerable:!0,get:function(){return n.REALTIME_CHANNEL_STATES}}),Object.defineProperty(_e,"WebSocketFactory",{enumerable:!0,get:function(){return l.default}});var t=e(r(d[0])),n=r(d[1]),E=e(n),u=r(d[2]),o=e(u),l=e(r(d[3]))},1045,[1046,1052,1053,1047]); +__d(function(g,r,i,a,m,_e2,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"default",{enumerable:!0,get:function(){return f}});var t=e(r(d[0])),n=r(d[1]),s=e(r(d[2])),o=r(d[3]),c=e(r(d[4])),l=e(r(d[5]));const h=25e3,u=[1e3,2e3,5e3,1e4];function k(){const e=new Map;return{get length(){return e.size},clear(){e.clear()},getItem:t=>e.has(t)?e.get(t):null,key(t){var n;return null!==(n=Array.from(e.keys())[t])&&void 0!==n?n:null},removeItem(t){e.delete(t)},setItem(t,n){e.set(t,String(n))}}}function p(){try{if('undefined'!=typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}return k()}class f{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,t){var n;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint='',this.headers={},this.params={},this.ref=0,this.serializer=new s.default,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),!(null===(n=null==t?void 0:t.params)||void 0===n?void 0:n.apikey))throw new Error('API key is required to connect to Realtime');this.apiKey=t.params.apikey;const c=this._initializeOptions(t);this.socketAdapter=new l.default(e,c),this.httpEndpoint=(0,o.httpEndpointURL)(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely('connect'),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const t=e.message;if(t.includes('Node.js'))throw new Error(`${t}\n\nTo use Realtime in Node.js, you need to provide a WebSocket implementation:\n\nOption 1: Use Node.js 22+ which has native WebSocket support\nOption 2: Install and provide the "ws" package:\n\n npm install ws\n\n import ws from "ws"\n const client = new RealtimeClient(url, {\n ...options,\n transport: ws\n })`);throw new Error(`WebSocket not available: ${t}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,t){return this._cancelPendingDisconnect(),this.isDisconnecting()?'ok':await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,t)}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return'ok'===t&&e.teardown(),t}async removeAllChannels(){const e=this.channels.map(async e=>{const t=await e.unsubscribe();return e.teardown(),t}),t=await Promise.all(e);return await this.disconnect(),t}log(e,t,n){this.socketAdapter.log(e,t,n)}connectionState(){return this.socketAdapter.connectionState()||n.CONNECTION_STATE.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,t={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(e=>e.topic===n);if(s)return s;{const n=new c.default(`realtime:${e}`,t,this);return this._cancelPendingDisconnect(),this.channels.push(n),n}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic),0===this.channels.length&&(this.log('transport','no channels remaining, scheduling disconnect'),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs)return this.log('transport','disconnecting immediately - no channels'),void this.disconnect();this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,0===this.channels.length&&(this.log('transport','deferred disconnect fired - no channels, disconnecting'),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log('transport',`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){null!==this._pendingDisconnectTimer&&(this.log('transport','pending disconnect cancelled - channel activity detected'),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e=null){let t,s=!1;if(e)t=e,s=!0;else if(this.accessToken)try{t=await this.accessToken()}catch(e){this.log('error','Error fetching access token from callback',e),t=this.accessTokenValue}else t=this.accessTokenValue;s?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{const s={access_token:t,version:n.DEFAULT_VERSION};t&&e.updateJoinPayload(s),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(n.CHANNEL_EVENTS.access_token,{access_token:t})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(t=>{this.log('error',`Error setting auth in ${e}`,t)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(e=>{this.log('error','error waiting for auth on connect',e)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(t,n)=>{'sent'==t&&this._setAuthSafely(),e&&e(t,n)}}_startWorkerHeartbeat(){this.workerUrl?this.log('worker',`starting worker for from ${this.workerUrl}`):this.log('worker',"starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log('worker','worker error',e.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=e=>{'keepAlive'===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:'start',interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log('worker','terminating worker'),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let t;if(e)t=e;else{const e=new Blob(["\n addEventListener(\"message\", (e) => {\n if (e.data.event === \"start\") {\n setInterval(() => postMessage({ event: \"keepAlive\" }), e.data.interval);\n }\n });"],{type:'application/javascript'});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var s,o,c,l,k,f,_,v,w,b,A,T;this.worker=null!==(s=null==e?void 0:e.worker)&&void 0!==s&&s,this.accessToken=null!==(o=null==e?void 0:e.accessToken)&&void 0!==o?o:null;const y={};let C,R;y.timeout=null!==(c=null==e?void 0:e.timeout)&&void 0!==c?c:n.DEFAULT_TIMEOUT,y.heartbeatIntervalMs=null!==(l=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==l?l:h,this._disconnectOnEmptyChannelsAfterMs=null!==(k=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)&&void 0!==k?k:2*(null!==(f=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==f?f:h),y.transport=null!==(_=null==e?void 0:e.transport)&&void 0!==_?_:t.default.getWebSocketConstructor(),y.params=null==e?void 0:e.params,y.logger=null==e?void 0:e.logger,y.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),y.sessionStorage=null!==(v=null==e?void 0:e.sessionStorage)&&void 0!==v?v:p(),y.reconnectAfterMs=null!==(w=null==e?void 0:e.reconnectAfterMs)&&void 0!==w?w:e=>u[e-1]||1e4;const E=null!==(b=null==e?void 0:e.vsn)&&void 0!==b?b:n.DEFAULT_VSN;switch(E){case n.VSN_1_0_0:C=(e,t)=>t(JSON.stringify(e)),R=(e,t)=>t(JSON.parse(e));break;case n.VSN_2_0_0:C=this.serializer.encode.bind(this.serializer),R=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${y.vsn}`)}if(y.vsn=E,y.encode=null!==(A=null==e?void 0:e.encode)&&void 0!==A?A:C,y.decode=null!==(T=null==e?void 0:e.decode)&&void 0!==T?T:R,y.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,y.params=Object.assign(Object.assign({},y.params),{log_level:this.logLevel})),this.worker){if('undefined'!=typeof window&&!window.Worker)throw new Error('Web Worker is not supported');this.workerUrl=null==e?void 0:e.workerUrl,y.autoSendHeartbeat=!this.worker}return y}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}},1046,[1047,1048,1050,1051,1052,1059]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"WebSocketFactory",{enumerable:!0,get:function(){return t}});class t{constructor(){}static detectEnvironment(){var t;if('undefined'!=typeof WebSocket)return{type:'native',wsConstructor:WebSocket};const o=globalThis;if('undefined'!=typeof globalThis&&void 0!==o.WebSocket)return{type:'native',wsConstructor:o.WebSocket};const n=void 0!==g?g:void 0;if(n&&void 0!==n.WebSocket)return{type:'native',wsConstructor:n.WebSocket};if('undefined'!=typeof globalThis&&void 0!==o.WebSocketPair&&void 0===globalThis.WebSocket)return{type:'cloudflare',error:'Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.',workaround:'Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime.'};if('undefined'!=typeof globalThis&&o.EdgeRuntime||'undefined'!=typeof navigator&&(null===(t=navigator.userAgent)||void 0===t?void 0:t.includes('Vercel-Edge')))return{type:'unsupported',error:'Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.',workaround:'Use serverless functions or a different deployment target for WebSocket functionality.'};const s=globalThis.process;if(s){const t=s.versions;if(t&&t.node){const o=t.node,n=parseInt(o.replace(/^v/,'').split('.')[0]);return n>=22?void 0!==globalThis.WebSocket?{type:'native',wsConstructor:globalThis.WebSocket}:{type:'unsupported',error:`Node.js ${n} detected but native WebSocket not found.`,workaround:'Provide a WebSocket implementation via the transport option.'}:{type:'unsupported',error:`Node.js ${n} detected without native WebSocket support.`,workaround:"For Node.js < 22, install \"ws\" package and provide it via the transport option:\nimport ws from \"ws\"\nnew RealtimeClient(url, { transport: ws })"}}}return{type:'unsupported',error:'Unknown JavaScript runtime without WebSocket support.',workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const t=this.detectEnvironment();if(t.wsConstructor)return t.wsConstructor;let o=t.error||'WebSocket not supported in this environment.';throw t.workaround&&(o+=`\n\nSuggested solution: ${t.workaround}`),new Error(o)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return'native'===t.type||'ws'===t.type}catch(t){return!1}}}var o=t},1047,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_VERSION",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VSN_1_0_0",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"VSN_2_0_0",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_VSN",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"DEFAULT_TIMEOUT",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"WS_CLOSE_NORMAL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MAX_PUSH_BUFFER_SIZE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SOCKET_STATES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"CHANNEL_STATES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"CHANNEL_EVENTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TRANSPORTS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"CONNECTION_STATE",{enumerable:!0,get:function(){return E}});var n=r(d[0]);const t=`realtime-js/${n.version}`,o='1.0.0',c='2.0.0',u=c,l=n.version,b=1e4,_=1e3,f=100,p={connecting:0,open:1,closing:2,closed:3},s={closed:'closed',errored:'errored',joined:'joined',joining:'joining',leaving:'leaving'},O={close:'phx_close',error:'phx_error',join:'phx_join',reply:'phx_reply',leave:'phx_leave',access_token:'access_token'},j={websocket:'websocket'},E={connecting:'connecting',open:'open',closing:'closing',closed:'closed'}},1048,[1049]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return t}});const t='2.109.0'},1049,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});class t{constructor(t){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT='broadcast',this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=t?t:[]}encode(t,n){if(t.event===this.BROADCAST_EVENT&&!(t.payload instanceof ArrayBuffer)&&'string'==typeof t.payload.event)return n(this._binaryEncodeUserBroadcastPush(t));let s=[t.join_ref,t.ref,t.topic,t.event,t.payload];return n(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(t){var n;return this._isArrayBuffer(null===(n=t.payload)||void 0===n?void 0:n.payload)?this._encodeBinaryUserBroadcastPush(t):this._encodeJsonUserBroadcastPush(t)}_encodeBinaryUserBroadcastPush(t){var n,s;const o=null!==(s=null===(n=t.payload)||void 0===n?void 0:n.payload)&&void 0!==s?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(t,this.BINARY_ENCODING,o)}_encodeJsonUserBroadcastPush(t){var n,s;const o=null!==(s=null===(n=t.payload)||void 0===n?void 0:n.payload)&&void 0!==s?s:{},c=(new TextEncoder).encode(JSON.stringify(o)).buffer;return this._encodeUserBroadcastPush(t,this.JSON_ENCODING,c)}_encodeUserBroadcastPush(t,n,s){var o,c;const l=t.topic,h=null!==(o=t.ref)&&void 0!==o?o:'',u=null!==(c=t.join_ref)&&void 0!==c?c:'',f=t.payload.event,y=this.allowedMetadataKeys?this._pick(t.payload,this.allowedMetadataKeys):{},_=0===Object.keys(y).length?'':JSON.stringify(y);if(u.length>255)throw new Error(`joinRef length ${u.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`ref length ${h.length} exceeds maximum of 255`);if(l.length>255)throw new Error(`topic length ${l.length} exceeds maximum of 255`);if(f.length>255)throw new Error(`userEvent length ${f.length} exceeds maximum of 255`);if(_.length>255)throw new Error(`metadata length ${_.length} exceeds maximum of 255`);const A=this.USER_BROADCAST_PUSH_META_LENGTH+u.length+h.length+l.length+f.length+_.length,E=new ArrayBuffer(this.HEADER_LENGTH+A);let U=new DataView(E),B=0;U.setUint8(B++,this.KINDS.userBroadcastPush),U.setUint8(B++,u.length),U.setUint8(B++,h.length),U.setUint8(B++,l.length),U.setUint8(B++,f.length),U.setUint8(B++,_.length),U.setUint8(B++,n),Array.from(u,t=>U.setUint8(B++,t.charCodeAt(0))),Array.from(h,t=>U.setUint8(B++,t.charCodeAt(0))),Array.from(l,t=>U.setUint8(B++,t.charCodeAt(0))),Array.from(f,t=>U.setUint8(B++,t.charCodeAt(0))),Array.from(_,t=>U.setUint8(B++,t.charCodeAt(0)));var N=new Uint8Array(E.byteLength+s.byteLength);return N.set(new Uint8Array(E),0),N.set(new Uint8Array(s),E.byteLength),N.buffer}decode(t,n){if(this._isArrayBuffer(t)){return n(this._binaryDecode(t))}if('string'==typeof t){const s=JSON.parse(t),[o,c,l,h,u]=s;return n({join_ref:o,ref:c,topic:l,event:h,payload:u})}return n({})}_binaryDecode(t){const n=new DataView(t),s=n.getUint8(0),o=new TextDecoder;if(s===this.KINDS.userBroadcast)return this._decodeUserBroadcast(t,n,o)}_decodeUserBroadcast(t,n,s){const o=n.getUint8(1),c=n.getUint8(2),l=n.getUint8(3),h=n.getUint8(4);let u=this.HEADER_LENGTH+4;const f=s.decode(t.slice(u,u+o));u+=o;const y=s.decode(t.slice(u,u+c));u+=c;const _=s.decode(t.slice(u,u+l));u+=l;const A=t.slice(u,t.byteLength),E=h===this.JSON_ENCODING?JSON.parse(s.decode(A)):A,U={type:this.BROADCAST_EVENT,event:y,payload:E};return l>0&&(U.meta=JSON.parse(_)),{join_ref:null,ref:null,topic:f,event:this.BROADCAST_EVENT,payload:U}}_isArrayBuffer(t){var n;return t instanceof ArrayBuffer||'ArrayBuffer'===(null===(n=null==t?void 0:t.constructor)||void 0===n?void 0:n.name)}_pick(t,n){return t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([t])=>n.includes(t))):{}}}},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";var t;Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PostgresTypes",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"convertChangeData",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"convertColumn",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"convertCell",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"toBoolean",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toNumber",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"toJson",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"toTimestampString",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"httpEndpointURL",{enumerable:!0,get:function(){return y}}),(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(t||(t={}));const n=(t,n,o={})=>{var s;const u=null!==(s=o.skipTypes)&&void 0!==s?s:[];return n?Object.keys(n).reduce((o,s)=>(o[s]=c(s,t,n,u),o),{}):{}},c=(t,n,c,u)=>{const p=n.find(n=>n.name===t),l=null==p?void 0:p.type,f=c[t];return l&&!u.includes(l)?o(l,f):s(f)},o=(n,c)=>{if('_'===n.charAt(0)){const t=n.slice(1,n.length);return f(c,t)}switch(n){case t.bool:return u(c);case t.float4:case t.float8:case t.int2:case t.int4:case t.int8:case t.numeric:case t.oid:return p(c);case t.json:case t.jsonb:return l(c);case t.timestamp:return b(c);case t.abstime:case t.date:case t.daterange:case t.int4range:case t.int8range:case t.money:case t.reltime:case t.text:case t.time:case t.timestamptz:case t.timetz:case t.tsrange:case t.tstzrange:default:return s(c)}},s=t=>t,u=t=>{switch(t){case't':return!0;case'f':return!1;default:return t}},p=t=>{if('string'==typeof t){const n=parseFloat(t);if(!Number.isNaN(n))return n}return t},l=t=>{if('string'==typeof t)try{return JSON.parse(t)}catch(n){return t}return t},f=(t,n)=>{if('string'!=typeof t)return t;const c=t.length-1,s=t[c];if('{'===t[0]&&'}'===s){let s;const u=t.slice(1,c);try{s=JSON.parse('['+u+']')}catch(t){s=u?u.split(','):[]}return s.map(t=>o(n,t))}return t},b=t=>'string'==typeof t?t.replace(' ','T'):t,y=t=>{const n=new URL(t);return n.protocol=n.protocol.replace(/^ws/i,'http'),n.pathname=n.pathname.replace(/\/+$/,'').replace(/\/socket\/websocket$/i,'').replace(/\/socket$/i,'').replace(/\/websocket$/i,''),''===n.pathname||'/'===n.pathname?n.pathname='/api/broadcast':n.pathname=n.pathname+'/api/broadcast',n.href}},1051,[]); +__d(function(g,_r,_i,a,m,_e2,_d2){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return d.RealtimePostgresFilterBuilder}}),Object.defineProperty(_e2,"postgresChangesFilter",{enumerable:!0,get:function(){return d.postgresChangesFilter}}),Object.defineProperty(_e2,"default",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e2,"REALTIME_POSTGRES_CHANGES_LISTEN_EVENT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e2,"REALTIME_LISTEN_TYPES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e2,"REALTIME_SUBSCRIBE_STATES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e2,"REALTIME_CHANNEL_STATES",{enumerable:!0,get:function(){return h}});var t,n,i,s=_r(_d2[0]),r=e(_r(_d2[1])),o=_r(_d2[2]),c=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(n){if('default'!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t})(o),l=_r(_d2[3]),u=e(_r(_d2[4])),d=_r(_d2[5]);!(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(t||(t={})),(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(n||(n={})),(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(i||(i={}));const h=s.CHANNEL_STATES;class p{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,t={config:{}},n){var i,s;if(this.topic=e,this.params=t,this.socket=n,this.bindings={},this.subTopic=e.replace(/^realtime:/i,''),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:'',enabled:!1},private:!1},t.config),this.channelAdapter=new u.default(this.socket.socketAdapter,e,this.params),this.presence=new r.default(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=(0,o.httpEndpointURL)(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null===(s=null===(i=this.params.config)||void 0===i?void 0:i.broadcast)||void 0===s?void 0:s.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,t=this.timeout){var r,o,c;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:u,presence:d,private:h}}=this.params,p=null!==(o=null===(r=this.bindings.postgres_changes)||void 0===r?void 0:r.map(e=>e.filter))&&void 0!==o?o:[],E=!!this.bindings[n.PRESENCE]&&this.bindings[n.PRESENCE].length>0||!0===(null===(c=this.params.config.presence)||void 0===c?void 0:c.enabled),b={},f={broadcast:u,presence:Object.assign(Object.assign({},d),{enabled:E}),postgres_changes:p,private:h};this.socket.accessTokenValue&&(b.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(i.CHANNEL_ERROR,(0,l.normalizeChannelError)(t))}),this._onClose(()=>null==e?void 0:e(i.CLOSED)),this.updateJoinPayload(Object.assign({config:f},b)),this._updateFilterMessage(),this.channelAdapter.subscribe(t).receive('ok',async({postgres_changes:t})=>{this.socket._isManualToken()||this.socket.setAuth(),void 0!==t?this._updatePostgresBindings(t,e):null==e||e(i.SUBSCRIBED)}).receive('error',t=>{this.state=s.CHANNEL_STATES.errored;const n=Object.values(t).join(', ')||'error';null==e||e(i.CHANNEL_ERROR,new Error(n,{cause:t}))}).receive('timeout',()=>{null==e||e(i.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var n;const r=this.bindings.postgres_changes,o=null!==(n=null==r?void 0:r.length)&&void 0!==n?n:0,c=[];for(let n=0;n{var i,s,r;const o=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);'broadcast'!==e.type||(null===(r=null===(s=null===(i=this.params)||void 0===i?void 0:i.config)||void 0===s?void 0:s.broadcast)||void 0===r?void 0:r.ack)||n('ok'),o.receive('ok',()=>n('ok')),o.receive('error',()=>n('error')),o.receive('timeout',()=>n('timed out'))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:s,payload:r}=e,o={apikey:this.socket.apiKey?this.socket.apiKey:'','Content-Type':'application/json'};this.socket.accessTokenValue&&(o.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:'POST',headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:r,private:this.private}]})};try{const e=await this._fetchWithTimeout(this.broadcastEndpointURL,c,null!==(n=t.timeout)&&void 0!==n?n:this.timeout);return await(null===(i=e.body)||void 0===i?void 0:i.cancel()),e.ok?'ok':'error'}catch(e){return e instanceof Error&&'AbortError'===e.name?'timed out':'error'}}}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(t=>{this.channelAdapter.unsubscribe(e).receive('ok',()=>t('ok')).receive('timeout',()=>t('timed out')).receive('error',()=>t('error'))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,t,n){const i=new AbortController,s=setTimeout(()=>i.abort(),n),r=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:i.signal}));return clearTimeout(s),r}_on(e,t,n){const i=e.toLocaleLowerCase(),s=null==t?void 0:t.filter;(s instanceof d.RealtimePostgresFilterBuilder||'object'==typeof s&&null!==s&&'function'==typeof s.build)&&(t=Object.assign(Object.assign({},t),{filter:s.build()}));const r={type:i,filter:t,callback:n,ref:this.channelAdapter.on(e,n)};return this.bindings[i]?this.bindings[i].push(r):this.bindings[i]=[r],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,n)=>{var i,s,r,o,c,l,u;const d=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(d,n))return!1;const h=null===(i=this.bindings[d])||void 0===i?void 0:i.find(t=>t.ref===e.ref);if(!h)return!0;if(['broadcast','presence','postgres_changes'].includes(d)){if('id'in h){const e=h.id,n=null===(s=h.filter)||void 0===s?void 0:s.event;return e&&(null===(r=t.ids)||void 0===r?void 0:r.includes(e))&&('*'===n||(null==n?void 0:n.toLocaleLowerCase())===(null===(o=t.data)||void 0===o?void 0:o.type.toLocaleLowerCase()))}{const e=null===(l=null===(c=null==h?void 0:h.filter)||void 0===c?void 0:c.event)||void 0===l?void 0:l.toLocaleLowerCase();return'*'===e||e===(null===(u=null==t?void 0:t.event)||void 0===u?void 0:u.toLocaleLowerCase())}}return h.type.toLocaleLowerCase()===d})}_notThisChannelEvent(e,t){const{close:n,error:i,leave:r,join:o}=s.CHANNEL_EVENTS;return t&&[n,i,r,o].includes(e)&&t!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,t,n)=>{if('object'==typeof t&&'ids'in t){const e=t.data,{schema:n,table:i,commit_timestamp:s,type:r,errors:o}=e,c={schema:n,table:i,commit_timestamp:s,eventType:r,new:{},old:{},errors:o};return Object.assign(Object.assign({},c),this._getPayloadRecords(e))}return t})}copyBindings(e){if(this.joinedOnce)throw new Error('cannot copy bindings into joined channel');for(const t in e.bindings)for(const n of e.bindings[t])this._on(n.type,n.filter,n.callback)}static isFilterValueEqual(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}_getPayloadRecords(e){const t={new:{},old:{}};return'INSERT'!==e.type&&'UPDATE'!==e.type||(t.new=c.convertChangeData(e.columns,e.record)),'UPDATE'!==e.type&&'DELETE'!==e.type||(t.old=c.convertChangeData(e.columns,e.old_record)),t}}},1052,[1048,1053,1051,1056,1057,1058]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REALTIME_PRESENCE_LISTEN_EVENTS",{enumerable:!0,get:function(){return t}});var e,t,n=r(d[0]),c=(e=n)&&e.__esModule?e:{default:e};!(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(t||(t={}));class u{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new c.default(this.channel.channelAdapter,t)}}},1053,[1054]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});var n=r(d[0]);class t{constructor(s,c){const u=o(c);this.presence=new n.Presence(s.getChannel(),u),this.presence.onJoin((n,c,o)=>{const u=t.onJoinPayload(n,c,o);s.getChannel().trigger('presence',u)}),this.presence.onLeave((n,c,o)=>{const u=t.onLeavePayload(n,c,o);s.getChannel().trigger('presence',u)}),this.presence.onSync(()=>{s.getChannel().trigger('presence',{event:'sync'})})}get state(){return t.transformState(this.presence.state)}static transformState(n){return n=c(n),Object.getOwnPropertyNames(n).reduce((t,c)=>{const o=n[c];return t[c]=s(o),t},{})}static onJoinPayload(n,t,c){return{event:'join',key:n,currentPresences:u(t),newPresences:s(c)}}static onLeavePayload(n,t,c){return{event:'leave',key:n,currentPresences:u(t),leftPresences:s(c)}}}function s(n){return n.metas.map(n=>(n.presence_ref=n.phx_ref,delete n.phx_ref,delete n.phx_ref_prev,n))}function c(n){return JSON.parse(JSON.stringify(n))}function o(n){return(null==n?void 0:n.events)&&{events:n.events}}function u(n){return(null==n?void 0:n.metas)?s(n):[]}},1054,[1055]); +__d(function(g,r,_i,a,_m,_e2,d){"use strict";Object.defineProperty(_e2,'__esModule',{value:!0}),Object.defineProperty(_e2,"Channel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e2,"LongPoll",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e2,"Presence",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e2,"Push",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e2,"Serializer",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e2,"Socket",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e2,"Timer",{enumerable:!0,get:function(){return w}});var e=e=>{if("function"==typeof e)return e;return function(){return e}},t="undefined"!=typeof self?self:null,s="undefined"!=typeof window?window:null,i=t||s||globalThis,n=0,o=1,h=2,c=3,l="closed",u="errored",f="joined",p="joining",m="leaving",b="phx_close",k="phx_error",T="phx_join",y="phx_reply",C="phx_leave",v="longpoll",R="websocket",j=4,E="base64url.bearer.phx.",S=class{constructor(e,t,s,i){this.channel=e,this.event=t,this.payload=s||function(){return{}},this.receivedResp=null,this.timeout=i,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:s}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},w=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},A=class{constructor(t,s,i){this.state=l,this.topic=t,this.params=e(s||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new S(this,T,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new w(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=f,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=u,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=l,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=u,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new S(this,C,e({}),this.timeout).send(),this.state=u,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(y,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=l,this.bindings=[]}onClose(e){this.on(b,e)}onError(e){return this.on(k,t=>e(t))}on(e,t){let s=this.bindingRef++;return this.bindings.push({event:e,ref:s,callback:t}),s}off(e,t){this.bindings=this.bindings.filter(s=>!(s.event===e&&(void 0===t||t===s.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,s=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let i=new S(this,e,function(){return t},s);return this.canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=m;let s=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(b,"leave")},i=new S(this,C,e({}),t);return i.receive("ok",()=>s()).receive("timeout",()=>s()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,s){return t}filterBindings(e,t,s){return!0}isMember(e,t,s,i){return this.topic===e&&(!i||i===this.joinRef()||(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:s,joinRef:i}),!1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=p,this.joinPush.resend(e))}trigger(e,t,s,i){let n=this.onMessage(e,t,s,i);if(t&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let o=this.bindings.filter(i=>i.event===e&&this.filterBindings(i,t,s));for(let e=0;eu.abort(),o);l.signal=u.signal}return i.fetch(t,l).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>c&&c(e)).catch(e=>{"AbortError"===e.name&&h?h():c&&c(null)}),u}static xdomainRequest(e,t,s,i,n,o,h){return e.timeout=n,e.open(t,s),e.onload=()=>{let t=this.parseJSON(e.responseText);h&&h(t)},o&&(e.ontimeout=o),e.onprogress=()=>{},e.send(i),e}static xhrRequest(e,t,s,i,n,o,h,c){e.open(t,s,!0),e.timeout=o;for(let[t,s]of Object.entries(i))e.setRequestHeader(t,s);return e.onerror=()=>c&&c(null),e.onreadystatechange=()=>{if(e.readyState===j&&c){let t=this.parseJSON(e.responseText);c(t)}},h&&(e.ontimeout=h),e.send(n),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let s=[];for(var i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let n=t?`${t}[${i}]`:i,o=e[i];"object"==typeof o?s.push(this.serialize(o,n)):s.push(encodeURIComponent(n)+"="+encodeURIComponent(o))}return s.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let s=e.match(/\?/)?"&":"?";return`${e}${s}${this.serialize(t)}`}},L=e=>{let t="",s=new Uint8Array(e),i=s.byteLength;for(let e=0;ethis.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+R),"$1/"+v)}endpointURL(){return H.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,s){this.close(e,t,s),this.readyState=n}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===o||this.readyState===n}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:s,messages:i}=e;if(410===t&&null!==this.token)return this.onerror(410),void this.closeAndRetry(3410,"session_gone",!1);this.token=s}else t=0;switch(t){case 200:i.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=o,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}})}send(e){"string"!=typeof e&&(e=L(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join("\n"),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,e&&200===e.status?this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]):(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,s){for(let e of this.reqs)e.abort();this.readyState=c;let i=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:s});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"undefined"!=typeof CloseEvent?this.onclose(new CloseEvent("close",i)):this.onclose(i)}ajax(e,t,s,i,n){let o;o=H.request(e,this.endpointURL(),t,s,this.timeout,()=>{this.reqs.delete(o),i()},e=>{this.reqs.delete(o),this.isActive()&&n(e)}),this.reqs.add(o)}},B=class e{constructor(t,s={}){let i=s.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(i.state,t=>{let{onJoin:s,onLeave:i,onSync:n}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,s,i),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,s,i)}),this.pendingDiffs=[],n()}),this.channel.on(i.diff,t=>{let{onJoin:s,onLeave:i,onSync:n}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,s,i),n())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,s,i){let n=this.clone(e),o={},h={};return this.map(n,(e,s)=>{t[e]||(h[e]=s)}),this.map(t,(e,t)=>{let s=n[e];if(s){let i=t.metas.map(e=>e.phx_ref),n=s.metas.map(e=>e.phx_ref),c=t.metas.filter(e=>n.indexOf(e.phx_ref)<0),l=s.metas.filter(e=>i.indexOf(e.phx_ref)<0);c.length>0&&(o[e]=t,o[e].metas=c),l.length>0&&(h[e]=this.clone(s),h[e].metas=l)}else o[e]=t}),this.syncDiff(n,{joins:o,leaves:h},s,i)}static syncDiff(e,t,s,i){let{joins:n,leaves:o}=this.clone(t);return s||(s=function(){}),i||(i=function(){}),this.map(n,(t,i)=>{let n=e[t];if(e[t]=this.clone(i),n){let s=e[t].metas.map(e=>e.phx_ref),i=n.metas.filter(e=>s.indexOf(e.phx_ref)<0);e[t].metas.unshift(...i)}s(t,n,i)}),this.map(o,(t,s)=>{let n=e[t];if(!n)return;let o=s.metas.map(e=>e.phx_ref);n.metas=n.metas.filter(e=>o.indexOf(e.phx_ref)<0),i(t,n,s),0===n.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,s)=>t(e,s))}static map(e,t){return Object.getOwnPropertyNames(e).map(s=>t(s,e[s]))}static clone(e){return JSON.parse(JSON.stringify(e))}},O={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let s=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(s))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[s,i,n,o,h]=JSON.parse(e);return t({join_ref:s,ref:i,topic:n,event:o,payload:h})}},binaryEncode(e){let{join_ref:t,ref:s,event:i,topic:n,payload:o}=e,h=this.META_LENGTH+t.length+s.length+n.length+i.length,c=new ArrayBuffer(this.HEADER_LENGTH+h),l=new DataView(c),u=0;l.setUint8(u++,this.KINDS.push),l.setUint8(u++,t.length),l.setUint8(u++,s.length),l.setUint8(u++,n.length),l.setUint8(u++,i.length),Array.from(t,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(s,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(n,e=>l.setUint8(u++,e.charCodeAt(0))),Array.from(i,e=>l.setUint8(u++,e.charCodeAt(0)));var f=new Uint8Array(c.byteLength+o.byteLength);return f.set(new Uint8Array(c),0),f.set(new Uint8Array(o),c.byteLength),f.buffer},binaryDecode(e){let t=new DataView(e),s=t.getUint8(0),i=new TextDecoder;switch(s){case this.KINDS.push:return this.decodePush(e,t,i);case this.KINDS.reply:return this.decodeReply(e,t,i);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,i)}},decodePush(e,t,s){let i=t.getUint8(1),n=t.getUint8(2),o=t.getUint8(3),h=this.HEADER_LENGTH+this.META_LENGTH-1,c=s.decode(e.slice(h,h+i));h+=i;let l=s.decode(e.slice(h,h+n));h+=n;let u=s.decode(e.slice(h,h+o));return h+=o,{join_ref:c,ref:null,topic:l,event:u,payload:e.slice(h,e.byteLength)}},decodeReply(e,t,s){let i=t.getUint8(1),n=t.getUint8(2),o=t.getUint8(3),h=t.getUint8(4),c=this.HEADER_LENGTH+this.META_LENGTH,l=s.decode(e.slice(c,c+i));c+=i;let u=s.decode(e.slice(c,c+n));c+=n;let f=s.decode(e.slice(c,c+o));c+=o;let p=s.decode(e.slice(c,c+h));c+=h;let m=e.slice(c,e.byteLength);return{join_ref:l,ref:u,topic:f,event:y,payload:{status:p,response:m}}},decodeBroadcast(e,t,s){let i=t.getUint8(1),n=t.getUint8(2),o=this.HEADER_LENGTH+2,h=s.decode(e.slice(o,o+i));o+=i;let c=s.decode(e.slice(o,o+n));return o+=n,{join_ref:null,ref:null,topic:h,event:c,payload:e.slice(o,e.byteLength)}}},$=class{constructor(t,n={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=n.timeout||1e4,this.transport=n.transport||i.WebSocket||P,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=n.longPollFallbackMs,this.fallbackTimer=null;let o=null;try{o=i&&i.sessionStorage}catch{}this.sessionStore=n.sessionStorage||o,this.establishedConnections=0,this.defaultEncoder=O.encode.bind(O),this.defaultDecoder=O.decode.bind(O),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=n.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==P?(this.encode=n.encode||this.defaultEncoder,this.decode=n.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let h=null;s&&s.addEventListener&&(s.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),h=this.connectClock)}),s.addEventListener("pageshow",e=>{h===this.connectClock&&(h=null,this.connect())}),s.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=n.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=n.autoSendHeartbeat??!0,this.heartbeatCallback=n.heartbeatCallback??(()=>{}),this.rejoinAfterMs=e=>n.rejoinAfterMs?n.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>n.reconnectAfterMs?n.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=n.logger||null,!this.logger&&n.debug&&(this.logger=(e,t,s)=>{console.log(`${e}: ${t}`,s)}),this.longpollerTimeout=n.longpollerTimeout||2e4,this.params=e(n.params||{}),this.endPoint=`${t}/${R}`,this.vsn=n.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new w(()=>{if(this.pageHidden)return this.log("Not reconnecting as page is hidden!"),void this.teardown();this.teardown(async()=>{n.beforeReconnect&&await n.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=n.authToken}getLongPollTransport(){return P}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=H.appendParams(H.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,s){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,s)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=e(t)),this.conn&&!this.disconnecting||(this.longPollFallbackMs&&this.transport!==P?this.connectWithFallback(P,this.longPollFallbackMs):this.transportConnect())}log(e,t,s){this.logger&&this.logger(e,t,s)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),s=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let i=this.onMessage(n=>{n.ref===t&&(this.off([i]),e(Date.now()-s))});return!0}transportName(e){return e===P?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${E}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let s,i=!1,n=!0,o=this.transportName(e),h=t=>{this.log("transport",`falling back to ${o}...`,t),this.off([void 0,s]),n=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return h("memorized");this.fallbackTimer=setTimeout(h,t),s=this.onError(e=>{this.log("transport","error",e),n&&!i&&(clearTimeout(this.fallbackTimer),h(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(i=!0,!n){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,"true"),this.log("transport",`established ${t} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(h,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,s){if(!this.conn)return e&&e();const i=this.conn;this.waitForBufferDone(i,()=>{t?i.close(t,s||""):i.close(),this.waitForSocketClosed(i,()=>{this.conn===i&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,s=1){5!==s&&e.bufferedAmount?setTimeout(()=>{this.waitForBufferDone(e,t,s+1)},150*s):t()}waitForSocketClosed(e,t,s=1){5!==s&&e.readyState!==c?setTimeout(()=>{this.waitForSocketClosed(e,t,s+1)},150*s):t()}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,s=this.establishedConnections;this.triggerStateCallbacks("error",e,t,s),(t===this.transport||s>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(k,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case n:return"connecting";case o:return"open";case h:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>-1===e.indexOf(t))}channel(e,t={}){let s=new A(e,t,this);return this.channels.push(s),s}push(e){if(this.hasLogger()){let{topic:t,event:s,payload:i,ref:n,join_ref:o}=e;this.log("push",`${t} ${s} (${o}, ${n})`,i)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(this.isConnected())if(this.pendingHeartbeatRef)this.heartbeatTimeout();else{this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}else try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:s,payload:i,ref:n,join_ref:o}=e;if(n&&n===this.pendingHeartbeatRef){const e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===i.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${i.status||""} ${t} ${s} ${n&&"("+n+")"||""}`.trim(),i);for(let e=0;e{try{i(...t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}}},1055,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeChannelError=function(n){if(n instanceof Error)return n;if('string'==typeof n)return new Error(n);if(n&&'object'==typeof n){const o=n;if('number'==typeof o.code){const t='string'==typeof o.reason&&o.reason?` (${o.reason})`:'';return new Error(`socket closed: ${o.code}${t}`,{cause:n})}return new Error('channel error: transport failure',{cause:n})}return new Error('channel error: connection lost')}},1056,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});var n=r(d[0]);class t{constructor(n,t,s){const h=(o=s,{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:'',enabled:!1},private:!1},o.config)});var o;this.channel=n.getSocket().channel(t,h),this.socket=n}get state(){return this.channel.state}set state(n){this.channel.state=n}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(n,t){return this.channel.on(n,t)}off(n,t){this.channel.off(n,t)}subscribe(n){return this.channel.join(n)}unsubscribe(n){return this.channel.leave(n)}teardown(){this.channel.teardown()}onClose(n){this.channel.onClose(n)}onError(n){return this.channel.onError(n)}push(t,s,h){let o;try{o=this.channel.push(t,s,h)}catch(n){throw new Error(`tried to push '${t}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>n.MAX_PUSH_BUFFER_SIZE){const n=this.channel.pushBuffer.shift();n.cancelTimeout(),this.socket.log('channel',`discarded push due to buffer overflow: ${n.event}`,n.payload())}return o}updateJoinPayload(n){const t=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},t),n)}canPush(){return this.socket.isConnected()&&this.state===n.CHANNEL_STATES.joined}isJoined(){return this.state===n.CHANNEL_STATES.joined}isJoining(){return this.state===n.CHANNEL_STATES.joining}isClosed(){return this.state===n.CHANNEL_STATES.closed}isLeaving(){return this.state===n.CHANNEL_STATES.leaving}updateFilterBindings(n){this.channel.filterBindings=n}updatePayloadTransform(n){this.channel.onMessage=n}getChannel(){return this.channel}}},1057,[1048]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"postgresChangesFilter",{enumerable:!0,get:function(){return c}});const t=/[,()"\\]/,n=n=>t.test(n)||n!==n.trim(),s=t=>`"${t.replace(/\\/g,'\\\\').replace(/"/g,'\\"')}"`,u=t=>{const u=null===t?'null':String(t);return n(u)?s(u):u},l=t=>null===t?'null':String(t),h=(t,n)=>{if('in'===t){const t=Array.isArray(n)?n:[n];if(0===t.length)throw new Error('Realtime `in` filter requires at least one value.');return`in.(${Array.from(new Set(t)).map(t=>u(t)).join(',')})`}return'is'===t?`is.${l(n)}`:`${t}.${u(n)}`};class o{constructor(){this.filters=[]}add(t,n,s,u=!1){const l=u?'not.':'';return this.filters.push(`${t}=${l}${h(n,s)}`),this}eq(t,n){return this.add(t,'eq',n)}neq(t,n){return this.add(t,'neq',n)}gt(t,n){return this.add(t,'gt',n)}gte(t,n){return this.add(t,'gte',n)}lt(t,n){return this.add(t,'lt',n)}lte(t,n){return this.add(t,'lte',n)}in(t,n){return this.add(t,'in',n)}like(t,n){return this.add(t,'like',n)}ilike(t,n){return this.add(t,'ilike',n)}match(t,n){return this.add(t,'match',n)}imatch(t,n){return this.add(t,'imatch',n)}is(t,n){return this.add(t,'is',n)}isDistinct(t,n){return this.add(t,'isdistinct',n)}not(t,n,s){return this.add(t,n,s,!0)}build(){return this.filters.join(',')}toString(){return this.build()}}const c=()=>new o},1058,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var t=r(d[0]),n=r(d[1]);class s{constructor(n,s){this.socket=new t.Socket(n,s)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(t){this.socket.heartbeatCallback=t}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(t,n,s,o=1e4){return new Promise(c=>{setTimeout(()=>c('timeout'),o),this.socket.disconnect(()=>{t(),c('ok')},n,s)})}push(t){this.socket.push(t)}log(t,n,s){this.socket.log(t,n,s)}makeRef(){return this.socket.makeRef()}onOpen(t){this.socket.onOpen(t)}onClose(t){this.socket.onClose(t)}onError(t){this.socket.onError(t)}onMessage(t){this.socket.onMessage(t)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==n.CONNECTION_STATE.connecting}isDisconnecting(){return this.socket.connectionState()==n.CONNECTION_STATE.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}},1059,[1055,1048]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"StorageAnalyticsClient",{enumerable:!0,get:function(){return H}}),Object.defineProperty(_e,"StorageApiError",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"StorageClient",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(_e,"StorageError",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"StorageUnknownError",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"StorageVectorsApiError",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"StorageVectorsClient",{enumerable:!0,get:function(){return X}}),Object.defineProperty(_e,"StorageVectorsError",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"StorageVectorsErrorCode",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"StorageVectorsUnknownError",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"VectorBucketApi",{enumerable:!0,get:function(){return W}}),Object.defineProperty(_e,"VectorBucketScope",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(_e,"VectorDataApi",{enumerable:!0,get:function(){return G}}),Object.defineProperty(_e,"VectorIndexApi",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(_e,"VectorIndexScope",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(_e,"isStorageError",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"isStorageVectorsError",{enumerable:!0,get:function(){return f}});var e=_r(d[0]);function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function n(e){var n=r(e,"string");return"symbol"==t(n)?n:n+""}function o(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function c(e){for(var t=1;t{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},k=e=>{if(Array.isArray(e))return e.map(e=>k(e));if("function"==typeof e||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([e,r])=>{const n=e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""));t[n]=k(r)}),t},x=e=>!(!e||"string"!=typeof e)&&(!(0===e.length||e.length>100)&&(e.trim()===e&&(!e.includes("/")&&!e.includes("\\")&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e)))),$=e=>{if("object"==typeof e&&null!==e){const t=e;if("string"==typeof t.msg)return t.msg;if("string"==typeof t.message)return t.message;if("string"==typeof t.error_description)return t.error_description;if("string"==typeof t.error)return t.error;if("object"==typeof t.error&&null!==t.error){const e=t.error;if("string"==typeof e.message)return e.message}}return JSON.stringify(e)},j=async(e,t,r,n)=>{if(null!==e&&"object"==typeof e&&"json"in e&&"function"==typeof e.json){const r=e;let o=parseInt(String(r.status),10);Number.isFinite(o)||(o=500),r.json().then(e=>{const r=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||o+"";t(new l($(e),o,r,n))}).catch(()=>{const e=o+"";t(new l(r.statusText||`HTTP ${o} error`,o,e,n))})}else t(new h($(e),e,n))},B=(e,t,r,n)=>{const o={method:e,headers:(null==t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!n)return c(c({},o),r);if(S(n)){var s;const e=(null==t?void 0:t.headers)||{};let r;for(const[t,n]of Object.entries(e))"content-type"===t.toLowerCase()&&(r=n);o.headers=w(e,"Content-Type",null!==(s=r)&&void 0!==s?s:"application/json"),o.body=JSON.stringify(n)}else o.body=n;return(null==t?void 0:t.duplex)&&(o.duplex=t.duplex),c(c({},o),r)};async function P(e,t,r,n,o,s,c){return new Promise((i,u)=>{e(r,B(t,n,o,s)).then(e=>{if(!e.ok)throw e;if(null==n?void 0:n.noResolveJson)return e;if("vectors"===c){const t=e.headers.get("content-type");if("0"===e.headers.get("content-length")||204===e.status)return{};if(!t||!t.includes("application/json"))return{}}return e.json()}).then(e=>i(e)).catch(e=>j(e,u,0,c))})}function N(e="storage"){return{get:async(t,r,n,o)=>P(t,"GET",r,n,o,void 0,e),post:async(t,r,n,o,s)=>P(t,"POST",r,o,s,n,e),put:async(t,r,n,o,s)=>P(t,"PUT",r,o,s,n,e),head:async(t,r,n,o)=>P(t,"HEAD",r,c(c({},n),{},{noResolveJson:!0}),o,void 0,e),remove:async(t,r,n,o,s)=>P(t,"DELETE",r,o,s,n,e)}}const E=N("storage"),{get:C,post:V,put:I,head:T,remove:U}=E,_=N("vectors");var F=class{constructor(e,t={},r,n="storage"){var o;this.shouldThrowOnError=!1,this.url=e,this.headers=O(t),this.fetch=(o=r)?(...e)=>o(...e):(...e)=>fetch(...e),this.namespace=n}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=w(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(u(e))return{data:null,error:e};throw e}}};let R;R=Symbol.toStringTag;var L=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[R]="StreamDownloadBuilder",this.promise=null}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(u(e))return{data:null,error:e};throw e}}};let D;D=Symbol.toStringTag;var A=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[D]="BlobDownloadBuilder",this.promise=null}asStream(){return new L(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:await(await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(u(e))return{data:null,error:e};throw e}}};const M={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},z={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var J=class extends F{constructor(e,t={},r,n){super(e,t,n,"storage"),this.bucketId=r}async uploadOrUpdate(e,t,r,n){var o=this;return o.handleOperation(async()=>{let s;const i=c(c({},z),n);let u=c(c({},o.headers),"POST"===e&&{"x-upsert":String(i.upsert)});const l=i.metadata;if("undefined"!=typeof Blob&&r instanceof Blob?(s=new FormData,s.append("cacheControl",i.cacheControl),l&&s.append("metadata",o.encodeMetadata(l)),s.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(s=r,s.has("cacheControl")||s.append("cacheControl",i.cacheControl),l&&!s.has("metadata")&&s.append("metadata",o.encodeMetadata(l))):(s=r,u["cache-control"]=`max-age=${i.cacheControl}`,u["content-type"]=i.contentType,l&&(u["x-metadata"]=o.toBase64(o.encodeMetadata(l))),("undefined"!=typeof ReadableStream&&s instanceof ReadableStream||s&&"object"==typeof s&&"pipe"in s&&"function"==typeof s.pipe)&&!i.duplex&&(i.duplex="half")),null==n?void 0:n.headers)for(const[e,t]of Object.entries(n.headers))u=w(u,e,t);const h=o._removeEmptyFolders(t),p=o._getFinalPath(h),f=await("PUT"==e?I:V)(o.fetch,`${o.url}/object/${p}`,s,c({headers:u},(null==i?void 0:i.duplex)?{duplex:i.duplex}:{}));return{path:h,id:f.Id,fullPath:f.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,n){var o=this;const s=o._removeEmptyFolders(e),i=o._getFinalPath(s),u=new URL(o.url+`/object/upload/sign/${i}`);return u.searchParams.set("token",t),o.handleOperation(async()=>{let e;const t=c(c({},z),n);let i=c(c({},o.headers),{"x-upsert":String(t.upsert)});const l=t.metadata;if("undefined"!=typeof Blob&&r instanceof Blob?(e=new FormData,e.append("cacheControl",t.cacheControl),l&&e.append("metadata",o.encodeMetadata(l)),e.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(e=r,e.has("cacheControl")||e.append("cacheControl",t.cacheControl),l&&!e.has("metadata")&&e.append("metadata",o.encodeMetadata(l))):(e=r,i["cache-control"]=`max-age=${t.cacheControl}`,i["content-type"]=t.contentType,l&&(i["x-metadata"]=o.toBase64(o.encodeMetadata(l))),("undefined"!=typeof ReadableStream&&e instanceof ReadableStream||e&&"object"==typeof e&&"pipe"in e&&"function"==typeof e.pipe)&&!t.duplex&&(t.duplex="half")),null==n?void 0:n.headers)for(const[e,t]of Object.entries(n.headers))i=w(i,e,t);return{path:s,fullPath:(await I(o.fetch,u.toString(),e,c({headers:i},(null==t?void 0:t.duplex)?{duplex:t.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var r=this;return r.handleOperation(async()=>{let n=r._getFinalPath(e);const o=c({},r.headers);(null==t?void 0:t.upsert)&&(o["x-upsert"]="true");const s=await V(r.fetch,`${r.url}/object/upload/sign/${n}`,{},{headers:o}),u=new URL(r.url+s.url),l=u.searchParams.get("token");if(!l)throw new i("No token returned by API");return{signedUrl:u.toString(),path:e,token:l}})}async update(e,t,r){return this.uploadOrUpdate("PUT",e,t,r)}async move(e,t,r){var n=this;return n.handleOperation(async()=>await V(n.fetch,`${n.url}/object/move`,{bucketId:n.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:n.headers}))}async copy(e,t,r){var n=this;return n.handleOperation(async()=>({path:(await V(n.fetch,`${n.url}/object/copy`,{bucketId:n.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:n.headers})).Key}))}async createSignedUrl(e,t,r){var n=this;return n.handleOperation(async()=>{let o=n._getFinalPath(e);const s="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0;let i=await V(n.fetch,`${n.url}/object/sign/${o}`,c({expiresIn:t},s?{transform:r.transform}:{}),{headers:n.headers});const u=new URLSearchParams;(null==r?void 0:r.download)&&u.set("download",!0===r.download?"":r.download),null!=(null==r?void 0:r.cacheNonce)&&u.set("cacheNonce",String(r.cacheNonce));const l=u.toString();return{signedUrl:encodeURI(`${n.url}${i.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(e,t,r){var n=this;return n.handleOperation(async()=>{const o=await V(n.fetch,`${n.url}/object/sign/${n.bucketId}`,{expiresIn:t,paths:e},{headers:n.headers}),s=new URLSearchParams;(null==r?void 0:r.download)&&s.set("download",!0===r.download?"":r.download),null!=(null==r?void 0:r.cacheNonce)&&s.set("cacheNonce",String(r.cacheNonce));const i=s.toString();return o.map(e=>c(c({},e),{},{signedUrl:e.signedURL?encodeURI(`${n.url}${e.signedURL}${i?`&${i}`:""}`):null}))})}download(e,t,r){const n="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",o=new URLSearchParams;(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(o,t.transform),null!=(null==t?void 0:t.cacheNonce)&&o.set("cacheNonce",String(t.cacheNonce));const s=o.toString(),c=this._getFinalPath(e);return new A(()=>C(this.fetch,`${this.url}/${n}/${c}${s?`?${s}`:""}`,{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e){var t=this;const r=t._getFinalPath(e);return t.handleOperation(async()=>k(await C(t.fetch,`${t.url}/object/info/${r}`,{headers:t.headers})))}async exists(e){var t=this;const r=t._getFinalPath(e);try{return await T(t.fetch,`${t.url}/object/${r}`,{headers:t.headers}),{data:!0,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(u(e)){var n;const t=e instanceof l?e.status:e instanceof h?null===(n=e.originalError)||void 0===n?void 0:n.status:void 0;if(void 0!==t&&[400,404].includes(t))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){const r=this._getFinalPath(e),n=new URLSearchParams;(null==t?void 0:t.download)&&n.set("download",!0===t.download?"":t.download),(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(n,t.transform),null!=(null==t?void 0:t.cacheNonce)&&n.set("cacheNonce",String(t.cacheNonce));const o=n.toString(),s="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${s}/public/${r}`)+(o?`?${o}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await U(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async purgeCache(e,t,r){var n=this;return n.handleOperation(async()=>{const o=n._getFinalPath(e),s=new URLSearchParams;(null==t?void 0:t.transformations)&&s.set("transformations","true");const c=s.toString();return await U(n.fetch,`${n.url}/cdn/${o}${c?`?${c}`:""}`,{},{headers:n.headers},r)})}async list(e,t,r){var n=this;return n.handleOperation(async()=>{const o=(null==t?void 0:t.sortBy)?c(c({},M.sortBy),t.sortBy):M.sortBy,s=c(c(c({},M),t),{},{sortBy:o,prefix:e||""});return await V(n.fetch,`${n.url}/object/list/${n.bucketId}`,s,{headers:n.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{const n=c({},e);return await V(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,n,{headers:r.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return"undefined"!=typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("quality",t.quality.toString()),e}};const K={"X-Client-Info":"storage-js/2.109.0"};var q=class extends F{constructor(e,t={},r,n){const o=new URL(e);(null==n?void 0:n.useNewHostname)&&/supabase\.(co|in|red)$/.test(o.hostname)&&!o.hostname.includes("storage.supabase.")&&(o.hostname=o.hostname.replace("supabase.","storage.supabase."));super(o.href.replace(/\/$/,""),c(c({},K),t),r,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const r=t.listBucketOptionsToQueryString(e);return await C(t.fetch,`${t.url}/bucket${r}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await C(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var r=this;return r.handleOperation(async()=>await V(r.fetch,`${r.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await I(r.fetch,`${r.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await V(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await U(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}async purgeBucketCache(e,t,r){var n=this;return n.handleOperation(async()=>{const o=new URLSearchParams;(null==t?void 0:t.transformations)&&o.set("transformations","true");const s=o.toString();return await U(n.fetch,`${n.url}/cdn/${e}${s?`?${s}`:""}`,{},{headers:n.headers},r)})}listBucketOptionsToQueryString(e){const t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},H=class extends F{constructor(e,t={},r){super(e.replace(/\/$/,""),c(c({},K),t),r,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await V(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const r=new URLSearchParams;void 0!==(null==e?void 0:e.limit)&&r.set("limit",e.limit.toString()),void 0!==(null==e?void 0:e.offset)&&r.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&r.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&r.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&r.set("search",e.search);const n=r.toString(),o=n?`${t.url}/bucket?${n}`:`${t.url}/bucket`;return await C(t.fetch,o,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await U(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(t){var r=this;if(!x(t))throw new i("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const n=new e.IcebergRestCatalog({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>r.headers},fetch:this.fetch}),o=this.shouldThrowOnError;return new Proxy(n,{get(e,t){const r=e[t];return"function"!=typeof r?r:async(...t)=>{try{return{data:await r.apply(e,t),error:null}}catch(e){if(o)throw e;return{data:null,error:e}}}}})}},Q=class extends F{constructor(e,t={},r){super(e.replace(/\/$/,""),c(c({},K),{},{"Content-Type":"application/json"},t),r,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await _.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await _.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}},G=class extends F{constructor(e,t={},r){super(e.replace(/\/$/,""),c(c({},K),{},{"Content-Type":"application/json"},t),r,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw new Error("segmentIndex must be between 0 and "+(e.segmentCount-1))}return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},W=class extends F{constructor(e,t={},r){super(e.replace(/\/$/,""),c(c({},K),{},{"Content-Type":"application/json"},t),r,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await _.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},X=class extends W{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new Y(this.url,this.headers,e,this.fetch)}async createBucket(e){return(()=>super.createBucket)().call(this,e)}async getBucket(e){return(()=>super.getBucket)().call(this,e)}async listBuckets(e={}){return(()=>super.listBuckets)().call(this,e)}async deleteBucket(e){return(()=>super.deleteBucket)().call(this,e)}},Y=class extends Q{constructor(e,t,r,n){super(e,t,n),this.vectorBucketName=r}async createIndex(e){return(()=>super.createIndex)().call(this,c(c({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(e={}){return(()=>super.listIndexes)().call(this,c(c({},e),{},{vectorBucketName:this.vectorBucketName}))}async getIndex(e){return(()=>super.getIndex)().call(this,this.vectorBucketName,e)}async deleteIndex(e){return(()=>super.deleteIndex)().call(this,this.vectorBucketName,e)}index(e){return new Z(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},Z=class extends G{constructor(e,t,r,n,o){super(e,t,o),this.vectorBucketName=r,this.indexName=n}async putVectors(e){var t=this;return(()=>super.putVectors)().call(t,c(c({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async getVectors(e){var t=this;return(()=>super.getVectors)().call(t,c(c({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async listVectors(e={}){var t=this;return(()=>super.listVectors)().call(t,c(c({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async queryVectors(e){var t=this;return(()=>super.queryVectors)().call(t,c(c({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async deleteVectors(e){var t=this;return(()=>super.deleteVectors)().call(t,c(c({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}},ee=class extends q{constructor(e,t={},r,n){super(e,t,r,n)}from(e){return new J(this.url,this.headers,e,this.fetch)}get vectors(){return new X(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new H(this.url+"/iceberg",this.headers,this.fetch)}}},1060,[1061]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IcebergError",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"IcebergRestCatalog",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"getCurrentSchema",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isDecimalType",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isFixedType",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseDecimalType",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseFixedType",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"typesEqual",{enumerable:!0,get:function(){return x}});var t=class extends Error{constructor(t,a){super(t),this.name="IcebergError",this.status=a.status,this.icebergType=a.icebergType,this.icebergCode=a.icebergCode,this.details=a.details,this.isCommitStateUnknown="CommitStateUnknownException"===a.icebergType||[500,502,504].includes(a.status)&&!0===a.icebergType?.includes("CommitState")}isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}};function a(t,a,s){const n=new URL(a,t);if(s)for(const[t,a]of Object.entries(s))void 0!==a&&n.searchParams.set(t,a);return n.toString()}async function s(t){return t&&"none"!==t.type?"bearer"===t.type?{Authorization:`Bearer ${t.token}`}:"header"===t.type?{[t.name]:t.value}:"custom"===t.type?await t.getHeaders():{}:{}}function n(n){const c=n.fetchImpl??globalThis.fetch;return{async request({method:o,path:p,query:u,body:l,headers:h}){const b=a(n.baseUrl,p,u),f=await s(n.auth),y=await c(b,{method:o,headers:{...l?{"Content-Type":"application/json"}:{},...f,...h},body:l?JSON.stringify(l):void 0}),T=await y.text(),w=(y.headers.get("content-type")||"").includes("application/json"),x=w&&T?JSON.parse(T):T;if(!y.ok){const a=w?x:void 0,s=a?.error;throw new t(s?.message??`Request failed with status ${y.status}`,{status:y.status,icebergType:s?.type,icebergCode:s?.code,details:a})}return{status:y.status,headers:y.headers,data:x}}}}function c(t){return t.join("\x1f")}var o=class{constructor(t,a=""){this.client=t,this.prefix=a}async listNamespaces(t){const a=t?{parent:c(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:a})).data.namespaces.map(t=>({namespace:t}))}async createNamespace(t,a){const s={namespace:t.namespace,properties:a?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:s})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${c(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${c(t.namespace)}`})).data.properties}}async namespaceExists(a){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${c(a.namespace)}`}),!0}catch(a){if(a instanceof t&&404===a.status)return!1;throw a}}async createNamespaceIfNotExists(a,s){try{return await this.createNamespace(a,s)}catch(a){if(a instanceof t&&409===a.status)return;throw a}}};function p(t){return t.join("\x1f")}var u=class{constructor(t,a="",s){this.client=t,this.prefix=a,this.accessDelegation=s}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${p(t.namespace)}/tables`})).data.identifiers}async createTable(t,a){const s={};this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation);return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${p(t.namespace)}/tables`,body:a,headers:s})).data.metadata}async updateTable(t,a){const s=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${p(t.namespace)}/tables/${t.name}`,body:a});return{"metadata-location":s.data["metadata-location"],metadata:s.data.metadata}}async dropTable(t,a){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${p(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String(a?.purge??!1)}})}async loadTable(t){const a={};this.accessDelegation&&(a["X-Iceberg-Access-Delegation"]=this.accessDelegation);return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${p(t.namespace)}/tables/${t.name}`,headers:a})).data.metadata}async tableExists(a){const s={};this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${p(a.namespace)}/tables/${a.name}`,headers:s}),!0}catch(a){if(a instanceof t&&404===a.status)return!1;throw a}}async createTableIfNotExists(a,s){try{return await this.createTable(a,s)}catch(n){if(n instanceof t&&409===n.status)return await this.loadTable({namespace:a.namespace,name:s.name});throw n}}},l=class{constructor(t){let a="v1";t.catalogName&&(a+=`/${t.catalogName}`);const s=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=n({baseUrl:s,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new o(this.client,a),this.tableOps=new u(this.client,a,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,a){return this.namespaceOps.createNamespace(t,a)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,a){return this.tableOps.createTable(t,a)}async updateTable(t,a){return this.tableOps.updateTable(t,a)}async dropTable(t,a){await this.tableOps.dropTable(t,a)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,a){return this.namespaceOps.createNamespaceIfNotExists(t,a)}async createTableIfNotExists(t,a){return this.tableOps.createTableIfNotExists(t,a)}},h=/^decimal\s*\(\s*(\d+)\s*,\s*(\d+)\s*\)$/,b=/^fixed\s*\[\s*(\d+)\s*\]$/;function f(t){const a=t.match(h);return a?{precision:parseInt(a[1],10),scale:parseInt(a[2],10)}:null}function y(t){const a=t.match(b);return a?{length:parseInt(a[1],10)}:null}function T(t){return h.test(t)}function w(t){return b.test(t)}function x(t,a){const s=f(t),n=f(a);if(s&&n)return s.precision===n.precision&&s.scale===n.scale;const c=y(t),o=y(a);return c&&o?c.length===o.length:t===a}function O(t){return t.schemas.find(a=>a["schema-id"]===t["current-schema-id"])}},1061,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"navigatorLock",{enumerable:!0,get:function(){return l.navigatorLock}}),Object.defineProperty(_e,"NavigatorLockAcquireTimeoutError",{enumerable:!0,get:function(){return l.NavigatorLockAcquireTimeoutError}}),Object.defineProperty(_e,"lockInternals",{enumerable:!0,get:function(){return l.internals}}),Object.defineProperty(_e,"processLock",{enumerable:!0,get:function(){return l.processLock}}),Object.defineProperty(_e,"GoTrueAdminApi",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(_e,"GoTrueClient",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(_e,"AuthAdminApi",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(_e,"AuthClient",{enumerable:!0,get:function(){return u.default}});var t=e(r(d[0])),n=e(r(d[1])),o=e(r(d[2])),u=e(r(d[3])),c=r(d[4]);Object.keys(c).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(d[5]);Object.keys(f).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return f[e]}})});var l=r(d[6])},1062,[1063,1071,1078,1079,1070,1068,1073]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});var t=r(d[0]),s=r(d[1]),n=r(d[2]),o=r(d[3]),h=r(d[4]);class u{constructor({url:t="",headers:s={},fetch:o,experimental:h}){this.url=t,this.headers=s,this.fetch=(0,n.resolveFetch)(o),this.experimental=null!=h?h:{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(t,n=o.SIGN_OUT_SCOPES[0]){if(o.SIGN_OUT_SCOPES.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${o.SIGN_OUT_SCOPES.join(', ')}`);try{return await(0,s._request)(this.fetch,'POST',`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async inviteUserByEmail(t,n={}){try{return await(0,s._request)(this.fetch,'POST',`${this.url}/invite`,{body:{email:t,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:s._userResponse})}catch(t){if((0,h.isAuthError)(t))return{data:{user:null},error:t};throw t}}async generateLink(n){try{const{options:o}=n,h=(0,t.__rest)(n,["options"]),u=Object.assign(Object.assign({},h),o);return'newEmail'in h&&(u.new_email=null==h?void 0:h.newEmail,delete u.newEmail),await(0,s._request)(this.fetch,'POST',`${this.url}/admin/generate_link`,{body:u,headers:this.headers,xform:s._generateLinkResponse,redirectTo:null==o?void 0:o.redirectTo})}catch(t){if((0,h.isAuthError)(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(t){try{return await(0,s._request)(this.fetch,'POST',`${this.url}/admin/users`,{body:t,headers:this.headers,xform:s._userResponse})}catch(t){if((0,h.isAuthError)(t))return{data:{user:null},error:t};throw t}}async listUsers(t){var n,o,u,l,c,f,_;try{const h={nextPage:null,lastPage:0,total:0},y=await(0,s._request)(this.fetch,'GET',`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!==(o=null===(n=null==t?void 0:t.page)||void 0===n?void 0:n.toString())&&void 0!==o?o:'',per_page:null!==(l=null===(u=null==t?void 0:t.perPage)||void 0===u?void 0:u.toString())&&void 0!==l?l:''},xform:s._noResolveJsonResponse});if(y.error)throw y.error;const v=await y.json(),p=null!==(c=y.headers.get('x-total-count'))&&void 0!==c?c:0,E=null!==(_=null===(f=y.headers.get('link'))||void 0===f?void 0:f.split(','))&&void 0!==_?_:[];return E.length>0&&(E.forEach(t=>{const s=parseInt(t.split(';')[0].split('=')[1].substring(0,1)),n=JSON.parse(t.split(';')[1].split('=')[1]);h[`${n}Page`]=s}),h.total=parseInt(p)),{data:Object.assign(Object.assign({},v),h),error:null}}catch(t){if((0,h.isAuthError)(t))return{data:{users:[]},error:t};throw t}}async getUserById(t){(0,n.validateUUID)(t);try{return await(0,s._request)(this.fetch,'GET',`${this.url}/admin/users/${t}`,{headers:this.headers,xform:s._userResponse})}catch(t){if((0,h.isAuthError)(t))return{data:{user:null},error:t};throw t}}async updateUserById(t,o){(0,n.validateUUID)(t);try{return await(0,s._request)(this.fetch,'PUT',`${this.url}/admin/users/${t}`,{body:o,headers:this.headers,xform:s._userResponse})}catch(t){if((0,h.isAuthError)(t))return{data:{user:null},error:t};throw t}}async deleteUser(t,o=!1){(0,n.validateUUID)(t);try{return await(0,s._request)(this.fetch,'DELETE',`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:o},xform:s._userResponse})}catch(t){if((0,h.isAuthError)(t))return{data:{user:null},error:t};throw t}}async _listFactors(t){(0,n.validateUUID)(t.userId);try{const{data:n,error:o}=await(0,s._request)(this.fetch,'GET',`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:t=>({data:{factors:t},error:null})});return{data:n,error:o}}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _deleteFactor(t){(0,n.validateUUID)(t.userId),(0,n.validateUUID)(t.id);try{return{data:await(0,s._request)(this.fetch,'DELETE',`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _listOAuthClients(t){var n,o,u,l,c,f,_;try{const h={nextPage:null,lastPage:0,total:0},y=await(0,s._request)(this.fetch,'GET',`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:null!==(o=null===(n=null==t?void 0:t.page)||void 0===n?void 0:n.toString())&&void 0!==o?o:'',per_page:null!==(l=null===(u=null==t?void 0:t.perPage)||void 0===u?void 0:u.toString())&&void 0!==l?l:''},xform:s._noResolveJsonResponse});if(y.error)throw y.error;const v=await y.json(),p=null!==(c=y.headers.get('x-total-count'))&&void 0!==c?c:0,E=null!==(_=null===(f=y.headers.get('link'))||void 0===f?void 0:f.split(','))&&void 0!==_?_:[];return E.length>0&&(E.forEach(t=>{const s=parseInt(t.split(';')[0].split('=')[1].substring(0,1)),n=JSON.parse(t.split(';')[1].split('=')[1]);h[`${n}Page`]=s}),h.total=parseInt(p)),{data:Object.assign(Object.assign({},v),h),error:null}}catch(t){if((0,h.isAuthError)(t))return{data:{clients:[]},error:t};throw t}}async _createOAuthClient(t){try{return await(0,s._request)(this.fetch,'POST',`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _getOAuthClient(t){try{return await(0,s._request)(this.fetch,'GET',`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _updateOAuthClient(t,n){try{return await(0,s._request)(this.fetch,'PUT',`${this.url}/admin/oauth/clients/${t}`,{body:n,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _deleteOAuthClient(t){try{return await(0,s._request)(this.fetch,'DELETE',`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _regenerateOAuthClientSecret(t){try{return await(0,s._request)(this.fetch,'POST',`${this.url}/admin/oauth/clients/${t}/regenerate_secret`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _listCustomProviders(t){try{const n={};return(null==t?void 0:t.type)&&(n.type=t.type),await(0,s._request)(this.fetch,'GET',`${this.url}/admin/custom-providers`,{headers:this.headers,query:n,xform:t=>{var s;return{data:{providers:null!==(s=null==t?void 0:t.providers)&&void 0!==s?s:[]},error:null}}})}catch(t){if((0,h.isAuthError)(t))return{data:{providers:[]},error:t};throw t}}async _createCustomProvider(t){try{return await(0,s._request)(this.fetch,'POST',`${this.url}/admin/custom-providers`,{body:t,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _getCustomProvider(t){try{return await(0,s._request)(this.fetch,'GET',`${this.url}/admin/custom-providers/${t}`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _updateCustomProvider(t,n){try{return await(0,s._request)(this.fetch,'PUT',`${this.url}/admin/custom-providers/${t}`,{body:n,headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _deleteCustomProvider(t){try{return await(0,s._request)(this.fetch,'DELETE',`${this.url}/admin/custom-providers/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _adminListPasskeys(t){(0,n.assertPasskeyExperimentalEnabled)(this.experimental),(0,n.validateUUID)(t.userId);try{return await(0,s._request)(this.fetch,'GET',`${this.url}/admin/users/${t.userId}/passkeys`,{headers:this.headers,xform:t=>({data:t,error:null})})}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}async _adminDeletePasskey(t){(0,n.assertPasskeyExperimentalEnabled)(this.experimental),(0,n.validateUUID)(t.userId),(0,n.validateUUID)(t.passkeyId);try{return await(0,s._request)(this.fetch,'DELETE',`${this.url}/admin/users/${t.userId}/passkeys/${t.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if((0,h.isAuthError)(t))return{data:null,error:t};throw t}}}},1063,[1041,1064,1067,1070,1068]); +__d(function(g,r,_i,_a2,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.handleError=i,_e._request=async function(e,o,t,n){var a;const i=Object.assign({},null==n?void 0:n.headers);i[s.API_VERSION_HEADER_NAME]||(i[s.API_VERSION_HEADER_NAME]=s.API_VERSIONS['2024-01-01'].name);(null==n?void 0:n.jwt)&&(i.Authorization=`Bearer ${n.jwt}`);const u=null!==(a=null==n?void 0:n.query)&&void 0!==a?a:{};(null==n?void 0:n.redirectTo)&&(u.redirect_to=n.redirectTo);const l=Object.keys(u).length?'?'+new URLSearchParams(u).toString():'',_=await c(e,o,t+l,{headers:i,noResolveJson:null==n?void 0:n.noResolveJson},{},null==n?void 0:n.body);return(null==n?void 0:n.xform)?null==n?void 0:n.xform(_):{data:Object.assign({},_),error:null}},_e._sessionResponse=l,_e._sessionResponsePassword=function(e){const s=l(e);!s.error&&e.weak_password&&'object'==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&'string'==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,s)=>e&&'string'==typeof s,!0)&&(s.data.weak_password=e.weak_password);return s},_e._userResponse=function(e){var s;return{data:{user:null!==(s=e.user)&&void 0!==s?s:e},error:null}},_e._ssoResponse=function(e){return{data:e,error:null}},_e._generateLinkResponse=function(s){const{action_link:o,email_otp:t,hashed_token:n,redirect_to:a,verification_type:i}=s,u=(0,e.__rest)(s,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),c={action_link:o,email_otp:t,hashed_token:n,redirect_to:a,verification_type:i},l=Object.assign({},u);return{data:{properties:c,user:l},error:null}},_e._noResolveJsonResponse=function(e){return e};var e=r(d[0]),s=r(d[1]),o=r(d[2]),t=r(d[3]);const n=e=>{if('object'==typeof e&&null!==e){const s=e;if('string'==typeof s.msg)return s.msg;if('string'==typeof s.message)return s.message;if('string'==typeof s.error_description)return s.error_description;if('string'==typeof s.error)return s.error}return JSON.stringify(e)},a=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function i(e){var i;if(!(0,o.looksLikeFetchResponse)(e))throw new t.AuthRetryableFetchError(n(e),0);if(a.includes(e.status))throw new t.AuthRetryableFetchError(n(e),e.status);let u,c;try{u=await e.json()}catch(e){throw new t.AuthUnknownError(n(e),e)}const l=(0,o.parseResponseAPIVersion)(e);if(l&&l.getTime()>=s.API_VERSIONS['2024-01-01'].timestamp&&'object'==typeof u&&u&&'string'==typeof u.code?c=u.code:'object'==typeof u&&u&&'string'==typeof u.error_code&&(c=u.error_code),c){if('weak_password'===c)throw new t.AuthWeakPasswordError(n(u),e.status,(null===(i=u.weak_password)||void 0===i?void 0:i.reasons)||[]);if('session_not_found'===c)throw new t.AuthSessionMissingError}else if('object'==typeof u&&u&&'object'==typeof u.weak_password&&u.weak_password&&Array.isArray(u.weak_password.reasons)&&u.weak_password.reasons.length&&u.weak_password.reasons.reduce((e,s)=>e&&'string'==typeof s,!0))throw new t.AuthWeakPasswordError(n(u),e.status,u.weak_password.reasons);throw new t.AuthApiError(n(u),e.status||500,c)}const u=(e,s,o,t)=>{const n={method:e,headers:(null==s?void 0:s.headers)||{}};return'GET'===e?n:(n.headers=Object.assign({'Content-Type':'application/json;charset=UTF-8'},null==s?void 0:s.headers),n.body=JSON.stringify(t),Object.assign(Object.assign({},n),o))};async function c(e,s,o,a,c,l){const _=u(s,a,c,l);let p;try{p=await e(o,Object.assign({},_))}catch(e){throw console.error(e),new t.AuthRetryableFetchError(n(e),0)}if(p.ok||await i(p),null==a?void 0:a.noResolveJson)return p;try{return await p.json()}catch(e){await i(e)}}function l(e){var s;let t=null;_(e)&&(t=Object.assign({},e),e.expires_at||(t.expires_at=(0,o.expiresAt)(e.expires_in)));return{data:{session:t,user:null!==(s=e.user)&&void 0!==s?s:'string'==typeof(null==e?void 0:e.id)?e:null},error:null}}function _(e){return!!e.access_token&&!!e.refresh_token&&!!e.expires_in}},1064,[1041,1065,1067,1068]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AUTO_REFRESH_TICK_DURATION_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AUTO_REFRESH_TICK_THRESHOLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"EXPIRY_MARGIN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REFRESH_FAILURE_COOLDOWN_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"GOTRUE_URL",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STORAGE_KEY",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"AUDIENCE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DEFAULT_HEADERS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"NETWORK_FAILURE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"API_VERSION_HEADER_NAME",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"API_VERSIONS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"BASE64URL_REGEX",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"JWKS_TTL",{enumerable:!0,get:function(){return A}});var t=r(d[0]);const n=3e4,u=3,o=9e4,c=6e4,E='http://localhost:9999',_='supabase.auth.token',b='',f={'X-Client-Info':`gotrue-js/${t.version}`},R={MAX_RETRIES:10,RETRY_INTERVAL:2},O='X-Supabase-Api-Version',p={'2024-01-01':{timestamp:Date.parse('2024-01-01T00:00:00.0Z'),name:'2024-01-01'}},l=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,A=6e5},1065,[1066]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return t}});const t='2.109.0'},1066,[]); +__d(function(g,r,_i,a,m,_e2,d){"use strict";Object.defineProperty(_e2,'__esModule',{value:!0}),_e2.expiresAt=function(e){return Math.round(Date.now()/1e3)+e},_e2.generateCallbackId=function(){return Symbol('auth-callback')},Object.defineProperty(_e2,"isBrowser",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e2,"supportsLocalStorage",{enumerable:!0,get:function(){return i}}),_e2.parseParametersFromURL=function(e){const t={},n=new URL(e);if(n.hash&&'#'===n.hash[0])try{new URLSearchParams(n.hash.substring(1)).forEach((e,n)=>{t[n]=e})}catch(e){}return n.searchParams.forEach((e,n)=>{t[n]=e}),t},Object.defineProperty(_e2,"resolveFetch",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e2,"looksLikeFetchResponse",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e2,"setItemAsync",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e2,"getItemAsync",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e2,"removeItemAsync",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e2,"Deferred",{enumerable:!0,get:function(){return p}}),_e2.decodeJWT=function(o){const s=o.split('.');if(3!==s.length)throw new t.AuthInvalidJwtError('Invalid JWT structure');for(let n=0;n{setTimeout(()=>t(null),e)})},_e2.retryable=function(e,t){return new Promise((n,o)=>{(async()=>{for(let s=0;s<1/0;s++)try{const o=await e(s);if(!t(s,null,o))return void n(o)}catch(e){if(!t(s,e))return void o(e)}})()})},_e2.generatePKCEVerifier=b,_e2.generatePKCEChallenge=S,_e2.getCodeChallengeAndMethod=async function(e,t,n=!1){const o=b();let s=o;n&&(s+='/recovery');await l(e,`${t}-code-verifier`,s);const i=await S(o);return[i,o===i?'plain':'s256']},_e2.parseResponseAPIVersion=function(t){const n=t.headers.get(e.API_VERSION_HEADER_NAME);if(!n)return null;if(!n.match(P))return null;try{return new Date(`${n}T00:00:00.0Z`)}catch(e){return null}},_e2.validateExp=function(e){if(!e)throw new Error('Missing exp claim');const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error('JWT has expired')},_e2.getAlgorithm=function(e){switch(e){case'RS256':return{name:'RSASSA-PKCS1-v1_5',hash:{name:'SHA-256'}};case'ES256':return{name:'ECDSA',namedCurve:'P-256',hash:{name:'SHA-256'}};default:throw new Error('Invalid alg claim')}},_e2.validateUUID=function(e){if(!A.test(e))throw new Error('@supabase/auth-js: Expected parameter to be UUID but is not')},_e2.assertPasskeyExperimentalEnabled=function(e){if(!e.passkey)throw new Error('@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).')},_e2.userNotAvailableProxy=function(){return new Proxy({},{get:(e,t)=>{if('__isUserNotAvailableProxy'===t)return!0;if('symbol'==typeof t){const e=t.toString();if('Symbol(Symbol.toPrimitive)'===e||'Symbol(Symbol.toStringTag)'===e||'Symbol(util.inspect.custom)'===e)return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})},_e2.insecureUserWarningProxy=function(e,t){return new Proxy(e,{get:(e,n,o)=>{if('__isInsecureUserWarningProxy'===n)return!0;if('symbol'==typeof n){const t=n.toString();if('Symbol(Symbol.toPrimitive)'===t||'Symbol(Symbol.toStringTag)'===t||'Symbol(util.inspect.custom)'===t||'Symbol(nodejs.util.inspect.custom)'===t)return Reflect.get(e,n,o)}return t.value||'string'!=typeof n||(console.warn('Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.'),t.value=!0),Reflect.get(e,n,o)}})},_e2.deepClone=function(e){return JSON.parse(JSON.stringify(e))};var e=r(d[0]),t=r(d[1]),n=r(d[2]);const o=()=>'undefined'!=typeof window&&'undefined'!=typeof document,s={tested:!1,writable:!1},i=()=>{if(!o())return!1;try{if('object'!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(s.tested)return s.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),s.tested=!0,s.writable=!0}catch(e){s.tested=!0,s.writable=!1}return s.writable};const u=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),c=e=>'object'==typeof e&&null!==e&&'status'in e&&'ok'in e&&'json'in e&&'function'==typeof e.json,l=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},f=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch(e){return null}},h=async(e,t)=>{await e.removeItem(t)};class p{constructor(){this.promise=new p.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function y(e){return('0'+e.toString(16)).substr(-2)}function b(){const e=new Uint32Array(56);if('undefined'==typeof crypto){const e='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~',t=e.length;let n='';for(let o=0;o<56;o++)n+=e.charAt(Math.floor(Math.random()*t));return n}return crypto.getRandomValues(e),Array.from(e,y).join('')}async function w(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest('SHA-256',t),o=new Uint8Array(n);return Array.from(o).map(e=>String.fromCharCode(e)).join('')}async function S(e){if(!('undefined'!=typeof crypto&&void 0!==crypto.subtle&&'undefined'!=typeof TextEncoder))return console.warn('WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256.'),e;const t=await w(e);return btoa(t).replace(/\+/g,'-').replace(/\//g,'_').replace(/=+$/,'')}p.promiseConstructor=Promise;const P=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;const A=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/},1067,[1065,1068,1069]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AuthError",{enumerable:!0,get:function(){return t}}),e.isAuthError=s,Object.defineProperty(e,"AuthApiError",{enumerable:!0,get:function(){return n}}),e.isAuthApiError=function(t){return s(t)&&'AuthApiError'===t.name},Object.defineProperty(e,"AuthUnknownError",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CustomAuthError",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AuthSessionMissingError",{enumerable:!0,get:function(){return c}}),e.isAuthSessionMissingError=function(t){return s(t)&&'AuthSessionMissingError'===t.name},Object.defineProperty(e,"AuthInvalidTokenResponseError",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"AuthInvalidCredentialsError",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AuthImplicitGrantRedirectError",{enumerable:!0,get:function(){return f}}),e.isAuthImplicitGrantRedirectError=function(t){return s(t)&&'AuthImplicitGrantRedirectError'===t.name},Object.defineProperty(e,"AuthPKCEGrantCodeExchangeError",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"AuthPKCECodeVerifierMissingError",{enumerable:!0,get:function(){return A}}),e.isAuthPKCECodeVerifierMissingError=function(t){return s(t)&&'AuthPKCECodeVerifierMissingError'===t.name},Object.defineProperty(e,"AuthRetryableFetchError",{enumerable:!0,get:function(){return p}}),e.isAuthRetryableFetchError=function(t){return s(t)&&'AuthRetryableFetchError'===t.name},Object.defineProperty(e,"AuthRefreshDiscardedError",{enumerable:!0,get:function(){return b}}),e.isAuthRefreshDiscardedError=function(t){return s(t)&&'AuthRefreshDiscardedError'===t.name},Object.defineProperty(e,"AuthWeakPasswordError",{enumerable:!0,get:function(){return O}}),e.isAuthWeakPasswordError=function(t){return s(t)&&'AuthWeakPasswordError'===t.name},Object.defineProperty(e,"AuthInvalidJwtError",{enumerable:!0,get:function(){return P}});class t extends Error{constructor(t,s,n){super(t),this.__isAuthError=!0,this.name='AuthError',this.status=s,this.code=n}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function s(t){return'object'==typeof t&&null!==t&&'__isAuthError'in t}class n extends t{constructor(t,s,n){super(t,s,n),this.name='AuthApiError',this.status=s,this.code=n}}class o extends t{constructor(t,s){super(t),this.name='AuthUnknownError',this.originalError=s}}class u extends t{constructor(t,s,n,o){super(t,n,o),this.name=s,this.status=n}}class c extends u{constructor(){super('Auth session missing!','AuthSessionMissingError',400,void 0)}}class h extends u{constructor(){super('Auth session or user missing','AuthInvalidTokenResponseError',500,void 0)}}class l extends u{constructor(t){super(t,'AuthInvalidCredentialsError',400,void 0)}}class f extends u{constructor(t,s=null){super(t,'AuthImplicitGrantRedirectError',500,void 0),this.details=null,this.details=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class E extends u{constructor(t,s=null){super(t,'AuthPKCEGrantCodeExchangeError',500,void 0),this.details=null,this.details=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class A extends u{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.",'AuthPKCECodeVerifierMissingError',400,'pkce_code_verifier_not_found')}}class p extends u{constructor(t,s){super(t,'AuthRetryableFetchError',s,void 0)}}class b extends u{constructor(t="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(t,'AuthRefreshDiscardedError',409,void 0)}}class O extends u{constructor(t,s,n){super(t,'AuthWeakPasswordError',s,'weak_password'),this.reasons=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class P extends u{constructor(t){super(t,'AuthInvalidJwtError',400,'invalid_jwt')}}},1068,[]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.byteToBase64URL=o,e.byteFromBase64URL=i,e.stringToBase64URL=function(t){const u=[],n=t=>{u.push(t)},i={queue:0,queuedBits:0};return f(t,t=>{o(t,i,n)}),o(null,i,n),u.join('')},e.stringFromBase64URL=function(t){const u=[],n=t=>{u.push(String.fromCodePoint(t))},o={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},f=t=>{c(t,o,n)};for(let u=0;u{u.push(t)};for(let u=0;uu.push(t)),new Uint8Array(u)},e.bytesToBase64URL=function(t){const u=[],n={queue:0,queuedBits:0},i=t=>{u.push(t)};return t.forEach(t=>o(t,n,i)),o(null,n,i),u.join('')};const t='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'.split(''),u=' \t\n\r='.split(''),n=(()=>{const n=new Array(128);for(let t=0;t=6;){const u=n.queue>>n.queuedBits-6&63;o(t[u]),n.queuedBits-=6}else if(n.queuedBits>0)for(n.queue=n.queue<<6-n.queuedBits,n.queuedBits=6;n.queuedBits>=6;){const u=n.queue>>n.queuedBits-6&63;o(t[u]),n.queuedBits-=6}}function i(t,u,o){const i=n[t];if(!(i>-1)){if(-2===i)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}for(u.queue=u.queue<<6|i,u.queuedBits+=6;u.queuedBits>=8;)o(u.queue>>u.queuedBits-8&255),u.queuedBits-=8}function s(t,u){if(!(t<=127)){if(t<=2047)return u(192|t>>6),void u(128|63&t);if(t<=65535)return u(224|t>>12),u(128|t>>6&63),void u(128|63&t);if(t<=1114111)return u(240|t>>18),u(128|t>>12&63),u(128|t>>6&63),void u(128|63&t);throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}u(t)}function f(t,u){for(let n=0;n55295&&o<=56319){const u=1024*(o-55296)&65535;o=65536+(t.charCodeAt(n+1)-56320&65535|u),n+=1}s(o,u)}}function c(t,u,n){if(0===u.utf8seq){if(t<=127)return void n(t);for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){u.utf8seq=n;break}if(2===u.utf8seq)u.codepoint=31&t;else if(3===u.utf8seq)u.codepoint=15&t;else{if(4!==u.utf8seq)throw new Error('Invalid UTF-8 sequence');u.codepoint=7&t}u.utf8seq-=1}else if(u.utf8seq>0){if(t<=127)throw new Error('Invalid UTF-8 sequence');u.codepoint=u.codepoint<<6|63&t,u.utf8seq-=1,0===u.utf8seq&&n(u.codepoint)}}},1069,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SIGN_OUT_SCOPES",{enumerable:!0,get:function(){return t}});const t=['global','local','others']},1070,[]); +__d(function(e,t,s,r,i,n,a){"use strict";Object.defineProperty(n,'__esModule',{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return A}});var o,l=t(a[0]),u=(o=l)&&o.__esModule?o:{default:o},h=t(a[1]),c=t(a[2]),d=t(a[3]),_=t(a[4]),g=t(a[5]),w=t(a[6]),y=t(a[7]),f=t(a[8]),p=t(a[9]),v=t(a[10]),b=t(a[11]);(0,y.polyfillGlobalThis)();const k={url:h.GOTRUE_URL,storageKey:h.STORAGE_KEY,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:h.DEFAULT_HEADERS,flowType:'implicit',debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},m={};class R{get jwks(){var e,t;return null!==(t=null===(e=m[this.storageKey])||void 0===e?void 0:e.jwks)&&void 0!==t?t:{keys:[]}}set jwks(e){m[this.storageKey]=Object.assign(Object.assign({},m[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!==(t=null===(e=m[this.storageKey])||void 0===e?void 0:e.cachedAt)&&void 0!==t?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){m[this.storageKey]=Object.assign(Object.assign({},m[this.storageKey]),{cachedAt:e})}constructor(e){var t,s,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.lastRefreshFailure=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},k),e);if(this.storageKey=i.storageKey,this.instanceID=null!==(t=R.nextInstanceID[this.storageKey])&&void 0!==t?t:0,R.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,'function'==typeof i.debug&&(this.logger=i.debug),this.instanceID>0&&(0,_.isBrowser)()){const e=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(e),this.logDebugMessages&&console.trace(e)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.experimental=null!==(s=i.experimental)&&void 0!==s?s:{},this.admin=new u.default({url:i.url,headers:i.headers,fetch:i.fetch,experimental:this.experimental}),this.url=i.url,this.headers=i.headers,this.fetch=(0,_.resolveFetch)(i.fetch),this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,this.lockAcquireTimeout=i.lockAcquireTimeout,null!=i.lock&&(this.lock=i.lock),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new b.WebAuthnApi(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:(0,_.supportsLocalStorage)()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=(0,g.memoryLocalStorageAdapter)(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=(0,g.memoryLocalStorageAdapter)(this.memoryStorage)),(0,_.isBrowser)()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error('Failed to create a new BroadcastChannel, multi-tab state changes will not be available',e)}null===(r=this.broadcastChannel)||void 0===r||r.addEventListener('message',async e=>{this._debug('received broadcast notification from other tab or client',e),'TOKEN_REFRESHED'!==e.data.event&&'SIGNED_IN'!==e.data.event||(this.lastRefreshFailure=null);try{await this._notifyAllSubscribers(e.data.event,e.data.session,!1)}catch(e){this._debug('#broadcastChannel','error',e)}})}i.skipAutoInitialize||this.initialize().catch(e=>{this._debug('#initialize()','error',e)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${f.version}) ${(new Date).toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())()),await this.initializePromise}async _initialize(){var e;try{let t={},s='none';if((0,_.isBrowser)()&&(t=(0,_.parseParametersFromURL)(window.location.href),this._isImplicitGrantCallback(t)?s='implicit':await this._isPKCECallback(t)&&(s='pkce')),(0,_.isBrowser)()&&this.detectSessionInUrl&&'none'!==s){const{data:r,error:i}=await this._getSessionFromURL(t,s);if(i){if(this._debug('#_initialize()','error detecting session from URL',i),(0,c.isAuthImplicitGrantRedirectError)(i)){const t=null===(e=i.details)||void 0===e?void 0:e.code;if('identity_already_exists'===t||'identity_not_found'===t||'single_identity_not_deletable'===t)return{error:i}}return{error:i}}const{session:n,redirectType:a}=r;return this._debug('#_initialize()','detected session in URL',n,'redirect type',a),await this._saveSession(n),setTimeout(async()=>{'recovery'===a?await this._notifyAllSubscribers('PASSWORD_RECOVERY',n):await this._notifyAllSubscribers('SIGNED_IN',n)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){return(0,c.isAuthError)(e)?this._returnResult({error:e}):this._returnResult({error:new c.AuthUnknownError('Unexpected error during initialization',e)})}finally{await this._handleVisibilityChange(),this._debug('#_initialize()','end')}}async signInAnonymously(e){var t,s,r;try{const i=await(0,d._request)(this.fetch,'POST',`${this.url}/signup`,{headers:this.headers,body:{data:null!==(s=null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.data)&&void 0!==s?s:{},gotrue_meta_security:{captcha_token:null===(r=null==e?void 0:e.options)||void 0===r?void 0:r.captchaToken}},xform:d._sessionResponse}),{data:n,error:a}=i;if(a||!n)return this._returnResult({data:{user:null,session:null},error:a});const o=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers('SIGNED_IN',o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signUp(e){var t,s,r;try{let i;if('email'in e){const{email:s,password:r,options:n}=e;let a=null,o=null;'pkce'===this.flowType&&([a,o]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey)),i=await(0,d._request)(this.fetch,'POST',`${this.url}/signup`,{headers:this.headers,redirectTo:null==n?void 0:n.emailRedirectTo,body:{email:s,password:r,data:null!==(t=null==n?void 0:n.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken},code_challenge:a,code_challenge_method:o},xform:d._sessionResponse})}else{if(!('phone'in e))throw new c.AuthInvalidCredentialsError('You must provide either an email or phone number and a password');{const{phone:t,password:n,options:a}=e;i=await(0,d._request)(this.fetch,'POST',`${this.url}/signup`,{headers:this.headers,body:{phone:t,password:n,data:null!==(s=null==a?void 0:a.data)&&void 0!==s?s:{},channel:null!==(r=null==a?void 0:a.channel)&&void 0!==r?r:'sms',gotrue_meta_security:{captcha_token:null==a?void 0:a.captchaToken}},xform:d._sessionResponse})}}const{data:n,error:a}=i;if(a||!n)return await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const o=n.session,l=n.user;return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers('SIGNED_IN',o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithPassword(e){try{let t;if('email'in e){const{email:s,password:r,options:i}=e;t=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:s,password:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:d._sessionResponsePassword})}else{if(!('phone'in e))throw new c.AuthInvalidCredentialsError('You must provide either an email or phone number and a password');{const{phone:s,password:r,options:i}=e;t=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:s,password:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:d._sessionResponsePassword})}}const{data:s,error:r}=t;if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!s||!s.session||!s.user){const e=new c.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers('SIGNED_IN',s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:r})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOAuth(e){var t,s,r,i;return await this._handleProviderSignIn(e.provider,{redirectTo:null===(t=e.options)||void 0===t?void 0:t.redirectTo,scopes:null===(s=e.options)||void 0===s?void 0:s.scopes,queryParams:null===(r=e.options)||void 0===r?void 0:r.queryParams,skipBrowserRedirect:null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,null!=this.lock?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e)):this._exchangeCodeForSession(e)}async signInWithWeb3(e){const{chain:t}=e;switch(t){case'ethereum':return await this.signInWithEthereum(e);case'solana':return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${t}"`)}}async signInWithEthereum(e){var t,s,r,i,n,a,o,l,u,h,g;let w,y;if('message'in e)w=e.message,y=e.signature;else{const{chain:h,wallet:c,statement:d,options:g}=e;let f;if((0,_.isBrowser)())if('object'==typeof c)f=c;else{const e=window;if(!('ethereum'in e)||'object'!=typeof e.ethereum||!('request'in e.ethereum)||'function'!=typeof e.ethereum.request)throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.");f=e.ethereum}else{if('object'!=typeof c||!(null==g?void 0:g.url))throw new Error('@supabase/auth-js: Both wallet and url must be specified in non-browser environments.');f=c}const p=new URL(null!==(t=null==g?void 0:g.url)&&void 0!==t?t:window.location.href),b=await f.request({method:'eth_requestAccounts'}).then(e=>e).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!b||0===b.length)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const k=(0,v.getAddress)(b[0]);let m=null===(s=null==g?void 0:g.signInWithEthereum)||void 0===s?void 0:s.chainId;if(!m){const e=await f.request({method:'eth_chainId'});m=(0,v.fromHex)(e)}const R={domain:p.host,address:k,statement:d,uri:p.href,version:'1',chainId:m,nonce:null===(r=null==g?void 0:g.signInWithEthereum)||void 0===r?void 0:r.nonce,issuedAt:null!==(n=null===(i=null==g?void 0:g.signInWithEthereum)||void 0===i?void 0:i.issuedAt)&&void 0!==n?n:new Date,expirationTime:null===(a=null==g?void 0:g.signInWithEthereum)||void 0===a?void 0:a.expirationTime,notBefore:null===(o=null==g?void 0:g.signInWithEthereum)||void 0===o?void 0:o.notBefore,requestId:null===(l=null==g?void 0:g.signInWithEthereum)||void 0===l?void 0:l.requestId,resources:null===(u=null==g?void 0:g.signInWithEthereum)||void 0===u?void 0:u.resources};w=(0,v.createSiweMessage)(R),y=await f.request({method:'personal_sign',params:[(0,v.toHex)(w),k]})}try{const{data:t,error:s}=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:'ethereum',message:w,signature:y},(null===(h=e.options)||void 0===h?void 0:h.captchaToken)?{gotrue_meta_security:{captcha_token:null===(g=e.options)||void 0===g?void 0:g.captchaToken}}:null),xform:d._sessionResponse});if(s)throw s;if(!t||!t.session||!t.user){const e=new c.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers('SIGNED_IN',t.session)),this._returnResult({data:Object.assign({},t),error:s})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSolana(e){var t,s,r,i,n,a,o,l,u,h,g,w;let y,f;if('message'in e)y=e.message,f=e.signature;else{const{chain:c,wallet:d,statement:g,options:w}=e;let p;if((0,_.isBrowser)())if('object'==typeof d)p=d;else{const e=window;if(!('solana'in e)||'object'!=typeof e.solana||!('signIn'in e.solana&&'function'==typeof e.solana.signIn||'signMessage'in e.solana&&'function'==typeof e.solana.signMessage))throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.");p=e.solana}else{if('object'!=typeof d||!(null==w?void 0:w.url))throw new Error('@supabase/auth-js: Both wallet and url must be specified in non-browser environments.');p=d}const v=new URL(null!==(t=null==w?void 0:w.url)&&void 0!==t?t:window.location.href);if('signIn'in p&&p.signIn){const e=await p.signIn(Object.assign(Object.assign(Object.assign({issuedAt:(new Date).toISOString()},null==w?void 0:w.signInWithSolana),{version:'1',domain:v.host,uri:v.href}),g?{statement:g}:null));let t;if(Array.isArray(e)&&e[0]&&'object'==typeof e[0])t=e[0];else{if(!(e&&'object'==typeof e&&'signedMessage'in e&&'signature'in e))throw new Error('@supabase/auth-js: Wallet method signIn() returned unrecognized value');t=e}if(!('signedMessage'in t&&'signature'in t&&('string'==typeof t.signedMessage||t.signedMessage instanceof Uint8Array)&&t.signature instanceof Uint8Array))throw new Error('@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields');y='string'==typeof t.signedMessage?t.signedMessage:(new TextDecoder).decode(t.signedMessage),f=t.signature}else{if(!('signMessage'in p&&'function'==typeof p.signMessage&&'publicKey'in p&&'object'==typeof p&&p.publicKey&&'toBase58'in p.publicKey&&'function'==typeof p.publicKey.toBase58))throw new Error('@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API');y=[`${v.host} wants you to sign in with your Solana account:`,p.publicKey.toBase58(),...g?['',g,'']:[''],'Version: 1',`URI: ${v.href}`,`Issued At: ${null!==(r=null===(s=null==w?void 0:w.signInWithSolana)||void 0===s?void 0:s.issuedAt)&&void 0!==r?r:(new Date).toISOString()}`,...(null===(i=null==w?void 0:w.signInWithSolana)||void 0===i?void 0:i.notBefore)?[`Not Before: ${w.signInWithSolana.notBefore}`]:[],...(null===(n=null==w?void 0:w.signInWithSolana)||void 0===n?void 0:n.expirationTime)?[`Expiration Time: ${w.signInWithSolana.expirationTime}`]:[],...(null===(a=null==w?void 0:w.signInWithSolana)||void 0===a?void 0:a.chainId)?[`Chain ID: ${w.signInWithSolana.chainId}`]:[],...(null===(o=null==w?void 0:w.signInWithSolana)||void 0===o?void 0:o.nonce)?[`Nonce: ${w.signInWithSolana.nonce}`]:[],...(null===(l=null==w?void 0:w.signInWithSolana)||void 0===l?void 0:l.requestId)?[`Request ID: ${w.signInWithSolana.requestId}`]:[],...(null===(h=null===(u=null==w?void 0:w.signInWithSolana)||void 0===u?void 0:u.resources)||void 0===h?void 0:h.length)?['Resources',...w.signInWithSolana.resources.map(e=>`- ${e}`)]:[]].join('\n');const e=await p.signMessage((new TextEncoder).encode(y),'utf8');if(!(e&&e instanceof Uint8Array))throw new Error('@supabase/auth-js: Wallet signMessage() API returned an recognized value');f=e}}try{const{data:t,error:s}=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:'solana',message:y,signature:(0,p.bytesToBase64URL)(f)},(null===(g=e.options)||void 0===g?void 0:g.captchaToken)?{gotrue_meta_security:{captcha_token:null===(w=e.options)||void 0===w?void 0:w.captchaToken}}:null),xform:d._sessionResponse});if(s)throw s;if(!t||!t.session||!t.user){const e=new c.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers('SIGNED_IN',t.session)),this._returnResult({data:Object.assign({},t),error:s})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _exchangeCodeForSession(e){const t=await(0,_.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`),[s,r]=(null!=t?t:'').split('/');try{if(!s&&'pkce'===this.flowType)throw new c.AuthPKCECodeVerifierMissingError;const{data:t,error:i}=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:s},xform:d._sessionResponse});if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!t||!t.session||!t.user){const e=new c.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers('recovery'===r?'PASSWORD_RECOVERY':'SIGNED_IN',t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!=r?r:null}),error:i})}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null,redirectType:null},error:e});throw e}}async signInWithIdToken(e){try{const{options:t,provider:s,token:r,access_token:i,nonce:n}=e,a=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:r,access_token:i,nonce:n,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:d._sessionResponse}),{data:o,error:l}=a;if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!o||!o.session||!o.user){const e=new c.AuthInvalidTokenResponseError;return this._returnResult({data:{user:null,session:null},error:e})}return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers('SIGNED_IN',o.session)),this._returnResult({data:o,error:l})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithOtp(e){var t,s,r,i,n;try{if('email'in e){const{email:r,options:i}=e;let n=null,a=null;'pkce'===this.flowType&&([n,a]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey));const{error:o}=await(0,d._request)(this.fetch,'POST',`${this.url}/otp`,{headers:this.headers,body:{email:r,data:null!==(t=null==i?void 0:i.data)&&void 0!==t?t:{},create_user:null===(s=null==i?void 0:i.shouldCreateUser)||void 0===s||s,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:n,code_challenge_method:a},redirectTo:null==i?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}if('phone'in e){const{phone:t,options:s}=e,{data:a,error:o}=await(0,d._request)(this.fetch,'POST',`${this.url}/otp`,{headers:this.headers,body:{phone:t,data:null!==(r=null==s?void 0:s.data)&&void 0!==r?r:{},create_user:null===(i=null==s?void 0:s.shouldCreateUser)||void 0===i||i,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken},channel:null!==(n=null==s?void 0:s.channel)&&void 0!==n?n:'sms'}});return this._returnResult({data:{user:null,session:null,messageId:null==a?void 0:a.message_id},error:o})}throw new c.AuthInvalidCredentialsError('You must provide either an email or phone number.')}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async verifyOtp(e){var t,s;try{let r,i;'options'in e&&(r=null===(t=e.options)||void 0===t?void 0:t.redirectTo,i=null===(s=e.options)||void 0===s?void 0:s.captchaToken);const{data:n,error:a}=await(0,d._request)(this.fetch,'POST',`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:r,xform:d._sessionResponse});if(a)throw a;if(!n){throw new Error('An error occurred on token verification.')}const o=n.session,l=n.user;return(null==o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers('recovery'==e.type?'PASSWORD_RECOVERY':'SIGNED_IN',o)),this._returnResult({data:{user:l,session:o},error:null})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async signInWithSSO(e){var t,s,r,i,n;try{let a=null,o=null;'pkce'===this.flowType&&([a,o]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey));const l=await(0,d._request)(this.fetch,'POST',`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},'providerId'in e?{provider_id:e.providerId}:null),'domain'in e?{domain:e.domain}:null),{redirect_to:null!==(s=null===(t=e.options)||void 0===t?void 0:t.redirectTo)&&void 0!==s?s:void 0}),(null===(r=null==e?void 0:e.options)||void 0===r?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:d._ssoResponse});return(null===(i=l.data)||void 0===i?void 0:i.url)&&(0,_.isBrowser)()&&!(null===(n=e.options)||void 0===n?void 0:n.skipBrowserRedirect)&&window.location.assign(l.data.url),this._returnResult(l)}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async reauthenticate(){return await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:t},error:s}=e;if(s)throw s;if(!t)throw new c.AuthSessionMissingError;const{error:r}=await(0,d._request)(this.fetch,'GET',`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return this._returnResult({data:{user:null,session:null},error:r})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const t=`${this.url}/resend`;if('email'in e){const{email:s,type:r,options:i}=e;let n=null,a=null;'pkce'===this.flowType&&([n,a]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey));const{error:o}=await(0,d._request)(this.fetch,'POST',t,{headers:this.headers,body:{email:s,type:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken},code_challenge:n,code_challenge_method:a},redirectTo:null==i?void 0:i.emailRedirectTo});return o&&await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:o})}if('phone'in e){const{phone:s,type:r,options:i}=e,{data:n,error:a}=await(0,d._request)(this.fetch,'POST',t,{headers:this.headers,body:{phone:s,type:r,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null==n?void 0:n.message_id},error:a})}throw new c.AuthInvalidCredentialsError('You must provide either an email or phone number and a type')}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async getSession(){return await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,t){this._debug('#_acquireLock','begin',e);try{if(this.lockAcquired){const e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch(e){}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug('#_acquireLock','lock acquired for storage key',this.storageKey);try{this.lockAcquired=!0;const e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){const e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug('#_acquireLock','lock released for storage key',this.storageKey),this.lockAcquired=!1}})}finally{this._debug('#_acquireLock','end')}}async _useSession(e){this._debug('#_useSession','begin');try{const t=await this.__loadSession();return await e(t)}finally{this._debug('#_useSession','end')}}async __loadSession(){this._debug('#__loadSession()','begin'),null==this.lock||this.lockAcquired||this._debug('#__loadSession()','used outside of an acquired lock!',(new Error).stack);try{let e=null;const t=await(0,_.getItemAsync)(this.storage,this.storageKey);if(this._debug('#getSession()','session from storage',t),null!==t&&(this._isValidSession(t)?e=t:(this._debug('#getSession()','session from storage is not valid'),await this._removeSession())),!e)return{data:{session:null},error:null};const s=!!e.expires_at&&1e3*e.expires_at-Date.now()Date.now())){const t=await(0,_.getItemAsync)(this.storage,this.storageKey);if(t&&t.refresh_token===e.refresh_token)return this._returnResult({data:{session:e},error:null})}return this._returnResult({data:{session:null},error:i})}return this._returnResult({data:{session:r},error:null})}finally{this._debug('#__loadSession()','end')}}async getUser(e){if(e)return await this._getUser(e);let t;return await this.initializePromise,t=null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):await this._getUser(),t.data.user&&(this.suppressGetSessionWarning=!0),t}async _getUser(e){try{return e?await(0,d._request)(this.fetch,'GET',`${this.url}/user`,{headers:this.headers,jwt:e,xform:d._userResponse}):await this._useSession(async e=>{var t,s,r;const{data:i,error:n}=e;if(n)throw n;return(null===(t=i.session)||void 0===t?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await(0,d._request)(this.fetch,'GET',`${this.url}/user`,{headers:this.headers,jwt:null!==(r=null===(s=i.session)||void 0===s?void 0:s.access_token)&&void 0!==r?r:void 0,xform:d._userResponse}):{data:{user:null},error:new c.AuthSessionMissingError}})}catch(e){if((0,c.isAuthError)(e))return(0,c.isAuthSessionMissingError)(e)&&(await this._removeSession(),await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:e});throw e}}async updateUser(e,t={}){return await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,t)):await this._updateUser(e,t)}async _updateUser(e,t={}){try{return await this._useSession(async s=>{const{data:r,error:i}=s;if(i)throw i;if(!r.session)throw new c.AuthSessionMissingError;const n=r.session;let a=null,o=null;'pkce'===this.flowType&&null!=e.email&&([a,o]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey));const{data:l,error:u}=await(0,d._request)(this.fetch,'PUT',`${this.url}/user`,{headers:this.headers,redirectTo:null==t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:o}),jwt:n.access_token,xform:d._userResponse});if(u)throw u;return n.user=l.user,await this._saveSession(n),await this._notifyAllSubscribers('USER_UPDATED',n),this._returnResult({data:{user:n.user},error:null})})}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:{user:null},error:e});throw e}}async setSession(e){return await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new c.AuthSessionMissingError;const t=Date.now()/1e3;let s=t,r=!0,i=null;const{payload:n}=(0,_.decodeJWT)(e.access_token);if(n.exp&&(s=n.exp,r=s<=t),r){const{data:t,error:s}=await this._callRefreshToken(e.refresh_token);if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!t)return{data:{user:null,session:null},error:null};i=t}else{const{data:r,error:n}=await this._getUser(e.access_token);if(n)return this._returnResult({data:{user:null,session:null},error:n});i={access_token:e.access_token,refresh_token:e.refresh_token,user:r.user,token_type:'bearer',expires_in:s-t,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers('SIGNED_IN',i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{session:null,user:null},error:e});throw e}}async refreshSession(e){return await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async t=>{var s;if(!e){const{data:r,error:i}=t;if(i)throw i;e=null!==(s=r.session)&&void 0!==s?s:void 0}if(!(null==e?void 0:e.refresh_token))throw new c.AuthSessionMissingError;const{data:r,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):r?this._returnResult({data:{user:r.user,session:r},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async _getSessionFromURL(e,t){var s;try{if(!(0,_.isBrowser)())throw new c.AuthImplicitGrantRedirectError('No browser detected.');if(e.error||e.error_description||e.error_code)throw new c.AuthImplicitGrantRedirectError(e.error_description||'Error in URL with unspecified error_description',{error:e.error||'unspecified_error',code:e.error_code||'unspecified_code'});switch(t){case'implicit':if('pkce'===this.flowType)throw new c.AuthPKCEGrantCodeExchangeError('Not a valid PKCE flow url.');break;case'pkce':if('implicit'===this.flowType)throw new c.AuthImplicitGrantRedirectError('Not a valid implicit grant flow url.')}if('pkce'===t){if(this._debug('#_initialize()','begin','is PKCE flow',!0),!e.code)throw new c.AuthPKCEGrantCodeExchangeError('No code detected.');const{data:t,error:r}=await this._exchangeCodeForSession(e.code);if(r)throw r;const i=new URL(window.location.href);return i.searchParams.delete('code'),window.history.replaceState(window.history.state,'',i.toString()),{data:{session:t.session,redirectType:null!==(s=t.redirectType)&&void 0!==s?s:null},error:null}}const{provider_token:r,provider_refresh_token:i,access_token:n,refresh_token:a,expires_in:o,expires_at:l,token_type:u}=e;if(!(n&&o&&a&&u))throw new c.AuthImplicitGrantRedirectError('No session defined in URL');const d=Math.round(Date.now()/1e3),g=parseInt(o);let w=d+g;l&&(w=parseInt(l));const y=w-d;1e3*y<=h.AUTO_REFRESH_TICK_DURATION_MS&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${g}s`);const f=w-g;d-f>=120?console.warn('@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale',f,w,d):d-f<0&&console.warn('@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew',f,w,d);const{data:p,error:v}=await this._getUser(n);if(v)throw v;const b={provider_token:r,provider_refresh_token:i,access_token:n,expires_in:g,expires_at:w,refresh_token:a,token_type:u,user:p.user};return window.location.hash='',this._debug('#_getSessionFromURL()','clearing window.location.hash'),this._returnResult({data:{session:b,redirectType:e.type},error:null})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:{session:null,redirectType:null},error:e});throw e}}_isImplicitGrantCallback(e){return'function'==typeof this.detectSessionInUrl?this.detectSessionInUrl(new URL(window.location.href),e):Boolean(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){const t=await(0,_.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return!(!e.code||!t)}async signOut(e={scope:'global'}){return await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:'global'}){return await this._useSession(async t=>{var s;const{data:r,error:i}=t;if(i&&!(0,c.isAuthSessionMissingError)(i))return this._returnResult({error:i});const n=null===(s=r.session)||void 0===s?void 0:s.access_token;if(n){const{error:t}=await this.admin.signOut(n,e);if(t&&(!(0,c.isAuthApiError)(t)||404!==t.status&&401!==t.status&&403!==t.status)&&!(0,c.isAuthSessionMissingError)(t))return this._returnResult({error:t})}return'others'!==e&&(await this._removeSession(),await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const t=(0,_.generateCallbackId)(),s={id:t,callback:e,unsubscribe:()=>{this._debug('#unsubscribe()','state change callback with id removed',t),this.stateChangeEmitters.delete(t)}};return this._debug('#onAuthStateChange()','registered callback with id',t),this.stateChangeEmitters.set(t,s),(async()=>{await this.initializePromise,null!=this.lock?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(t)}):await this._emitInitialSession(t)})(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async t=>{var s,r;try{const{data:{session:r},error:i}=t;if(i)throw i;await(null===(s=this.stateChangeEmitters.get(e))||void 0===s?void 0:s.callback('INITIAL_SESSION',r)),this._debug('INITIAL_SESSION','callback id',e,'session',r)}catch(t){await(null===(r=this.stateChangeEmitters.get(e))||void 0===r?void 0:r.callback('INITIAL_SESSION',null)),this._debug('INITIAL_SESSION','callback id',e,'error',t),(0,c.isAuthSessionMissingError)(t)?console.warn(t):console.error(t)}})}async resetPasswordForEmail(e,t={}){let s=null,r=null;'pkce'===this.flowType&&([s,r]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey,!0));try{return await(0,d._request)(this.fetch,'POST',`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:r,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async getUserIdentities(){var e;try{const{data:t,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:null!==(e=t.user.identities)&&void 0!==e?e:[]},error:null})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async linkIdentity(e){return'token'in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var t;try{const{data:s,error:r}=await this._useSession(async t=>{var s,r,i,n,a;const{data:o,error:l}=t;if(l)throw l;const u=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:null===(s=e.options)||void 0===s?void 0:s.redirectTo,scopes:null===(r=e.options)||void 0===r?void 0:r.scopes,queryParams:null===(i=e.options)||void 0===i?void 0:i.queryParams,skipBrowserRedirect:!0});return await(0,d._request)(this.fetch,'GET',u,{headers:this.headers,jwt:null!==(a=null===(n=o.session)||void 0===n?void 0:n.access_token)&&void 0!==a?a:void 0})});if(r)throw r;return(0,_.isBrowser)()&&!(null===(t=e.options)||void 0===t?void 0:t.skipBrowserRedirect)&&window.location.assign(null==s?void 0:s.url),this._returnResult({data:{provider:e.provider,url:null==s?void 0:s.url},error:null})}catch(t){if((0,c.isAuthError)(t))return this._returnResult({data:{provider:e.provider,url:null},error:t});throw t}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var s;try{const{error:r,data:{session:i}}=t;if(r)throw r;const{options:n,provider:a,token:o,access_token:l,nonce:u}=e,h=await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:null!==(s=null==i?void 0:i.access_token)&&void 0!==s?s:void 0,body:{provider:a,id_token:o,access_token:l,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:null==n?void 0:n.captchaToken}},xform:d._sessionResponse}),{data:_,error:g}=h;return g?this._returnResult({data:{user:null,session:null},error:g}):_&&_.session&&_.user?(_.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers('USER_UPDATED',_.session)),this._returnResult({data:_,error:g})):this._returnResult({data:{user:null,session:null},error:new c.AuthInvalidTokenResponseError})}catch(e){if(await(0,_.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),(0,c.isAuthError)(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var s,r;const{data:i,error:n}=t;if(n)throw n;return await(0,d._request)(this.fetch,'DELETE',`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:null!==(r=null===(s=i.session)||void 0===s?void 0:s.access_token)&&void 0!==r?r:void 0})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _refreshAccessToken(e){const t="#_refreshAccessToken()";this._debug(t,'begin');try{const s=Date.now();return await(0,_.retryable)(async s=>(s>0&&await(0,_.sleep)(200*Math.pow(2,s-1)),this._debug(t,'refreshing attempt',s),await(0,d._request)(this.fetch,'POST',`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:d._sessionResponse})),(e,t)=>{const r=200*Math.pow(2,e);return t&&(0,c.isAuthRetryableFetchError)(t)&&Date.now()+r-sDate.now())?this._debug(r,'proactive refresh failed, access token still valid \u2014 preserving session'):await this._removeSession()}return this.lastRefreshFailure={refreshToken:e,result:s,expiresAt:Date.now()+h.REFRESH_FAILURE_COOLDOWN_MS},null===(t=this.refreshingDeferred)||void 0===t||t.resolve(s),s}throw null===(s=this.refreshingDeferred)||void 0===s||s.reject(i),i}finally{this.refreshingDeferred=null,this._debug(r,'end')}}async _notifyAllSubscribers(e,t,s=!0){const r=`#_notifyAllSubscribers(${e})`;this._debug(r,'begin',t,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:t});const r=[],i=Array.from(this.stateChangeEmitters.values()).map(async s=>{try{await s.callback(e,t)}catch(e){r.push(e)}});if(await Promise.all(i),r.length>0){for(let e=0;ethis._autoRefreshTokenTick(),h.AUTO_REFRESH_TICK_DURATION_MS);this.autoRefreshTicker=e,e&&'object'==typeof e&&'function'==typeof e.unref?e.unref():'undefined'!=typeof Deno&&'function'==typeof Deno.unrefTimer&&Deno.unrefTimer(e);const t=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=t,t&&'object'==typeof t&&'function'==typeof t.unref?t.unref():'undefined'!=typeof Deno&&'function'==typeof Deno.unrefTimer&&Deno.unrefTimer(t)}async _stopAutoRefresh(){this._debug('#_stopAutoRefresh()');const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const t=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,t&&clearTimeout(t)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),null===(e=this.broadcastChannel)||void 0===e||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug('#_autoRefreshTokenTick()','begin'),null==this.lock)if(null===this.refreshingDeferred)try{const e=Date.now();try{await this._useSession(async t=>{const{data:{session:s}}=t;if(!s||!s.refresh_token||!s.expires_at)return void this._debug('#_autoRefreshTokenTick()','no session');const r=Math.floor((1e3*s.expires_at-e)/h.AUTO_REFRESH_TICK_DURATION_MS);this._debug('#_autoRefreshTokenTick()',`access token expires in ${r} ticks, a tick lasts ${h.AUTO_REFRESH_TICK_DURATION_MS}ms, refresh threshold is ${h.AUTO_REFRESH_TICK_THRESHOLD} ticks`),r<=h.AUTO_REFRESH_TICK_THRESHOLD&&await this._callRefreshToken(s.refresh_token)})}catch(e){console.error('Auto refresh tick failed with error. This is likely a transient error.',e)}}finally{this._debug('#_autoRefreshTokenTick()','end')}else this._debug('#_autoRefreshTokenTick()','refresh already in flight, skipping');else try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async t=>{const{data:{session:s}}=t;if(!s||!s.refresh_token||!s.expires_at)return void this._debug('#_autoRefreshTokenTick()','no session');const r=Math.floor((1e3*s.expires_at-e)/h.AUTO_REFRESH_TICK_DURATION_MS);this._debug('#_autoRefreshTokenTick()',`access token expires in ${r} ticks, a tick lasts ${h.AUTO_REFRESH_TICK_DURATION_MS}ms, refresh threshold is ${h.AUTO_REFRESH_TICK_THRESHOLD} ticks`),r<=h.AUTO_REFRESH_TICK_THRESHOLD&&await this._callRefreshToken(s.refresh_token)})}catch(e){console.error('Auto refresh tick failed with error. This is likely a transient error.',e)}}finally{this._debug('#_autoRefreshTokenTick()','end')}})}catch(e){if(!(e instanceof w.LockAcquireTimeoutError))throw e;this._debug('auto refresh token tick lock not available')}}async _handleVisibilityChange(){if(this._debug('#_handleVisibilityChange()'),!(0,_.isBrowser)()||!(null===window||void 0===window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug('#visibilityChangedCallback','error',e)}},null===window||void 0===window||window.addEventListener('visibilitychange',this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error('_handleVisibilityChange',e)}}async _onVisibilityChanged(e){const t=`#_onVisibilityChanged(${e})`;if(this._debug(t,'visibilityState',document.visibilityState),'visible'===document.visibilityState){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,null!=this.lock)await this._acquireLock(this.lockAcquireTimeout,async()=>{'visible'===document.visibilityState?await this._recoverAndRefresh():this._debug(t,'acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting')});else{if('visible'!==document.visibilityState)return void this._debug(t,'visibilityState is no longer visible, skipping recovery');await this._recoverAndRefresh()}}else'hidden'===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,s){const r=[`provider=${encodeURIComponent(t)}`];if((null==s?void 0:s.redirectTo)&&r.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),(null==s?void 0:s.scopes)&&r.push(`scopes=${encodeURIComponent(s.scopes)}`),'pkce'===this.flowType){const[e,t]=await(0,_.getCodeChallengeAndMethod)(this.storage,this.storageKey),s=new URLSearchParams({code_challenge:`${encodeURIComponent(e)}`,code_challenge_method:`${encodeURIComponent(t)}`});r.push(s.toString())}if(null==s?void 0:s.queryParams){const e=new URLSearchParams(s.queryParams);r.push(e.toString())}return(null==s?void 0:s.skipBrowserRedirect)&&r.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${e}?${r.join('&')}`}async _unenroll(e){try{return await this._useSession(async t=>{var s;const{data:r,error:i}=t;return i?this._returnResult({data:null,error:i}):await(0,d._request)(this.fetch,'DELETE',`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:null===(s=null==r?void 0:r.session)||void 0===s?void 0:s.access_token})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _enroll(e){try{return await this._useSession(async t=>{var s,r;const{data:i,error:n}=t;if(n)return this._returnResult({data:null,error:n});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},'phone'===e.factorType?{phone:e.phone}:'totp'===e.factorType?{issuer:e.issuer}:{}),{data:o,error:l}=await(0,d._request)(this.fetch,'POST',`${this.url}/factors`,{body:a,headers:this.headers,jwt:null===(s=null==i?void 0:i.session)||void 0===s?void 0:s.access_token});return l?this._returnResult({data:null,error:l}):('totp'===e.factorType&&'totp'===o.type&&(null===(r=null==o?void 0:o.totp)||void 0===r?void 0:r.qr_code)&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),this._returnResult({data:o,error:null}))})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _verify(e){const t=async()=>{try{return await this._useSession(async t=>{var s;const{data:r,error:i}=t;if(i)return this._returnResult({data:null,error:i});const n=Object.assign({challenge_id:e.challengeId},'webauthn'in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:'create'===e.webauthn.type?(0,b.serializeCredentialCreationResponse)(e.webauthn.credential_response):(0,b.serializeCredentialRequestResponse)(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:o}=await(0,d._request)(this.fetch,'POST',`${this.url}/factors/${e.factorId}/verify`,{body:n,headers:this.headers,jwt:null===(s=null==r?void 0:r.session)||void 0===s?void 0:s.access_token});return o?this._returnResult({data:null,error:o}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers('MFA_CHALLENGE_VERIFIED',a),this._returnResult({data:a,error:o}))})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _challenge(e){const t=async()=>{try{return await this._useSession(async t=>{var s;const{data:r,error:i}=t;if(i)return this._returnResult({data:null,error:i});const n=await(0,d._request)(this.fetch,'POST',`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:null===(s=null==r?void 0:r.session)||void 0===s?void 0:s.access_token});if(n.error)return n;const{data:a}=n;if('webauthn'!==a.type)return{data:a,error:null};switch(a.webauthn.type){case'create':return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:(0,b.deserializeCredentialCreationOptions)(a.webauthn.credential_options.publicKey)})})}),error:null};case'request':return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:(0,b.deserializeCredentialRequestOptions)(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}};return null!=this.lock?this._acquireLock(this.lockAcquireTimeout,t):t()}async _challengeAndVerify(e){const{data:t,error:s}=await this._challenge({factorId:e.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;const{data:{user:t},error:s}=await this.getUser();if(s)return{data:null,error:s};const r={all:[],phone:[],totp:[],webauthn:[]};for(const s of null!==(e=null==t?void 0:t.factors)&&void 0!==e?e:[])r.all.push(s),'verified'===s.status&&r[s.factor_type].push(s);return{data:r,error:null}}async _getAuthenticatorAssuranceLevel(e){var t,s,r,i;if(e)try{const{payload:r}=(0,_.decodeJWT)(e);let i=null;r.aal&&(i=r.aal);let n=i;const{data:{user:a},error:o}=await this.getUser(e);if(o)return this._returnResult({data:null,error:o});(null!==(s=null===(t=null==a?void 0:a.factors)||void 0===t?void 0:t.filter(e=>'verified'===e.status))&&void 0!==s?s:[]).length>0&&(n='aal2');return{data:{currentLevel:i,nextLevel:n,currentAuthenticationMethods:r.amr||[]},error:null}}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}const{data:{session:n},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=(0,_.decodeJWT)(n.access_token);let l=null;o.aal&&(l=o.aal);let u=l;(null!==(i=null===(r=n.user.factors)||void 0===r?void 0:r.filter(e=>'verified'===e.status))&&void 0!==i?i:[]).length>0&&(u='aal2');return{data:{currentLevel:l,nextLevel:u,currentAuthenticationMethods:o.amr||[]},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{const{data:{session:s},error:r}=t;return r?this._returnResult({data:null,error:r}):s?await(0,d._request)(this.fetch,'GET',`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:s.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new c.AuthSessionMissingError})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _approveAuthorization(e,t){try{return await this._useSession(async s=>{const{data:{session:r},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!r)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const n=await(0,d._request)(this.fetch,'POST',`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:'approve'},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&(0,_.isBrowser)()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _denyAuthorization(e,t){try{return await this._useSession(async s=>{const{data:{session:r},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!r)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const n=await(0,d._request)(this.fetch,'POST',`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:'deny'},xform:e=>({data:e,error:null})});return n.data&&n.data.redirect_url&&(0,_.isBrowser)()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(n.data.redirect_url),n})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:t},error:s}=e;return s?this._returnResult({data:null,error:s}):t?await(0,d._request)(this.fetch,'GET',`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new c.AuthSessionMissingError})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async t=>{const{data:{session:s},error:r}=t;return r?this._returnResult({data:null,error:r}):s?(await(0,d._request)(this.fetch,'DELETE',`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new c.AuthSessionMissingError})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async fetchJwk(e,t={keys:[]}){let s=t.keys.find(t=>t.kid===e);if(s)return s;const r=Date.now();if(s=this.jwks.keys.find(t=>t.kid===e),s&&this.jwks_cached_at+h.JWKS_TTL>r)return s;const{data:i,error:n}=await(0,d._request)(this.fetch,'GET',`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(n)throw n;return i.keys&&0!==i.keys.length?(this.jwks=i,this.jwks_cached_at=r,s=i.keys.find(t=>t.kid===e),s||null):null}async getClaims(e,t={}){try{let s=e;if(!s){const{data:e,error:t}=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});s=e.session.access_token}const{header:r,payload:i,signature:n,raw:{header:a,payload:o}}=(0,_.decodeJWT)(s);if(!(null==t?void 0:t.allowExpired))try{(0,_.validateExp)(i.exp)}catch(e){throw new c.AuthInvalidJwtError(e instanceof Error?e.message:'JWT validation failed')}const l=r.alg&&!r.alg.startsWith('HS')&&r.kid&&'crypto'in globalThis&&'subtle'in globalThis.crypto?await this.fetchJwk(r.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks):null;if(!l){const{error:e}=await this.getUser(s);if(e)throw e;return{data:{claims:i,header:r,signature:n},error:null}}const u=(0,_.getAlgorithm)(r.alg),h=await crypto.subtle.importKey('jwk',l,u,!0,['verify']);if(!await crypto.subtle.verify(u,h,n,(0,p.stringToUint8Array)(`${a}.${o}`)))throw new c.AuthInvalidJwtError('Invalid JWT signature');return{data:{claims:i,header:r,signature:n},error:null}}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async signInWithPasskey(e){var t,s,r;(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{if(!(0,b.browserSupportsWebAuthn)())return this._returnResult({data:null,error:new c.AuthUnknownError('Browser does not support WebAuthn',null)});const{data:i,error:n}=await this._startPasskeyAuthentication({options:{captchaToken:null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.captchaToken}});if(n||!i)return this._returnResult({data:null,error:n});const a=(0,b.deserializeCredentialRequestOptions)(i.options),o=null!==(r=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.signal)&&void 0!==r?r:b.webAuthnAbortService.createNewAbortSignal(),{data:l,error:u}=await(0,b.getCredential)({publicKey:a,signal:o});if(u||!l)return this._returnResult({data:null,error:null!=u?u:new c.AuthUnknownError('WebAuthn ceremony failed',null)});const h=(0,b.serializeCredentialRequestResponse)(l);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:h})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async registerPasskey(e){var t,s;(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{if(!(0,b.browserSupportsWebAuthn)())return this._returnResult({data:null,error:new c.AuthUnknownError('Browser does not support WebAuthn',null)});const{data:r,error:i}=await this._startPasskeyRegistration();if(i||!r)return this._returnResult({data:null,error:i});const n=(0,b.deserializeCredentialCreationOptions)(r.options),a=null!==(s=null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.signal)&&void 0!==s?s:b.webAuthnAbortService.createNewAbortSignal(),{data:o,error:l}=await(0,b.createCredential)({publicKey:n,signal:a});if(l||!o)return this._returnResult({data:null,error:null!=l?l:new c.AuthUnknownError('WebAuthn ceremony failed',null)});const u=(0,b.serializeCredentialCreationResponse)(o);return this._verifyPasskeyRegistration({challengeId:r.challenge_id,credential:u})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyRegistration(){(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{return await this._useSession(async e=>{const{data:{session:t},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!t)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const{data:r,error:i}=await(0,d._request)(this.fetch,'POST',`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:t.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:r,error:null})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{return await this._useSession(async t=>{const{data:{session:s},error:r}=t;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const{data:i,error:n}=await(0,d._request)(this.fetch,'POST',`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:s.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:i,error:null})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _startPasskeyAuthentication(e){var t;(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{const{data:s,error:r}=await(0,d._request)(this.fetch,'POST',`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.captchaToken}}});return r?this._returnResult({data:null,error:r}):this._returnResult({data:s,error:null})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyAuthentication(e){(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{const{data:t,error:s}=await(0,d._request)(this.fetch,'POST',`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:d._sessionResponse});return s?this._returnResult({data:null,error:s}):(t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers('SIGNED_IN',t.session)),this._returnResult({data:t,error:null}))}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _listPasskeys(){(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{return await this._useSession(async e=>{const{data:{session:t},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!t)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const{data:r,error:i}=await(0,d._request)(this.fetch,'GET',`${this.url}/passkeys`,{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:r,error:null})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{return await this._useSession(async t=>{const{data:{session:s},error:r}=t;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const{data:i,error:n}=await(0,d._request)(this.fetch,'PATCH',`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,body:{friendly_name:e.friendlyName}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:i,error:null})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}async _deletePasskey(e){(0,_.assertPasskeyExperimentalEnabled)(this.experimental);try{return await this._useSession(async t=>{const{data:{session:s},error:r}=t;if(r)return this._returnResult({data:null,error:r});if(!s)return this._returnResult({data:null,error:new c.AuthSessionMissingError});const{error:i}=await(0,d._request)(this.fetch,'DELETE',`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(e){if((0,c.isAuthError)(e))return this._returnResult({data:null,error:e});throw e}}}R.nextInstanceID={};var A=R},1071,[1063,1065,1068,1064,1067,1072,1073,1074,1066,1069,1075,1076]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.memoryLocalStorageAdapter=function(t={}){return{getItem:o=>t[o]||null,setItem:(o,n)=>{t[o]=n},removeItem:o=>{delete t[o]}}}},1072,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"internals",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"LockAcquireTimeoutError",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"NavigatorLockAcquireTimeoutError",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"ProcessLockAcquireTimeoutError",{enumerable:!0,get:function(){return s}}),_e.navigatorLock=async function(e,t,s){o.debug&&console.log('@supabase/gotrue-js: navigatorLock: acquire lock',e,t);const c=new globalThis.AbortController;let l;t>0&&(l=setTimeout(()=>{c.abort(),o.debug&&console.log('@supabase/gotrue-js: navigatorLock acquire timed out',e)},t));await Promise.resolve();try{return await globalThis.navigator.locks.request(e,0===t?{mode:'exclusive',ifAvailable:!0}:{mode:'exclusive',signal:c.signal},async c=>{if(!c){if(0===t)throw o.debug&&console.log('@supabase/gotrue-js: navigatorLock: not immediately available',e),new n(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(o.debug)try{const e=await globalThis.navigator.locks.query();console.log('@supabase/gotrue-js: Navigator LockManager state',JSON.stringify(e,null,' '))}catch(e){console.warn('@supabase/gotrue-js: Error when querying Navigator LockManager state',e)}return console.warn('@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request'),clearTimeout(l),await s()}clearTimeout(l),o.debug&&console.log('@supabase/gotrue-js: navigatorLock: acquired',e,c.name);try{return await s()}finally{o.debug&&console.log('@supabase/gotrue-js: navigatorLock: released',e,c.name)}})}catch(u){if(t>0&&clearTimeout(l),null!==u&&'object'==typeof u&&'name'in u&&'AbortError'===u.name&&t>0){if(c.signal.aborted)return o.debug&&console.log('@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock',e),console.warn(`@supabase/gotrue-js: Lock "${e}" was not released within ${t}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:'exclusive',steal:!0},async t=>{if(!t)return console.warn('@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true'),await s();o.debug&&console.log('@supabase/gotrue-js: navigatorLock: recovered (stolen)',e,t.name);try{return await s()}finally{o.debug&&console.log('@supabase/gotrue-js: navigatorLock: released (stolen)',e,t.name)}}));throw o.debug&&console.log('@supabase/gotrue-js: navigatorLock: lock was stolen by another request',e),new n(`Lock "${e}" was released because another request stole it`)}throw u}},_e.processLock=async function(e,o,n){var l;const u=null!==(l=c[e])&&void 0!==l?l:Promise.resolve(),b=(async()=>{try{return await u,null}catch(e){return null}})(),k=(async()=>{let c=null;try{const t=o>=0?new Promise((t,n)=>{c=setTimeout(()=>{console.warn(`@supabase/gotrue-js: Lock "${e}" acquisition timed out after ${o}ms. This may be caused by another operation holding the lock. Consider increasing lockAcquireTimeout or checking for stuck operations.`),n(new s(`Acquiring process lock with name "${e}" timed out`))},o)}):null;await Promise.race([b,t].filter(e=>e)),null!==c&&clearTimeout(c)}catch(e){if(null!==c&&clearTimeout(c),e instanceof t)throw e}return await n()})();return c[e]=(async()=>{try{return await k}catch(e){if(e instanceof t){try{await u}catch(e){}return null}throw e}})(),await k};var e=r(d[0]);const o={debug:!!(globalThis&&(0,e.supportsLocalStorage)()&&globalThis.localStorage&&'true'===globalThis.localStorage.getItem('supabase.gotrue-js.locks.debug'))};class t extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class n extends t{}class s extends t{}const c={}},1073,[1067]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.polyfillGlobalThis=function(){if('object'==typeof globalThis)return;try{Object.defineProperty(Object.prototype,'__magic__',{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){'undefined'!=typeof self&&(self.globalThis=self)}}},1074,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}Object.defineProperty(e,'__esModule',{value:!0}),e.getAddress=t,e.fromHex=function(t){return parseInt(t,16)},e.toHex=function(t){const n=(new TextEncoder).encode(t);return'0x'+Array.from(n,t=>t.toString(16).padStart(2,'0')).join('')},e.createSiweMessage=function(n){var s;const{chainId:o,domain:u,expirationTime:c,issuedAt:l=new Date,nonce:f,notBefore:I,requestId:v,resources:h,scheme:$,uri:w,version:E}=n;if(!Number.isInteger(o))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${o}`);if(!u)throw new Error("@supabase/auth-js: Invalid SIWE message field \"domain\". Domain must be provided.");if(f&&f.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${f}`);if(!w)throw new Error("@supabase/auth-js: Invalid SIWE message field \"uri\". URI must be provided.");if('1'!==E)throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${E}`);if(null===(s=n.statement)||void 0===s?void 0:s.includes('\n'))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${n.statement}`);const S=t(n.address),b=$?`${$}://${u}`:u,p=n.statement?`${n.statement}\n`:'',j=`${b} wants you to sign in with your Ethereum account:\n${S}\n\n${p}`;let x=`URI: ${w}\nVersion: ${E}\nChain ID: ${o}${f?`\nNonce: ${f}`:''}\nIssued At: ${l.toISOString()}`;c&&(x+=`\nExpiration Time: ${c.toISOString()}`);I&&(x+=`\nNot Before: ${I.toISOString()}`);v&&(x+=`\nRequest ID: ${v}`);if(h){let t='\nResources:';for(const n of h){if(!n||'string'!=typeof n)throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${n}`);t+=`\n- ${n}`}x+=t}return`${j}\n${x}`}},1075,[]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WebAuthnError",{enumerable:!0,get:function(){return l.WebAuthnError}}),Object.defineProperty(e,"isWebAuthnError",{enumerable:!0,get:function(){return l.isWebAuthnError}}),Object.defineProperty(e,"identifyRegistrationError",{enumerable:!0,get:function(){return l.identifyRegistrationError}}),Object.defineProperty(e,"identifyAuthenticationError",{enumerable:!0,get:function(){return l.identifyAuthenticationError}}),Object.defineProperty(e,"WebAuthnAbortService",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"webAuthnAbortService",{enumerable:!0,get:function(){return u}}),e.deserializeCredentialCreationOptions=function(i){if(!i)throw new Error('Credential creation options are required');if('undefined'!=typeof PublicKeyCredential&&'parseCreationOptionsFromJSON'in PublicKeyCredential&&'function'==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(i);const{challenge:o,user:l,excludeCredentials:s}=i,u=(0,t.__rest)(i,["challenge","user","excludeCredentials"]),c=(0,n.base64UrlToUint8Array)(o).buffer,f=Object.assign(Object.assign({},l),{id:(0,n.base64UrlToUint8Array)(l.id).buffer}),h=Object.assign(Object.assign({},u),{challenge:c,user:f});if(s&&s.length>0){h.excludeCredentials=new Array(s.length);for(let t=0;t0){c.allowCredentials=new Array(l.length);for(let t=0;tnull!==t&&'object'==typeof t&&!Array.isArray(t),i=t=>t instanceof ArrayBuffer||ArrayBuffer.isView(t),o={};for(const l of t)if(l)for(const t in l){const s=l[t];if(void 0!==s)if(Array.isArray(s))o[t]=s;else if(i(s))o[t]=s;else if(n(s)){const i=o[t];n(i)?o[t]=p(i,s):o[t]=p(s)}else o[t]=s}return o}function w(t,n){return p(b,t,n||{})}function A(t,n){return p(y,t,n||{})}class O{constructor(t){this.client=t,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:'webauthn'}))}async _challenge({factorId:t,webauthn:n,friendlyName:o,signal:l},s){var c;try{const{data:i,error:b}=await this.client.mfa.challenge({factorId:t,webauthn:n});if(!i)return{data:null,error:b};const y=null!=l?l:u.createNewAbortSignal();if('create'===i.webauthn.type){const{user:t}=i.webauthn.credential_options.publicKey;if(!t.name){const n=o;if(n)t.name=`${t.id}:${n}`;else{const n=(await this.client.getUser()).data.user,i=(null===(c=null==n?void 0:n.user_metadata)||void 0===c?void 0:c.name)||(null==n?void 0:n.email)||(null==n?void 0:n.id)||'User';t.name=`${t.id}:${i}`}}t.displayName||(t.displayName=t.name)}switch(i.webauthn.type){case'create':{const n=w(i.webauthn.credential_options.publicKey,null==s?void 0:s.create),{data:o,error:l}=await f({publicKey:n,signal:y});return o?{data:{factorId:t,challengeId:i.id,webauthn:{type:i.webauthn.type,credential_response:o}},error:null}:{data:null,error:l}}case'request':{const n=A(i.webauthn.credential_options.publicKey,null==s?void 0:s.request),{data:o,error:l}=await h(Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:n,signal:y}));return o?{data:{factorId:t,challengeId:i.id,webauthn:{type:i.webauthn.type,credential_response:o}},error:null}:{data:null,error:l}}}}catch(t){return(0,i.isAuthError)(t)?{data:null,error:t}:{data:null,error:new i.AuthUnknownError('Unexpected error in challenge',t)}}}async _verify({challengeId:t,factorId:n,webauthn:i}){return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:i})}async _authenticate({factorId:t,webauthn:{rpId:n=('undefined'!=typeof window?window.location.hostname:void 0),rpOrigins:o=('undefined'!=typeof window?[window.location.origin]:void 0),signal:l}={}},s){if(!n)return{data:null,error:new i.AuthError('rpId is required for WebAuthn authentication')};try{if(!c())return{data:null,error:new i.AuthUnknownError('Browser does not support WebAuthn',null)};const{data:u,error:f}=await this.challenge({factorId:t,webauthn:{rpId:n,rpOrigins:o},signal:l},{request:s});if(!u)return{data:null,error:f};const{webauthn:h}=u;return this._verify({factorId:t,challengeId:u.challengeId,webauthn:{type:h.type,rpId:n,rpOrigins:o,credential_response:h.credential_response}})}catch(t){return(0,i.isAuthError)(t)?{data:null,error:t}:{data:null,error:new i.AuthUnknownError('Unexpected error in authenticate',t)}}}async _register({friendlyName:t,webauthn:{rpId:n=('undefined'!=typeof window?window.location.hostname:void 0),rpOrigins:o=('undefined'!=typeof window?[window.location.origin]:void 0),signal:l}={}},s){if(!n)return{data:null,error:new i.AuthError('rpId is required for WebAuthn registration')};try{if(!c())return{data:null,error:new i.AuthUnknownError('Browser does not support WebAuthn',null)};const{data:u,error:f}=await this._enroll({friendlyName:t});if(!u)return await this.client.mfa.listFactors().then(n=>{var i;return null===(i=n.data)||void 0===i?void 0:i.all.find(n=>'webauthn'===n.factor_type&&n.friendly_name===t&&'unverified'!==n.status)}).then(t=>t?this.client.mfa.unenroll({factorId:null==t?void 0:t.id}):void 0),{data:null,error:f};const{data:h,error:b}=await this._challenge({factorId:u.id,friendlyName:u.friendly_name,webauthn:{rpId:n,rpOrigins:o},signal:l},{create:s});return h?this._verify({factorId:u.id,challengeId:h.challengeId,webauthn:{rpId:n,rpOrigins:o,type:h.webauthn.type,credential_response:h.webauthn.credential_response}}):{data:null,error:b}}catch(t){return(0,i.isAuthError)(t)?{data:null,error:t}:{data:null,error:new i.AuthUnknownError('Unexpected error in register',t)}}}}},1076,[1041,1069,1068,1067,1077]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WebAuthnError",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"WebAuthnUnknownError",{enumerable:!0,get:function(){return t}}),e.isWebAuthnError=function(n){return'object'==typeof n&&null!==n&&'__isWebAuthnError'in n},e.identifyRegistrationError=function({error:t,options:s}){var u,c,R;const{publicKey:E}=s;if(!E)throw Error('options was missing required publicKey property');if('AbortError'===t.name){if(s.signal instanceof AbortSignal)return new o({message:'Registration ceremony was sent an abort signal',code:'ERROR_CEREMONY_ABORTED',cause:t})}else if('ConstraintError'===t.name){if(!0===(null===(u=E.authenticatorSelection)||void 0===u?void 0:u.requireResidentKey))return new o({message:'Discoverable credentials were required but no available authenticator supported it',code:'ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT',cause:t});if('conditional'===s.mediation&&'required'===(null===(c=E.authenticatorSelection)||void 0===c?void 0:c.userVerification))return new o({message:'User verification was required during automatic registration but it could not be performed',code:'ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE',cause:t});if('required'===(null===(R=E.authenticatorSelection)||void 0===R?void 0:R.userVerification))return new o({message:'User verification was required but no available authenticator supported it',code:'ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT',cause:t})}else{if('InvalidStateError'===t.name)return new o({message:'The authenticator was previously registered',code:'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED',cause:t});if('NotAllowedError'===t.name)return new o({message:t.message,code:'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',cause:t});if('NotSupportedError'===t.name){return 0===E.pubKeyCredParams.filter(n=>'public-key'===n.type).length?new o({message:'No entry in pubKeyCredParams was of type "public-key"',code:'ERROR_MALFORMED_PUBKEYCREDPARAMS',cause:t}):new o({message:'No available authenticator supported any of the specified pubKeyCredParams algorithms',code:'ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG',cause:t})}if('SecurityError'===t.name){const s=window.location.hostname;if(!(0,n.isValidDomain)(s))return new o({message:`${window.location.hostname} is an invalid domain`,code:'ERROR_INVALID_DOMAIN',cause:t});if(E.rp.id!==s)return new o({message:`The RP ID "${E.rp.id}" is invalid for this domain`,code:'ERROR_INVALID_RP_ID',cause:t})}else if('TypeError'===t.name){if(E.user.id.byteLength<1||E.user.id.byteLength>64)return new o({message:'User ID was not between 1 and 64 characters',code:'ERROR_INVALID_USER_ID_LENGTH',cause:t})}else if('UnknownError'===t.name)return new o({message:'The authenticator was unable to process the specified options, or could not create a new credential',code:'ERROR_AUTHENTICATOR_GENERAL_ERROR',cause:t})}return new o({message:'a Non-Webauthn related error has occurred',code:'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',cause:t})},e.identifyAuthenticationError=function({error:t,options:s}){const{publicKey:u}=s;if(!u)throw Error('options was missing required publicKey property');if('AbortError'===t.name){if(s.signal instanceof AbortSignal)return new o({message:'Authentication ceremony was sent an abort signal',code:'ERROR_CEREMONY_ABORTED',cause:t})}else{if('NotAllowedError'===t.name)return new o({message:t.message,code:'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',cause:t});if('SecurityError'===t.name){const s=window.location.hostname;if(!(0,n.isValidDomain)(s))return new o({message:`${window.location.hostname} is an invalid domain`,code:'ERROR_INVALID_DOMAIN',cause:t});if(u.rpId!==s)return new o({message:`The RP ID "${u.rpId}" is invalid for this domain`,code:'ERROR_INVALID_RP_ID',cause:t})}else if('UnknownError'===t.name)return new o({message:'The authenticator was unable to process the specified options, or could not create a new assertion signature',code:'ERROR_AUTHENTICATOR_GENERAL_ERROR',cause:t})}return new o({message:'a Non-Webauthn related error has occurred',code:'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',cause:t})};var n=r(d[0]);class o extends Error{constructor({message:n,code:o,cause:t,name:s}){var u;super(n,{cause:t}),this.__isWebAuthnError=!0,this.name=null!==(u=null!=s?s:t instanceof Error?t.name:void 0)&&void 0!==u?u:'Unknown Error',this.code=o}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class t extends o{constructor(n,o){super({code:'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',cause:o,message:n}),this.name='WebAuthnUnknownError',this.originalError=o}}},1077,[1076]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]);var u=((e=t)&&e.__esModule?e:{default:e}).default},1078,[1063]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]);var u=((e=t)&&e.__esModule?e:{default:e}).default},1079,[1071]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUPABASE_URL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPABASE_ANON_KEY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return u}});const t="https://rowdoidkftriylijobuy.supabase.co",n="sb_publishable_rPm723MQz6FwmFVHy6e1SA_ko-_-6GR",o=()=>t.startsWith('https://')&&n.length>20,u=['bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_counts']},1080,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.setSyncNamespace=function(e){c=`cc-sync:${e}:`},Object.defineProperty(_e,"syncNamespace",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"kv",{enumerable:!0,get:function(){return o}}),_e.uuid=function(){const e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();const t=new Uint8Array(16);if(e?.getRandomValues)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(256*Math.random());t[6]=15&t[6]|64,t[8]=63&t[8]|128;const n=Array.from(t,e=>e.toString(16).padStart(2,'0')).join('');return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e};let c='cc-sync:';const s=()=>c,o={async get(e,t){try{const s=await n.default.getItem(c+e);return null==s?t:JSON.parse(s)}catch{return t}},async set(e,t){try{await n.default.setItem(c+e,JSON.stringify(t))}catch{}},async remove(e){try{await n.default.removeItem(c+e)}catch{}}}},1081,[975]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isOnline",{enumerable:!0,get:function(){return t}}),_e.setOnline=o,_e.onConnectivity=function(e){return n.add(e),()=>{n.delete(e)}},_e.isNetworkError=function(e){if(!e)return!1;const n=String(e.message??e).toLowerCase();return 0===e.status||/network|fetch failed|failed to fetch|timeout|timed out|offline|econn|enotfound|socket/.test(n)};let e=!0;const n=new Set,t=()=>e;function o(t){t!==e&&(e=t,n.forEach(n=>n(e)))}const s=globalThis.window;s?.addEventListener&&('boolean'==typeof s.navigator?.onLine&&(e=s.navigator.onLine),s.addEventListener('online',()=>o(!0)),s.addEventListener('offline',()=>o(!1)))},1082,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return u}}),e.executeMutation=async function(t){if('rpc'===t.kind){const{error:s}=await o().rpc(t.fn,t.values??{});if(s)throw s;return'ok'}const s=o().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:n}=await s.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(n)throw n;return'ok'}let n='update'===t.kind?s.update(t.values??{}):s.delete();for(const[s,r]of Object.entries(t.match??{}))n=n.eq(s,r);const{data:r,error:u}=await n.select();if(u)throw u;return'update'!==t.kind||r&&0!==r.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]);const o=()=>(0,s.getSupabase)();class u{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(s){return t.cache.rows(this.table,s)}get(s,n){return t.cache.get(this.table,s,n)}subscribe(s,n){return t.cache.subscribe(this.table,s,n)}hydrate(s){return t.cache.hydrate(this.table,s)}async refresh(s,n={}){let u=o().from(this.table).select('*').eq(this.venueCol,s);this.opts.orderBy&&(u=u.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),n.filter&&(u=n.filter(u));const{data:c,error:h}=await u.limit(this.opts.limit??1e3);if(h)throw h;const l=c??[];return t.cache.replace(this.table,s,l.map(t=>[this.keyOf(t),t]),t=>r.mutationQueue.hasPending(this.table,s,t)),l}async create(s,o){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,n.uuid)()}:{},...o,[this.venueCol]:s},c=this.keyOf(u);return t.cache.put(this.table,s,c,u),await r.mutationQueue.enqueue({table:this.table,venueId:s,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(s,n,o,u={}){const c=t.cache.get(this.table,s,n),h={...this.matchFor(n,c),...u,[this.venueCol]:s};t.cache.patch(this.table,s,n,{...o,updated_at:(new Date).toISOString()}),await r.mutationQueue.enqueue({table:this.table,venueId:s,kind:'update',rowKey:n,values:o,match:h})}async remove(s,n){const o=t.cache.get(this.table,s,n),u={...this.matchFor(n,o),[this.venueCol]:s};t.cache.remove(this.table,s,n),await r.mutationQueue.enqueue({table:this.table,venueId:s,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},1083,[1084,1037,1081,1085]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return w}});var t=r(d[0]);const n=new Map,s=new Map,c=new Map,o=new Map,u=new Set,l=(t,n)=>`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},1084,[1081]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return h}});var t=r(d[0]),e=r(d[1]);const s='queue:v1',n='queue:failed:v1';const h=new class{items=[];failedItems=[];loaded=null;flushing=null;exec=null;listeners=new Set;onFailure=new Set;retryTimer=null;backoffMs=2e3;constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(s,[]);this.items=[...t,...this.items],this.failedItems=await e.kv.get(n,[]),this.emit()})()),this.loaded}get pending(){return this.items}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}flush(){return this.flushing||(this.flushing=(async()=>{for(await this.load();this.items.length&&this.exec;){if(!(0,t.isOnline)()){this.scheduleRetry();break}const e=this.items[0];try{const t=await this.exec(e);this.items.shift(),this.backoffMs=2e3,'conflict'===t&&this.fail(e,'conflict','Row changed on the server (version conflict) or is not visible to you')}catch(s){if(e.attempts+=1,e.lastError=String(s?.message??s),(0,t.isNetworkError)(s)){(0,t.setOnline)(!1),this.scheduleRetry();break}this.items.shift(),this.fail(e,'rejected',e.lastError)}await this.persist()}this.flushing=null})()),this.flushing}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(n,[]),this.emit()}fail(t,s,h){const l={...t,lastError:h,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[l,...this.failedItems].slice(0,100),e.kv.set(n,this.failedItems),this.onFailure.forEach(t=>t(l))}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(s,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}},1085,[1082,1081]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hashOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return c}}),_e.venueChannel=function(e,t,n,s){let o=i().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:i}of t)o=o.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${i??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return o.subscribe(e=>s(e)),o},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return t.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]);const i=()=>(0,e.getSupabase)(),o=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(o).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${o(t[e])}`).join(',')}}`},h=e=>{const t=o(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`};class c{known={};last=new Map;reconciled=!1;applying=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}async start(){this.known=await n.kv.get(this.kvKey,{}),this.snapshotLocal(),this.unsub=this.spec.subscribe(()=>{!this.applying&&this.reconciled&&this.pushLocalChanges()})}stop(){this.unsub?.(),this.unsub=null}snapshotLocal(){this.last=new Map(this.spec.list().map(e=>[this.spec.key(e),h(e)]))}saveKnown(){n.kv.set(this.kvKey,this.known)}pending(e){return s.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){let e=i().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);this.spec.filter&&(e=this.spec.filter(e));const{data:t,error:n}=await e.limit(2e3);if(n)throw n;const s=t??[];this.merge(s,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(s)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],c=[],l=[];for(const t of e){const e=n.rowKey(t),c=n.fromRow(t);if(!c)continue;i.add(e);const u=h(c),p=s.get(e);if(!this.pending(e)){if(p){const t=h(p);if(t===u){this.known[e]=u;continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(p)){l.push(p);continue}}o.push(c),this.known[e]=u}}for(const[e,t]of s)i.has(e)||this.pending(e)||!n.syncable(t)||n.inWindow&&!n.inWindow(t)||(this.known[e]?(c.push(e),delete this.known[e]):n.writable()&&l.push(t));this.applyRemote(o,c);for(const e of l)this.write(e);this.saveKnown()}applyRemote(e,t){if(e.length||t.length){this.applying=!0;try{this.spec.apply(e,t)}finally{this.applying=!1}this.snapshotLocal(),this.ev.onActivity?.()}}remote(e,t){if(!this.reconciled)return;const n=this.spec,s=n.rowKey(t);if(this.pending(s))return;if('delete'===e){if(!this.last.has(s))return;return delete this.known[s],this.applyRemote([],[s]),this.saveKnown(),void n.onRemote?.(t,e)}const i=n.fromRow(t);if(!i)return;const o=h(i);this.known[s]=o,this.saveKnown(),this.last.get(s)!==o&&this.applyRemote([i],[]),n.onRemote?.(t,e)}pushLocalChanges(){const e=this.spec,t=new Map(e.list().map(t=>[e.key(t),t]));for(const[n,s]of t){const t=h(s);this.last.get(n)!==t&&(this.last.set(n,t),e.syncable(s)&&e.writable()&&this.known[n]!==t&&this.write(s))}for(const n of[...this.last.keys()])t.has(n)||(this.last.delete(n),this.known[n]&&e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode&&(delete this.known[n],s.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:n,match:{...this.deleteMatch(n),venue_id:this.venueId}})));this.saveKnown()}deleteMatch(e){return this.spec.matchKey?this.spec.matchKey(e):{id:e}}write(e){const t=this.spec,n=t.key(e);let i;try{i=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if(this.known[n]=h(e),'update'===t.mode){const e=t.venueColumn??'venue_id';s.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:i,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else s.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:i,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1086,[1037,1082,1081,1085]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOrderSheets",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return p}});var e,s=r(d[0]),t=(e=s)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]),h=r(d[3]);const i=()=>({anchorage:h.ANCHORAGE_SHEETS.map(e=>({...e,items:e.items.map(e=>({...e}))}))}),c=(0,n.create)()((0,o.persist)(e=>({sheets:i(),opened:{},upsert:(s,t)=>e(e=>{const n=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:n.some(e=>e.id===t.id)?n.map(e=>e.id===t.id?t:e):[...n,t]}}}),patch:(s,t,n)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...n}:e)}})),remove:(s,t)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).filter(e=>e.id!==t)}})),markOpened:(s,t)=>e(e=>({opened:{...e.opened,[s]:t}})),reset:s=>e(e=>({sheets:{...e.sheets,[s]:'anchorage'===s?i().anchorage:[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,o.createJSONStorage)(()=>t.default),version:1})),u=[],p=e=>c(s=>s.sheets[e])??u},1087,[975,974,976,1088]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"METHOD_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return s}}),e.dayRange=function(t){const o=[...new Set(t)].sort((t,n)=>t-n);if(!o.length)return'';if(7===o.length)return'every day';return o.every((t,n)=>n===0||t===o[n-1]+1)&&o.length>=3?`${n[o[0]]} to ${n[o[o.length-1]]}`:o.map(t=>n[t]).join(', ')},e.nextDelivery=i,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return a}}),e.remindersFor=function(t,n,a={}){const d=s(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(a[t.id]&&new Date(a[t.id]).toDateString()===n.toDateString())return[];let d=!1;if(/^\d\d:\d\d$/.test(t.cutoff)){const[o,s]=t.cutoff.split(':').map(Number),i=new Date(n);i.setHours(o,s,0,0),d=n>i}const l=i(t,n),u=t.reminder||`Order ${t.name} today${l?` for ${o[s(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${u}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(t,n,o){const s=t.items.filter(t=>(n[t.id]??0)>0).map(t=>`${d(n[t.id])} ${t.unit} ${t.name}`.replace(/\s+/g,' ').trim());return o.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>s.push(t)),s},e.orderMessage=function(t,n,o,s,d,l){const u=i(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${u?` for ${a(u)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${d}`].join('\n')},e.intlDigits=l,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return b}});const t={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},n=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],o=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],s=t=>(t.getDay()+6)%7;function i(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const i=new Date(n);if(i.setDate(i.getDate()+t),o.includes(s(i)))return i}return null}const a=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const d=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function l(t){const n=t.replace(/[^\d+]/g,'').replace(/^\+/,'');return n.startsWith('00')?n.slice(2):n.startsWith('0')?`44${n.slice(1)}`:n}const u=(t,n)=>`sms:${t.replace(/[^\d+]/g,'')}?&body=${encodeURIComponent(n)}`,c=(t,n)=>`https://wa.me/${l(t)}?text=${encodeURIComponent(n)}`,m=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let f=0;const p=(t="os")=>`${t}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(t,n,o)=>({id:t,name:n,unit:o}),y=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),b=[y({id:'os-reids',name:'Reids',goods:'Dry goods and frozen',method:'online',urlLabel:'Open Coldweb',deliveryDays:[0,1,2,3,4],frequency:'Order on Coldweb',items:[h('rd-chips','Frozen chips','boxes'),h('rd-oil','Fryer oil','tubs'),h('rd-flour','Flour','bags'),h('rd-rice','Rice','bags'),h('rd-peas','Frozen peas','bags')],notes:'Order on their Coldweb ordering site. Add the Coldweb link in Managers \u203a Settings \u203a Supplier order sheets, or here.'}),y({id:'os-veg',name:'Veg',goods:'Fruit and veg (supplier to be added)',method:'tbc',placeholder:!0,frequency:'To be added by Gordon',notes:'Placeholder: Gordon will add the veg supplier, how to order and delivery days.'}),y({id:'os-peroni',name:'Peroni Ayr',goods:'Seafood',method:'phone',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[h('pa-haddock','Haddock fillets','kg'),h('pa-mussels','Mussels','kg'),h('pa-scallops','Scallops','kg'),h('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),y({id:'os-spesbona',name:'Spes Bona',goods:'Langoustines and smoked haddock',method:'text',orderDays:[2],deliversOn:4,deliveryDays:[4],frequency:'Text on Wednesday for Friday',reminder:'Text Spes Bona today for Friday\u2019s langoustines and smoked haddock',items:[h('sb-langs','Langoustines','kg'),h('sb-smoked','Smoked haddock','kg')]}),y({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[h('tg-steak','Ribeye steaks',''),h('tg-mince','Steak mince','kg'),h('tg-chicken','Chicken breasts',''),h('tg-sausage','Sausages','kg')]}),y({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[h('ml-milk','Milk','litres'),h('ml-cream','Double cream','litres'),h('ml-butter','Butter','kg')]}),y({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[h('kf-lobster','Lobsters',''),h('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),y({id:'os-lionsmane',name:'Lion\u2019s mane mushroom',goods:'Lion\u2019s mane mushrooms',method:'online',urlLabel:'Open seller',frequency:'Weekly or fortnightly',priceCapPerKg:2500,seller:'Cheapest UK seller (to be chosen)',items:[h('lm-kg','Lion\u2019s mane mushroom','kg')],notes:'Order online from the cheapest UK seller under the price cap. Check the price per kg before you buy.'})]},1088,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAvatars",{enumerable:!0,get:function(){return l}});var t,e=r(d[0]),o=(t=e)&&t.__esModule?t:{default:t},s=r(d[1]),n=r(d[2]);const l=(0,s.create)()((0,n.persist)((t,e)=>({photos:{},log:[],setOwn:(e,o,s,n)=>{if(!e||e!==o||!s.startsWith('data:image/'))return!1;const l=(new Date).toISOString();return t(t=>({photos:{...t.photos,[o]:{dataUrl:s,at:l}},log:[{id:`av-${Date.now().toString(36)}`,staffId:o,what:'made',by:n,at:l},...t.log].slice(0,100)})),!0},reset:(o,s)=>{if(s.id!==o&&'staff'===s.role)return!1;if(!e().photos[o])return!1;const n={...e().photos};return delete n[o],t(t=>({photos:n,log:[{id:`av-${Date.now().toString(36)}`,staffId:o,what:'reset',by:s.name,at:(new Date).toISOString()},...t.log].slice(0,100)})),!0}}),{name:'covercharge-avatars-v1',storage:(0,n.createJSONStorage)(()=>o.default),version:1}))},1089,[975,974,976]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SETUP_STEPS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"ACCESS_LEVELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"ACCESS_ROLE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"ACCESS_APP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"accessOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PERMS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DEFAULT_PERMS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"DEFAULT_GRADES",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useSetup",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"useSiteSetup",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"setupProgress",{enumerable:!0,get:function(){return w}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),s=r(d[2]);const o=[{id:'venue',title:'Venue details & logo',sub:'Name, address, phone, your logo and order at table'},{id:'hours',title:'Opening hours',sub:'When the kitchen is open each day'},{id:'plan',title:'Areas & table plan',sub:'Your areas, tables and seats'},{id:'paygrades',title:'Pay grades',sub:'Named hourly rates for your team'},{id:'staff',title:'Add staff',sub:'Name, role, access, pay and avatar'},{id:'permissions',title:'Permissions',sub:'What each access level can do'},{id:'email',title:'Link email',sub:'Your work email address'},{id:'website',title:'Link website',sub:'Your website and booking link'},{id:'invites',title:'Staff invite links',sub:'Personal links for each person'}],l=['Owner','Manager','Supervisor','Head Chef','Staff'],u={Owner:'owner',Manager:'manager',Supervisor:'manager','Head Chef':'staff',Staff:'staff'},c={Owner:'Managers',Manager:'Managers',Supervisor:'Managers','Head Chef':'Head Chef',Staff:'Staff'},f=(e,t)=>l.includes(e??'')?e:'owner'===t?'Owner':'manager'===t?'Manager':'Staff',b=[{id:'bookings',label:'Take and change bookings'},{id:'walkins',label:'Seat walk-ins'},{id:'block',label:'Block bookings and close the garden'},{id:'tableplan',label:'Edit the table plan'},{id:'kitchen',label:'Kitchen tickets and allergy ticks'},{id:'menu',label:'Edit the menu and allergens'},{id:'rota',label:'Make the rota'},{id:'timesheets',label:'Approve timesheets'},{id:'pay',label:'See pay and wages'},{id:'takings',label:'See takings and reports'},{id:'staff',label:'Add staff and change access'},{id:'settings',label:'Change venue settings'},{id:'billing',label:'Plan and billing'}],p=e=>Object.fromEntries(b.map(t=>[t.id,e])),g=e=>({...p(!1),...Object.fromEntries(e.map(e=>[e,!0]))}),h={Owner:p(!0),Manager:{...p(!0),staff:!1,billing:!1},Supervisor:g(['bookings','walkins','block','tableplan','kitchen','rota']),'Head Chef':g(['kitchen','menu','rota']),Staff:g(['bookings','walkins'])},S=[{id:'pg-foh',name:'Front of house',pence:1271},{id:'pg-bar',name:'Bar team',pence:1271},{id:'pg-kp',name:'Kitchen porter',pence:1271},{id:'pg-cdp',name:'Chef de partie',pence:1450},{id:'pg-sup',name:'Supervisor',pence:1400}],k=()=>({done:{},grades:S.map(e=>({...e})),staffGrade:{},perms:JSON.parse(JSON.stringify(h)),email:'',website:'',bookingUrl:'',invites:{}}),O=(0,i.create)()((0,s.persist)((e,t)=>({sites:{},looks:{},patch:(t,n)=>e(e=>({sites:{...e.sites,[t]:{...e.sites[t]??k(),...n}}})),markDone:(e,n,i=!0)=>{const s={...(t().sites[e]??k()).done};i?s[n]=(new Date).toISOString():delete s[n],t().patch(e,{done:s})},setPerm:(e,n,i,s)=>{const o=t().sites[e]??k();'Owner'!==n&&t().patch(e,{perms:{...o.perms,[n]:{...o.perms[n],[i]:s}}})},resetPerms:e=>t().patch(e,{perms:JSON.parse(JSON.stringify(h))}),setLook:(t,n)=>e(e=>{const i={...e.looks};return null==n?delete i[t]:i[t]=n,{looks:i}})}),{name:'covercharge-setup-v1',storage:(0,s.createJSONStorage)(()=>n.default),version:1})),P=e=>O(t=>t.sites[e])??y,y=k(),w=e=>{const t=o.filter(t=>e.done[t.id]).length;return{done:t,total:o.length,pct:t/o.length}}},1090,[975,974,976]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SEED_INGREDIENTS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return b}});var e,t=_r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=_r(_d[1]),n=_r(_d[2]);const o=(e,t,s,i,n,o,r,d=[],l)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:o,onHand:r,allergens:d,prevCost:l}),r=[o('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),o('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),o('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),o('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),o('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),o('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),o('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),o('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),o('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),o('steak','Braising steak','kg',1200,'sup-2',8,6.2),o('patty','Burger patty 6 oz','each',160,'sup-2',40,18),o('chicken','Chicken breast','kg',950,'sup-2',10,7.5),o('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),o('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),o('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),o('onions','Onions','kg',110,'sup-3',15,11),o('leaves','Salad leaves','kg',700,'sup-3',3,.8),o('lemons','Lemons','each',25,'sup-3',60,44),o('milk','Whole milk','L',110,'sup-4',20,14,['milk']),o('cream','Double cream','L',380,'sup-4',12,9,['milk']),o('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),o('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),o('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),o('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),o('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),o('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),o('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),o('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),o('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),o('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),o('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),o('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),o('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),o('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),o('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],d=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),l=[d('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),d('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),d('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),d('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),d('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),d('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),d('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),d('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),d('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),d('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),d('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),d('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),d('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),d('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),d('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),d('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),d('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),d('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),d('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),d('a-chips','1 side',[['potatoes',.35],['oil',.05]]),d('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),d('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),d('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),d('a-salad','1 side',[['leaves',.06],['lemons',.5]]),d('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],p=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],c=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},u=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function k(){return{ingredients:r.map(e=>({...e})),recipes:l,targetGp:70,deliveries:[{id:'dl-today-fish',supplierId:'sup-1',due:'today',status:'expected',lines:[{ing:'haddock',ordered:10,received:8,price:1848},{ing:'mussels',ordered:12,received:12,price:450},{ing:'langoustine',ordered:3,received:3,price:2750},{ing:'smk-salmon',ordered:2,received:2,price:2800}]},{id:'dl-today-veg',supplierId:'sup-3',due:'today',status:'expected',lines:[{ing:'potatoes',ordered:50,received:50,price:90},{ing:'leaves',ordered:3,received:2,price:700},{ing:'lemons',ordered:30,received:30,price:25}]}],stockTakes:[{id:'stk-1',at:c(7,22),by:'Head Chef (example)',lines:[{ing:'haddock',expected:6,counted:5.4,cost:1650},{ing:'potatoes',expected:30,counted:28,cost:90},{ing:'cream',expected:8,counted:8,cost:380},{ing:'beef-fillet',expected:3.2,counted:3,cost:4800}]}],waste:[{id:'w1',at:c(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:c(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:c(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:c(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:c(5,22),by:'Head Chef (example)',item:'Chips',ing:'potatoes',qty:3,unit:'kg',reason:'Over-production',cost:270}],orders:[{id:'po-1',supplierId:'sup-1',at:c(1,13),by:'Head Chef (example)',status:'placed (by phone)',lines:[{ing:'haddock',qty:10,cost:1848},{ing:'mussels',qty:12,cost:450},{ing:'langoustine',qty:3,cost:2600},{ing:'smk-salmon',qty:2,cost:2800}],total:30520},{id:'po-2',supplierId:'sup-3',at:c(1,18),by:'Head Chef (example)',status:'placed (on website)',lines:[{ing:'potatoes',qty:50,cost:90},{ing:'leaves',qty:3,cost:700},{ing:'lemons',qty:30,cost:25}],total:7350}],prepTicks:{},temps:[{id:'t1',at:c(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:c(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}const b=(0,i.create)()((0,n.persist)(e=>({...k(),setTarget:t=>e({targetGp:Math.max(40,Math.min(90,Math.round(t)))}),setIngredient:(t,s)=>e(e=>({ingredients:e.ingredients.map(e=>e.id===t?{...e,...s}:e)})),setRecipeQty:(t,s,i)=>e(e=>({recipes:e.recipes.map(e=>e.dishId!==t?e:{...e,lines:i>0?e.lines.some(e=>e.ing===s)?e.lines.map(e=>e.ing===s?{...e,qty:i}:e):[...e.lines,{ing:s,qty:i}]:e.lines.filter(e=>e.ing!==s)})})),acceptDelivery:(t,s,i,n)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:s,status:'accepted',checkedBy:i,at:(new Date).toISOString(),note:n}:e),ingredients:e.ingredients.map(e=>{const t=s.find(t=>t.ing===e.id);return t?{...e,onHand:Math.round(100*(e.onHand+t.received))/100,...t.price!==e.cost?{prevCost:e.cost,cost:t.price}:{}}:e})})),saveStockTake:(t,s)=>e(e=>({stockTakes:[{id:u('stk'),at:(new Date).toISOString(),by:s,lines:Object.entries(t).map(([t,s])=>{const i=e.ingredients.find(e=>e.id===t);return{ing:t,expected:i.onHand,counted:s,cost:i.cost}})},...e.stockTakes],ingredients:e.ingredients.map(e=>e.id in t?{...e,onHand:t[e.id]}:e)})),addWaste:t=>e(e=>({waste:[{...t,id:u('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=u('po');return e(e=>({orders:[{...t,id:s,at:(new Date).toISOString()},...e.orders]})),s},setOrderStatus:(t,s)=>e(e=>({orders:e.orders.map(e=>e.id===t?{...e,status:s}:e)})),tickPrep:(t,s)=>e(e=>{const i={...e.prepTicks};return s?i[t]={by:s,at:(new Date).toISOString()}:delete i[t],{prepTicks:i}}),addTemp:t=>e(e=>({temps:[{...t,id:u('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(k())}),{name:'covercharge-kitchen-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1091,[975,974,976]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatSync",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"chatSynced",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({synced:!1,checked:!1})),n=()=>t.getState().synced},1092,[974]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAT",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return n}}),e.dishCost=i,Object.defineProperty(e,"gpPct",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"priceForTarget",{enumerable:!0,get:function(){return c}}),e.costings=function(r,c,s,u){const d=(0,t.dishStats)(r);return c.map(t=>{const c=r.find(r=>r.id===t.dishId);if(!c||null==c.price)return null;const p=i(t,s),l=n(c.price),f=o(p,c.price),b=d.find(t=>t.item.id===c.id)?.sold??0;return{item:c,recipe:t,cost:p,priceInc:c.price,priceEx:l,gp:f,cashGp:l-p,below:ft.prevCost&&t.prevCost!==t.cost).map(s=>{const u=(s.cost-(s.prevCost??s.cost))/(s.prevCost??1)*100,d=r.filter(t=>t.lines.some(t=>t.ing===s.id)).map(r=>{const u=t.find(t=>t.id===r.dishId);if(!u||null==u.price)return null;const d=o(i(r,n,{ing:s.id,cost:s.prevCost}),u.price),p=o(i(r,n),u.price);return{item:u,before:d,after:p,dropped:d>=c&&pt.dropped),below:d.filter(t=>t.below)}})},e.weekGp=function(t,r,n){const i=t.reduce((t,r)=>t+r.priceEx*r.soldWeek,0),o=t.reduce((t,r)=>t+r.cost*r.soldWeek,0),c=o+r+Math.max(0,n);return{sales:i,theoCost:o,actualCost:c,theo:i?(i-o)/i*100:0,actual:i?(i-c)/i*100:0}},Object.defineProperty(e,"fmtQty",{enumerable:!0,get:function(){return s}});var t=_r(_d[0]);const r=.2,n=t=>Math.round(t/1.2);function i(t,r,n){return Math.round(t.lines.reduce((t,i)=>{const o=r.find(t=>t.id===i.ing);return t+(n&&n.ing===i.ing?n.cost:o?.cost??0)*i.qty},0))}const o=(t,r)=>{const i=n(r);return i>0?(i-t)/i*100:0},c=(t,r)=>50*Math.ceil(t/(1-r/100)*1.2/50);const s=(t,r)=>`${Number.isInteger(t)?t:t.toFixed(t<1?3:2).replace(/0+$/,'').replace(/\.$/,'')} ${'each'===r?'':r}`.trim()},1093,[1094]); +__d(function(g,_r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hash",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const i=[];for(let s=r;s>=1;s--){const r=(0,t.addMins)(n,1440*-s),d=!!e.kitchenHours[r.getDay()],l=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),u=n=>.85+.3*o((0,t.ymd)(r)+n+e.id),c=d?Math.round(24e4*l*u('d')):0,p=d?Math.round(95e3*l*u('t')):0,h=d?Math.round(52e3*l*u('q')):0;i.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':c,Takeaway:p,'Table QR':h},total:c+p+h,covers:d?Math.round(150*l*u('c')):0})}return i},_e.dishStats=function(e){return e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*o(e.id+'s')),n=.24+.22*o(e.id+'c'),r=e.price??0,i=Math.round(r*(1-n));return{item:e,sold:t,revenue:t*r,costPct:n,margin:i,gp:i*t}})},_e.quadrant=function(e,t,o,n){return e>=o?t>=n?'Star':'Plough horse':t>=n?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return i.map((e,t)=>{const r=o(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${s[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*r),lastVisit:`${1+Math.round(27*r)} days ago`,spend:Math.round(3e3+6e4*r),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:r>.8?['Gluten (coeliac)']:r<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*r),optIn:r>.25,channel:n[Math.floor(3*r)%3],birthday:r>.6?`${1+Math.round(27*r)} Nov`:void 0}})},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),_e.insights=function(o,n,r,i,s,l,u){const c=[],p=new Date(l);p.setDate(p.getDate()+((6-p.getDay()+7)%7||7)),p.setHours(0,0,0,0);const h=(0,e.forecastToday)(o,n,r,i,p),m=Math.round(h.restOfDay.covers/Math.max(1,h.multiplier)),b=Math.max(35,Math.round(100*(h.multiplier-1))+35);c.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(p)} forecast +${b}%: add 1 server 6\u20139pm`,body:`Example: ~${Math.round(m*(1+b/100))} covers expected vs ~${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(o,n,r,i,l),y=d[0],v=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*y.perCover);c.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${y.onHand} portions left`,body:`Tonight\u2019s forecast needs ~${v}. Call the supplier before 18:00 or 86 the fish supper at ${y.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const M=i.find(e=>/Burns/.test(e.title));if(M){const e=Math.max(1,Math.round((new Date(M.date).getTime()-l.getTime())/6048e5));c.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out ~3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const w=n.filter(e=>'noshow'===e.status).length;c.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:w?`${w} no-show today: deposits for 6+?`:'No-shows down 40% since card-on-file (example)',body:'Saved card is required from parties of 6. Consider deposits on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const k=s.filter(e=>e.stars<=2).length;k&&c.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${k} low rating this week: cold chips at collection`,body:'Readiness alerts now time bagging 5 min before pickup. Reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});return c.push({id:'commission',icon:'\ud83d\udcb7',tone:'green',title:'You kept ~\xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost ~30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),c.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${u} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),c};var e=_r(_d[0]),t=_r(_d[1]);const o=e=>{let t=2166136261;for(let o=0;o>>0)/4294967295},n=['Dine-in','Takeaway','Table QR'];const r={Star:'Keep: high margin and popular. Feature it.','Plough horse':'Popular, low margin: nudge the price or trim the cost.',Puzzle:'High margin, few sales: promote it or rename it.',Dog:'Low margin, few sales: consider removing it.'},i=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],s=['Morgan','Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Paterson','Duncan','Gilmour','Reid','Ross','Grant'];const d=[{cat:'Fish & seafood',id:'haddock',name:'Haddock fillets',unit:'portions',onHand:8,perCover:.22,par:40},{cat:'Fruit & veg',id:'chips',name:'Chipping potatoes',unit:'kg',onHand:25,perCover:.18,par:40},{cat:'Fish & seafood',id:'langoustine',name:'Langoustines',unit:'kg',onHand:4,perCover:.03,par:6},{cat:'Fish & seafood',id:'mussels',name:'Mussels',unit:'kg',onHand:10,perCover:.05,par:12},{cat:'Fish & seafood',id:'scallops',name:'Scallops',unit:'portions',onHand:14,perCover:.06,par:20},{cat:'Meat',id:'beef',name:'Burger patties',unit:'each',onHand:30,perCover:.1,par:40},{cat:'Fruit & veg',id:'peas',name:'Garden peas',unit:'kg',onHand:6,perCover:.04,par:8},{cat:'Dairy',id:'tartare',name:'House tartare sauce',unit:'tubs',onHand:5,perCover:.05,par:10}]},1094,[853,796]); +__d(function(g,r,i,a,m,e,_d){"use strict";function t(t,n){const o={};for(let c=0;c<7;c++){o[c]={};const u=n[c]??0;for(const[n,s]of Object.entries(t))o[c][Number(n)]=Math.round(s*u)}return o}Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"EXAMPLE_HISTORY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"EXAMPLE_ACCURACY",{enumerable:!0,get:function(){return f}});const n={12:18,13:26,14:16,15:9,16:10,17:22,18:36,19:38,20:20},o={12:2,13:2,14:1,15:1,16:2,17:4,18:6,19:5,20:2},c={0:1.05,1:0,2:0,3:.6,4:.7,5:1,6:1.15},u={0:.6,1:.5,2:.5,3:.6,4:.7,5:.9,6:1},s={anchorage:{covers:t(n,c),takeaway:t(o,c)},default:{covers:t(n,u),takeaway:t(o,u)}},f='Example: last 4 weeks within \xb118% of actual covers'},1095,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CHEF_ID",{enumerable:!0,get:function(){return p}}),_e.useChef=y,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return j}}),_e.useWeek=function(){const{k:e,c:r,now:o}=y(6e4),t=e.waste.filter(e=>j(e.at,o)).reduce((e,r)=>e+r.cost,0),s=e.stockTakes[0],n=s?s.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,l.weekGp)(r,t,n),wasteWeek:t,variance:Math.round(n)}},_e.useForecast=function(){const{r:e,rid:r,now:o}=y(6e4),s=(0,t.useBookings)(r),i=(0,t.useOrders)(r),u=(0,t.useEvents)(r),l=(0,n.forecastToday)(e,s,i,u,o),b=l.hours.reduce((e,r)=>e+r.covers,0),f=l.hours.reduce((e,r)=>e+r.historicalCovers,0),h=f?Math.round((b-f)/f*100):0,p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,c.weekday)(o)];return{f:l,covers:b,typical:f,pct:h,day:p,label:`${p} ${h>=0?'+':''}${h}%`}},_e.Tile=function({label:e,value:o,sub:t,tone:s,onPress:n,testID:c}){const l='red'===s?u.colours.red:'amber'===s?u.colours.amber:'green'===s?u.colours.green:u.colours.text;return(0,h.jsxs)(r.default,{testID:c,accessibilityRole:n?'button':void 0,accessibilityLabel:`${e}: ${o}`,onPress:n,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:140,padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===s?u.colours.red:u.colours.border,backgroundColor:e?'#1d1a14':u.colours.surface,gap:2}),children:[(0,h.jsx)(i.Muted,{children:e}),(0,h.jsx)(i.T,{size:22,weight:"bold",colour:l,children:o}),t?(0,h.jsx)(i.T,{size:12,colour:u.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:o,onChange:t}){return(0,h.jsx)(i.Row,{wrap:!0,gap:6,children:o.map(o=>(0,h.jsx)(r.default,{accessibilityRole:"tab",accessibilityState:{selected:e===o.id},accessibilityLabel:o.label,onPress:()=>t(o.id),style:{paddingHorizontal:12,paddingVertical:7,borderRadius:999,borderWidth:1,borderColor:e===o.id?u.colours.gold:u.colours.border,backgroundColor:e===o.id?u.colours.goldTint:'transparent'},children:(0,h.jsx)(i.T,{size:13,weight:e===o.id?'semibold':'regular',colour:e===o.id?u.colours.goldLight:u.colours.text,children:o.label})},o.id))})},_e.Bar=function({pct:e,colour:r=u.colours.gold}){return(0,h.jsx)(o.default,{style:{height:6,borderRadius:3,backgroundColor:u.colours.surface2,overflow:'hidden'},children:(0,h.jsx)(o.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return k}}),_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=_r(d[3]),s=_r(d[4]),n=_r(d[5]),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),l=_r(d[9]),b=_r(d[10]),f=_r(d[11]),h=_r(d[12]);const p=f.ROSTER.find(e=>'chef'===e.app)?.id??'st-bisto';function y(e=3e4){const r=(0,s.useOwner)(e=>e.site),o=(0,t.useRestaurant)(r),n=(0,s.useOwner)(e=>e.staff),i=n.find(e=>e.id===p)?.name??'Head Chef',u=(0,t.useNow)(e),c=(0,t.useAllMenu)(r),f=(0,b.useKitchen)();return{rid:r,r:o,me:i,now:u,menu:c,k:f,c:(0,l.costings)(c,f.recipes,f.ingredients,f.targetGp)}}const w=(e,r)=>e>0&&e<.5*r,x=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),j=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const k=e=>`${e.toFixed(1)}%`},1096,[12,245,109,797,813,853,791,799,884,1093,1091,916,6]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GpScreen=function({initial:e="dishes"}){const[t,l]=(0,s.useState)(e),{k:c}=(0,d.useChef)(),o=(0,a.useKitchen)(e=>e.setTarget);return(0,h.jsxs)(i.default,{style:{gap:12},children:[(0,h.jsx)(n.Card,{children:(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{weight:"semibold",children:"Target GP"}),(0,h.jsx)(n.Muted,{children:"Dishes under target are flagged red."})]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"\u2212",accessibilityLabel:"Lower target",onPress:()=>o(c.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[c.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>o(c.targetGp+1)})]})}),(0,h.jsx)(d.Seg,{value:t,onChange:l,options:[{id:'dishes',label:'Recipe cards & GP'},{id:'changes',label:'Price changes'},{id:'week',label:'Theoretical vs actual'},{id:'engineering',label:'Menu engineering'}]}),'dishes'===t?(0,h.jsx)(u,{}):'changes'===t?(0,h.jsx)(j,{}):'week'===t?(0,h.jsx)(b,{}):(0,h.jsx)(f,{})]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,d.useChef)(),[l,r]=(0,s.useState)(null),c=e.filter(e=>e.below),o=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Menu prices include VAT (20%). GP is worked out on the price ex VAT: (price ex VAT \u2212 dish cost) \xf7 price ex VAT. VAT figures are for information only."}),c.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${c.length} of ${e.length} dishes below ${t.targetGp}%`,children:[c.slice(0,6).map(e=>e.item.name).join(', '),c.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),o.map(e=>(0,h.jsx)(p,{d:e,onPress:()=>r(e.item.id)},e.item.id)),(0,h.jsx)(n.Sheet,{visible:!!a,onClose:()=>r(null),title:a?.item.name??'',children:a?(0,h.jsx)(x,{d:a}):null})]})}function p({d:e,onPress:s}){return(0,h.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:`${e.item.name}, GP ${e.gp.toFixed(1)} percent`,onPress:s,style:({pressed:s})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:e.below?r.colours.red:r.colours.border,backgroundColor:s?'#1d1a14':e.below?r.colours.redBg:r.colours.surface,gap:2}),children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"medium",style:{flex:1},children:e.item.name}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.green,children:(0,d.pct1)(e.gp)})]}),(0,h.jsxs)(n.Muted,{children:["Cost ",(0,l.gbp)(e.cost)," \xb7 ",(0,l.gbp)(e.priceInc)," inc VAT (",(0,l.gbp)(e.priceEx)," ex) \xb7 cash GP ",(0,l.gbp)(e.cashGp)]}),e.below?(0,h.jsxs)(n.T,{size:12,colour:r.colours.red,children:["Below ",e.target,"%: price for target ",(0,l.gbp)((0,o.priceForTarget)(e.cost,e.target))," inc VAT"]}):null]})}function x({d:e}){const s=(0,a.useKitchen)(),t=s.recipes.find(s=>s.dishId===e.item.id);return(0,h.jsxs)(i.default,{style:{gap:8},children:[(0,h.jsxs)(n.Muted,{children:["Recipe card \xb7 ",t.yield]}),t.lines.map(t=>{const r=s.ingredients.find(e=>e.id===t.ing);if(!r)return null;const c='each'===r.unit?1:'kg'===r.unit&&t.qty<.1?.005:.01;return(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(i.default,{style:{flex:1},children:[(0,h.jsx)(n.T,{size:14,children:r.name}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(r.cost)," per ",r.unit]})]}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2212",accessibilityLabel:`Less ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.max(0,Math.round(1e3*(t.qty-c))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,o.fmtQty)(t.qty,r.unit)}),(0,h.jsx)(n.Button,{small:!0,kind:"ghost",label:"+",accessibilityLabel:`More ${r.name}`,onPress:()=>s.setRecipeQty(e.item.id,t.ing,Math.round(1e3*(t.qty+c))/1e3)}),(0,h.jsx)(n.T,{size:13,style:{width:60,textAlign:'right'},children:(0,l.gbp)(Math.round(r.cost*t.qty))})]},t.ing)}),(0,h.jsxs)(i.default,{style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Dish cost"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cost)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Selling price inc VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceInc)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.Muted,{children:"VAT (20%, for info)"}),(0,h.jsx)(n.Muted,{children:(0,l.gbp)(e.priceInc-e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Price ex VAT"}),(0,h.jsx)(n.T,{children:(0,l.gbp)(e.priceEx)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"Cash GP"}),(0,h.jsx)(n.T,{weight:"semibold",children:(0,l.gbp)(e.cashGp)})]}),(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{children:"GP %"}),(0,h.jsx)(n.T,{weight:"bold",colour:e.below?r.colours.red:r.colours.green,children:(0,d.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,o.priceForTarget)(e.cost,e.target))} inc VAT`,children:["Or bring the dish cost down to ",(0,l.gbp)(Math.floor(e.priceEx*(1-e.target/100))),". Prices are changed in Cover Charge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,d.useChef)(),t=(0,o.priceImpacts)(e,s.recipes,s.ingredients,s.targetGp);return t.length?(0,h.jsx)(i.default,{style:{gap:10},children:t.map(e=>(0,h.jsxs)(n.Card,{highlight:e.dropped.length?r.colours.red:void 0,children:[(0,h.jsxs)(n.T,{weight:"semibold",children:[e.ing.name," ",e.pct>0?'+':'',e.pct.toFixed(0),"%: ",e.dropped.length," dish",1===e.dropped.length?'':'es'," drop below target"]}),(0,h.jsxs)(n.Muted,{children:[(0,l.gbp)(e.ing.prevCost??0)," \u2192 ",(0,l.gbp)(e.ing.cost)," per ",e.ing.unit]}),e.dishes.map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.T,{size:13,colour:r.colours.muted,children:[(0,d.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.green,children:(0,d.pct1)(e.after)}),e.dropped?(0,h.jsx)(n.Badge,{kind:"red",label:"NOW BELOW"}):null]},e.item.id))]},e.ing.id))}):(0,h.jsx)(n.Muted,{children:"No ingredient price changes since the last deliveries."})}function b(){const{k:e}=(0,d.useChef)(),s=(0,d.useWeek)();return(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(d.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,d.pct1)(s.theo),tone:s.theoe.soldWeek>0),t=s.reduce((e,s)=>e+s.soldWeek,0)/Math.max(1,s.length),r=s.reduce((e,s)=>e+s.cashGp,0)/Math.max(1,s.length),o={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>o[(0,c.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from Cover Charge for Managers. Example sales figures."}),Object.keys(o).map(e=>(0,h.jsxs)(n.Card,{children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{weight:"semibold",children:'Star'===e?'\u2b50 Stars':'Plough horse'===e?'\ud83d\udc0e Plough horses':'Puzzle'===e?'\ud83e\udde9 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${o[e].length}`})]}),(0,h.jsx)(n.Muted,{children:c.QUADRANT_TIP[e]}),o[e].map(e=>(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(n.T,{size:14,style:{flex:1},children:e.item.name}),(0,h.jsxs)(n.Muted,{children:[e.soldWeek,"/wk \xb7 ",(0,l.gbp)(e.cashGp)," \xb7 ",(0,d.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1097,[12,245,109,791,794,799,1094,1093,1096,1091,6]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.PrepScreen=function(){const{k:e,menu:t,me:i,now:n}=(0,C.useChef)(),{covers:l,label:d,typical:o}=(0,C.useForecast)(),c=(0,m.ymd)(n),u=(0,b.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),h=u.reduce((e,t)=>e+t.sold,0)||1,f=u.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*l*(e.sold/h)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),x={};f.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{x[e.ing]=(x[e.ing]??0)+e.qty*t.qty}));const j=[{id:'haddock',text:`Portion ${f.filter(e=>['a-fishsupper','a-mini','a-tempura'].includes(e.id)).reduce((e,t)=>e+t.qty,0)} haddock portions (fish supper, tempura, Mini Anchors)`},{id:'chips',text:`Peel, cut and blanch ${(0,y.fmtQty)(Math.ceil(2*(x.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,y.fmtQty)(Math.ceil(10*(x.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,y.fmtQty)(Math.ceil(10*(x.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,y.fmtQty)(Math.ceil(2*(x.mussels??0))/2,'kg')} mussels (discard any open that don't close)`},{id:'sauce',text:'Garlic butter, tartare and Marie Rose: check, make and date-label'}],w=(0,T.useKitchen)(e=>e.tickPrep),k=[...j.map(e=>({key:`${c}:task:${e.id}`,text:e.text})),...f.map(e=>({key:`${c}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=k.filter(t=>e.prepTicks[t.key]).length;return(0,M.jsxs)(r.default,{style:{gap:10},children:[(0,M.jsxs)(a.Banner,{kind:"info",title:`${d}: ${l} covers forecast`,children:["A typical ",d.split(' ')[0]," is about ",o," covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}),(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Prep list for today"}),(0,M.jsx)(a.Badge,{kind:S===k.length?'green':'gold',label:`${S}/${k.length} done`})]}),k.map((t,n)=>{const l=e.prepTicks[t.key];return(0,M.jsxs)(s.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!l},accessibilityLabel:t.text,onPress:()=>w(t.key,l?null:i),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:l?p.colours.green:p.colours.border,backgroundColor:p.colours.surface,marginTop:n===j.length?8:0},children:[(0,M.jsx)(a.T,{size:18,colour:l?p.colours.green:p.colours.muted,children:l?'\u2611':'\u2610'}),(0,M.jsxs)(r.default,{style:{flex:1},children:[(0,M.jsx)(a.T,{size:14,style:l?{textDecorationLine:'line-through',color:p.colours.muted}:void 0,children:t.text}),l?(0,M.jsxs)(a.Muted,{children:[l.by," \xb7 ",new Date(l.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]})},_e.WasteScreen=function(){const{k:e,me:s,now:l}=(0,C.useChef)(),d=(0,C.useWeek)(),o=(0,T.useKitchen)(e=>e.addWaste),[c,u]=(0,t.useState)(e.ingredients[0].id),[f,m]=(0,t.useState)(''),[x,j]=(0,t.useState)('Over-production'),b=e.ingredients.find(e=>e.id===c),w=Number(f.replace(',','.'))||0,k=e.waste.filter(e=>(0,C.within7)(e.at,l));return(0,M.jsxs)(r.default,{style:{gap:10},children:[(0,M.jsxs)(a.Row,{wrap:!0,gap:10,children:[(0,M.jsx)(C.Tile,{label:"Waste this week",value:(0,h.gbp)(d.wasteWeek),sub:`${k.length} entries`,tone:d.sales&&d.wasteWeek/d.sales>.02?'amber':'green'}),(0,M.jsx)(C.Tile,{label:"Waste as % of food sales",value:d.sales?(0,C.pct1)(d.wasteWeek/d.sales*100):'\u2014',sub:"Food sales ex VAT, example week"})]}),(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Log waste"}),(0,M.jsx)(i.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,M.jsx)(a.Row,{gap:6,children:e.ingredients.map(e=>(0,M.jsx)(a.Chip,{label:e.name,selected:e.id===c,onPress:()=>u(e.id)},e.id))})}),(0,M.jsxs)(a.Row,{gap:8,children:[(0,M.jsx)(n.default,{accessibilityLabel:"Waste quantity",keyboardType:"decimal-pad",value:f,onChangeText:m,placeholder:`qty (${b.unit})`,placeholderTextColor:p.colours.muted,style:{flex:1,borderWidth:1,borderColor:p.colours.border,borderRadius:8,padding:8,color:p.colours.text}}),(0,M.jsx)(a.T,{children:b.unit}),(0,M.jsx)(a.T,{weight:"semibold",colour:p.colours.gold,children:(0,h.gbp)(Math.round(w*b.cost))})]}),(0,M.jsx)(a.Row,{wrap:!0,gap:6,children:T.WASTE_REASONS.map(e=>(0,M.jsx)(a.Chip,{label:e,selected:e===x,onPress:()=>j(e)},e))}),(0,M.jsx)(a.Button,{label:"Add to waste log",disabled:w<=0,onPress:()=>{o({by:s,item:b.name,ing:b.id,qty:w,unit:b.unit,reason:x,cost:Math.round(w*b.cost)}),m('')}}),(0,M.jsx)(a.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,M.jsxs)(r.default,{style:{flex:1},children:[(0,M.jsxs)(a.T,{size:14,children:[e.item," \xb7 ",(0,y.fmtQty)(e.qty,e.unit)]}),(0,M.jsxs)(a.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,M.jsx)(a.T,{size:14,children:(0,h.gbp)(e.cost)})]},e.id))]})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:n}=(0,C.useChef)(),o=(0,l.useRecipeCards)(n),h=(0,c.auditView)('chef',(0,l.useAudit)(n)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),f=o.slice().sort((e,t)=>e.section.localeCompare(t.section)||e.dish.localeCompare(t.dish)).map(e=>{const s=t.recipes.find(t=>t.dishId===e.menuItemId),i=new Set(s?s.lines.flatMap(e=>t.ingredients.find(t=>t.id===e.ing)?.allergens??[]):[]),n=[...i].filter(t=>!e.allergens[t]);return{card:e,fromCosting:i,missing:n}}),m={name:s,role:'head-chef'};return(0,M.jsxs)(r.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,M.jsx)(a.Muted,{children:"The 14 allergens from each recipe card (C contains, m may contain). These are what guests see on the menu, takeaway and the booking allergy check. A red cell means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,M.jsx)(a.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,(0,M.jsx)(i.default,{horizontal:!0,children:(0,M.jsxs)(r.default,{children:[(0,M.jsxs)(a.Row,{gap:0,children:[(0,M.jsx)(r.default,{style:{width:150},children:(0,M.jsx)(a.Muted,{children:"Dish"})}),u.ALLERGENS.map(e=>(0,M.jsx)(r.default,{style:{width:34,alignItems:'center'},children:(0,M.jsx)(a.T,{size:10,colour:p.colours.muted,children:e.short})},e.id))]}),f.map(({card:e,fromCosting:t})=>(0,M.jsxs)(a.Row,{gap:0,style:{borderTopWidth:1,borderColor:p.colours.border,paddingVertical:4},children:[(0,M.jsx)(r.default,{style:{width:150},children:(0,M.jsx)(a.T,{size:12,numberOfLines:2,children:e.dish})}),u.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i;return(0,M.jsx)(r.default,{accessibilityLabel:`${e.dish} ${s.label}: ${'contains'===i?'contains':'may'===i?'may contain':n?'in the costing recipe, not on the card':'no'}`,style:{width:34,height:24,alignItems:'center',justifyContent:'center',backgroundColor:n?p.colours.redBg:'transparent'},children:(0,M.jsx)(a.T,{size:11,weight:'contains'===i?'bold':'regular',colour:n?p.colours.red:'contains'===i?p.colours.gold:i?p.colours.muted:'#444',children:'contains'===i?'C':'may'===i?'m':n?'!':'\xb7'})},s.id)})]},e.id))]})}),(0,M.jsx)(a.Muted,{children:"C card says contains \xb7 m may contain \xb7 ! in the costing recipe but not on the card"}),f.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,M.jsxs)(a.Card,{highlight:s.length?p.colours.red:p.colours.amber,children:[(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(a.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,M.jsx)(a.Badge,{kind:"green",label:"Signed off"}):(0,M.jsx)(a.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,M.jsxs)(a.T,{size:13,colour:p.colours.red,children:["Costing recipe has ",s.map(e=>u.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,M.jsxs)(a.Row,{wrap:!0,gap:8,children:[s.length?(0,M.jsx)(a.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,d.recipeCards)().update(t.id,{allergens:e},m).catch(()=>{})}}):null,e?(0,M.jsx)(a.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Audit log"}),h.length?h.map(e=>(0,M.jsxs)(a.Muted,{children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.text]},e.id)):(0,M.jsx)(a.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:i,now:l}=(0,C.useChef)(),d=(0,m.ymd)(l),c=(0,T.useKitchen)(e=>e.addTemp),u=(0,o.useOwner)(e=>e.checks),{tick:h,untick:f}=o.useOwner.getState(),[x,j]=(0,t.useState)('fridge'),b=O.find(e=>e.id===x),[y,w]=(0,t.useState)(b.units[0]),[k,S]=(0,t.useState)(''),$=Number(k.replace(',','.')),v=k.trim()&&!Number.isNaN($)?b.ok($):null,R=e.temps.filter(e=>e.at.slice(0,10)===d),z=(e,t,n)=>{const l=u[e];return(0,M.jsxs)(s.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!l},accessibilityLabel:t,onPress:()=>l?f(e):h(e,i,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,M.jsx)(a.T,{size:18,colour:l?p.colours.green:p.colours.muted,children:l?'\u2611':'\u2610'}),(0,M.jsxs)(r.default,{style:{flex:1},children:[(0,M.jsx)(a.T,{size:14,children:t}),(0,M.jsx)(a.Muted,{children:l?`${l.by} \xb7 ${new Date(l.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:n??''})]})]},e)};return(0,M.jsxs)(r.default,{style:{gap:10},children:[(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Record a temperature"}),(0,M.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,M.jsx)(a.Chip,{label:e.label,selected:e.id===x,onPress:()=>{j(e.id),w(e.units[0])}},e.id))}),(0,M.jsx)(a.Row,{wrap:!0,gap:6,children:b.units.map(e=>(0,M.jsx)(a.Chip,{label:e,selected:e===y,onPress:()=>w(e)},e))}),(0,M.jsx)(a.Muted,{children:b.rule}),(0,M.jsxs)(a.Row,{gap:8,children:[(0,M.jsx)(n.default,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:k,onChangeText:S,placeholder:"\xb0C",placeholderTextColor:p.colours.muted,style:{width:90,borderWidth:1,borderColor:p.colours.border,borderRadius:8,padding:8,color:p.colours.text}}),null===v?null:(0,M.jsx)(a.Badge,{kind:!0===v?'green':'warn'===v?'amber':'red',label:!0===v?'OK':'warn'===v?'CHECK':'OUT OF RANGE'}),(0,M.jsx)(a.Button,{small:!0,label:"Save",disabled:null===v,onPress:()=>{c({by:i,kind:x,unit:y,temp:$,note:!0===v?void 0:'Action needed'}),S('')}})]}),!1===v?(0,M.jsx)(a.Banner,{kind:"danger",title:"Out of range",children:"Record what you did (e.g. moved food, called the engineer, cooked longer) and re-check."}):null]}),(0,M.jsxs)(a.Card,{children:[(0,M.jsxs)(a.T,{weight:"semibold",children:["Today's readings (",R.length,")"]}),R.length?R.map(e=>{const t=O.find(t=>t.id===e.kind)?.ok(e.temp);return(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(a.T,{size:14,style:{flex:1},children:e.unit}),(0,M.jsx)(a.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,M.jsxs)(a.T,{size:14,weight:"semibold",colour:!0===t?p.colours.green:'warn'===t?p.colours.amber:p.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,M.jsx)(a.Muted,{children:"None yet today."})]}),(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Opening and closing checks"}),(0,M.jsx)(a.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),D.map(e=>z(`${d}:kc-${e.id}`,e.text))]}),(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Cleaning schedule"}),B.map(e=>z('Daily'===e.freq?`${d}:kcl-${e.id}`:`wk${Math.floor(l.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:s,me:i,now:n,menu:a}=(0,C.useChef)(15e3),[l,d]=(0,t.useState)('live'),o=(0,j.useSignedIn)(),c=(0,t.useMemo)(()=>({meId:o?.id??C.CHEF_ID,role:'staff'}),[o?.id]);return(0,M.jsx)(x.ChatAsCtx.Provider,{value:c,children:(0,M.jsxs)(r.default,{style:{gap:10},children:[(0,M.jsx)(z,{sub:l,setSub:d}),'live'===l?(0,M.jsx)(L,{}):'86'===l?(0,M.jsx)(A,{}):'team'===l?(0,M.jsx)(q,{}):(0,M.jsx)(I,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=e(_r(_d[3])),r=e(_r(_d[4])),a=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),v=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]);const O=[{id:'fridge',label:'Fridge',units:['Walk-in fridge','Prep fridge','Bar fridge'],rule:'Target 5\xb0C or below (8\xb0C maximum)',ok:e=>e<=5||e<=8&&'warn'},{id:'freezer',label:'Freezer',units:['Chest freezer','Upright freezer'],rule:'Target \u221218\xb0C or below',ok:e=>e<=-18||e<=-15&&'warn'},{id:'cook',label:'Cooking (core)',units:['Fish','Chicken','Pie','Burger'],rule:'Core 75\xb0C or above',ok:e=>e>=75},{id:'reheat',label:'Reheating',units:['Soup','Skink','Sauce'],rule:'Core 82\xb0C or above (Scotland)',ok:e=>e>=82},{id:'hot hold',label:'Hot holding',units:['Bain-marie','Soup kettle'],rule:'63\xb0C or above',ok:e=>e>=63},{id:'cool',label:'Cooling',units:['Stock','Rice','Braise'],rule:'Below 8\xb0C, cooled as quickly as possible (aim for 90 minutes)',ok:e=>e<8||'warn'}],B=[{id:'surfaces',text:'Work surfaces and boards cleaned and sanitised',freq:'Daily'},{id:'fryers',text:'Fryers filtered, oil checked',freq:'Daily'},{id:'floors',text:'Floors and drains',freq:'Daily'},{id:'handwash',text:'Wash-hand basins stocked (soap, towels)',freq:'Daily'},{id:'fridges',text:'Fridges emptied and cleaned',freq:'Weekly'},{id:'extract',text:'Extraction canopy filters',freq:'Weekly'}],D=[{id:'open-temps',text:'Opening: fridge and freezer temperatures recorded',when:'Opening'},{id:'open-fit',text:'Opening: staff fit for work (no sickness or diarrhoea in 48 hours)',when:'Opening'},{id:'open-probe',text:'Opening: probe thermometer checked and wiped',when:'Opening'},{id:'close-label',text:'Closing: food covered, labelled and dated',when:'Closing'},{id:'close-dates',text:'Closing: anything past its use-by removed',when:'Closing'},{id:'close-clean',text:'Closing: cleaning schedule done',when:'Closing'}];function z({sub:e,setSub:t}){const{total:s}=(0,x.useChatUnread)();return(0,M.jsx)(C.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'86',label:'86 / sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function I(){return(0,M.jsx)(x.Chat,{go:()=>{}})}function L(){const{rid:e,r:t,me:s,now:i}=(0,C.useChef)(15e3),n=(0,l.useStore)(e=>e.bookings),d=(0,l.useOrders)(e).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,k.nextStep)(e,(0,k.linkedBooking)(e,n))),o=(e,t)=>!!(0,k.statusBlock)(e,t,(0,k.linkedBooking)(e,n)),h=(0,c.ticketView)('chef',d),m=(0,l.useStore)(e=>e.setOrderStatus),x=(0,l.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,f.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,M.jsxs)(r.default,{style:{gap:8},children:[j.length?(0,M.jsx)(a.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,M.jsx)(a.Muted,{children:"No readiness alerts right now."}),h.length?h.map(e=>(0,M.jsxs)(a.Card,{highlight:e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,n))&&'ready'!==e.status?p.colours.red:void 0,children:[(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsxs)(a.T,{weight:"semibold",children:['table'===e.type?`Table ${e.tableNo}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,M.jsx)(a.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,M.jsxs)(a.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,M.jsxs)(a.T,{size:13,colour:p.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${u.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,M.jsxs)(a.T,{size:13,colour:p.colours.green,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>u.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,M.jsx)(w.AllergyChain,{o:e,me:s}):null,(0,M.jsxs)(a.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,M.jsx)(a.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:o(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,M.jsx)(a.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:o(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,M.jsx)(a.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}function A(){const{menu:e}=(0,C.useChef)(),t=(0,l.useStore)(e=>e.updateMenuItem),s=e.filter(e=>e.soldOut);return(0,M.jsxs)(r.default,{style:{gap:6},children:[(0,M.jsx)(a.Muted,{children:"Sold out items disappear from ordering in the customer app straight away and show as 86 in Staff and Managers."}),s.length?(0,M.jsx)(a.Banner,{kind:"warn",title:`86: ${s.length}`,children:s.map(e=>e.name).join(', ')}):null,e.filter(e=>!e.hidden).map(e=>(0,M.jsx)(a.Toggle,{label:`${e.soldOut?'86 \xb7 ':''}${e.name}`,value:e.soldOut,onChange:s=>{t(e.id,{soldOut:s}),o.useOwner.getState().chatSend({ch:'kitchen',from:'system',text:s?`86: ${e.name} sold out`:`Back on: ${e.name}`,at:(new Date).toISOString()})}},e.id))]})}const P=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,m.ymd)(new Date(s,i-1,n+t))};function q(){const{now:e,today:t}={...(0,C.useChef)(6e4),today:(0,m.ymd)(new Date)},{staff:s,shifts:i}=(0,c.rotaView)('chef',(0,o.useOwner)(e=>e.staff),(0,o.useOwner)(e=>e.shifts)),n=(0,o.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),l=(0,j.weekday)(e),d=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),u=(0,v.useSession)(e=>e.meId),h=(0,R.useSync)(e=>e.staffRef),f=u??h??C.CHEF_ID,x=(0,o.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,M.jsxs)(r.default,{style:{gap:10},children:[(0,M.jsx)($.BreakRoomCard,{staffId:f,name:x,now:e}),(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"On now"}),n.length?n.map(e=>(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsxs)(a.Row,{gap:8,style:{flex:1},children:[(0,M.jsx)(S.StaffAvatar,{id:e.staffId,size:28}),(0,M.jsx)(a.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,M.jsxs)(a.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,M.jsx)(a.Muted,{children:"Nobody clocked in yet."})]}),(0,M.jsxs)(a.Card,{children:[(0,M.jsxs)(a.T,{weight:"semibold",children:["Today on the rota (",j.DAY3[l],")"]}),i.filter(e=>e.date===t).map(e=>(0,M.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsxs)(a.Row,{gap:8,style:{flex:1},children:[(0,M.jsx)(S.StaffAvatar,{id:e.staffId,size:28}),(0,M.jsx)(a.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,M.jsxs)(a.Muted,{children:[(0,j.fmtH)(e.start),"\u2013",(0,j.fmtH)(e.end)]})]},e.id))]}),(0,M.jsxs)(a.Card,{children:[(0,M.jsx)(a.T,{weight:"semibold",children:"Kitchen rota this week"}),d.map(e=>(0,M.jsxs)(r.default,{style:{gap:4},children:[(0,M.jsx)(a.T,{size:14,children:e.name}),(0,M.jsx)(a.Row,{wrap:!0,gap:4,children:j.DAY3.map((s,n)=>{const d=i.find(s=>s.staffId===e.id&&s.date===P(t,n-l));return(0,M.jsxs)(r.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:d?p.colours.goldTint:p.colours.surface2,alignItems:'center'},children:[(0,M.jsx)(a.T,{size:10,colour:p.colours.muted,children:s}),(0,M.jsx)(a.T,{size:10,children:d?`${(0,j.fmtH)(d.start).slice(0,2)}\u2013${(0,j.fmtH)(d.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,M.jsx)(a.Muted,{children:"Rota changes, swaps and leave are made in Cover Charge for Managers. This view shows shifts only."})]})]})}},1098,[12,245,133,255,109,791,797,808,813,788,792,794,1099,796,799,910,884,1094,1093,892,893,1096,1091,898,923,816,798,6]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readinessFor=function(a,d,r){if('takeaway'!==a.type||!a.slotTime)return[];if(['collected','cancelled','closed'].includes(a.status))return[];const s=new Date(a.slotTime),n=d.settings.bufferMins,o=a.lines.map(a=>({name:a.name,qty:a.qty,at:(0,t.addMins)(s,-(a.prepMins+n))})),u=o.reduce((t,a)=>a.at{if(a)return'done';const d=r.getTime()-t.getTime();return d<0?'upcoming':d>3e5?'overdue':'due'},y=['ready','collected'].includes(a.status);return[{id:`${a.id}:cook`,orderId:a.id,stage:'cook',due:u,state:l(u,!!a.readiness.cook||y),detail:o.sort((t,a)=>t.at.getTime()-a.at.getTime()).map(t=>{return`${t.qty}\xd7 ${t.name} at ${a=t.at,`${String(a.getHours()).padStart(2,'0')}:${String(a.getMinutes()).padStart(2,'0')}`}`;var a}).join(' \xb7 ')},{id:`${a.id}:bag`,orderId:a.id,stage:'bag',due:c,state:l(c,!!a.readiness.bag||y),detail:'Bag, add sauces/drinks, check against ticket and allergy flags'},{id:`${a.id}:ready`,orderId:a.id,stage:'ready',due:s,state:l(s,y),detail:'Mark ready \u2014 sends the customer a "your order is ready" notification'}]};var t=_r(_d[0])},1099,[796]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inlineStyles",{enumerable:!0,get:function(){return n.inlineStyles}}),Object.defineProperty(_e,"loadLocalRawResource",{enumerable:!0,get:function(){return n.loadLocalRawResource}}),Object.defineProperty(_e,"LocalSvg",{enumerable:!0,get:function(){return n.LocalSvg}}),Object.defineProperty(_e,"SvgCss",{enumerable:!0,get:function(){return n.SvgCss}}),Object.defineProperty(_e,"SvgCssUri",{enumerable:!0,get:function(){return n.SvgCssUri}}),Object.defineProperty(_e,"SvgWithCss",{enumerable:!0,get:function(){return n.SvgWithCss}}),Object.defineProperty(_e,"SvgWithCssUri",{enumerable:!0,get:function(){return n.SvgWithCssUri}}),Object.defineProperty(_e,"WithLocalSvg",{enumerable:!0,get:function(){return n.WithLocalSvg}}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(_e,"camelCase",{enumerable:!0,get:function(){return e.camelCase}}),Object.defineProperty(_e,"fetchText",{enumerable:!0,get:function(){return t.fetchText}}),Object.defineProperty(_e,"parse",{enumerable:!0,get:function(){return e.parse}}),Object.defineProperty(_e,"SvgAst",{enumerable:!0,get:function(){return e.SvgAst}}),Object.defineProperty(_e,"SvgFromUri",{enumerable:!0,get:function(){return e.SvgFromUri}}),Object.defineProperty(_e,"SvgFromXml",{enumerable:!0,get:function(){return e.SvgFromXml}}),Object.defineProperty(_e,"SvgUri",{enumerable:!0,get:function(){return e.SvgUri}}),Object.defineProperty(_e,"SvgXml",{enumerable:!0,get:function(){return e.SvgXml}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),u=r(d[3]);Object.keys(u).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return u[e]}})});var o=r(d[4]);Object.keys(o).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return o[e]}})});var c,f=(c=o)&&c.__esModule?c:{default:c}},1100,[1101,1102,1121,1122,1104]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SvgAst=c,_e.SvgXml=l,_e.SvgUri=function(r){const{onError:o=i,uri:s,onLoad:c,fallback:u}=r,[f,p]=(0,t.useState)(null),[d,h]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{s?(0,n.fetchText)(s).then(t=>{p(t),d&&h(!1),c?.()}).catch(t=>{o(t),h(!0)}):p(null)},[o,s,c]),d)return u??null;return e.createElement(l,{xml:f,override:r,fallback:u})},Object.defineProperty(_e,"SvgFromXml",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"SvgFromUri",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"camelCase",{enumerable:!0,get:function(){return d}}),_e.getStyle=h,_e.astToReact=x,_e.parse=j,Object.defineProperty(_e,"tags",{enumerable:!0,get:function(){return r.tags}});var t=_r(_d[0]),e=(function(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,e})(t),n=_r(_d[1]),r=_r(_d[2]);function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;enull!==o?j(o):null,[o]);return e.createElement(c,{ast:r,override:s||n})}catch(t){return r(t),l??null}}class u extends t.Component{state={ast:null};componentDidMount(){this.parse(this.props.xml)}componentDidUpdate(t){const{xml:e}=this.props;e!==t.xml&&this.parse(e)}parse(t){const{onError:e=i}=this.props;try{this.setState({ast:t?j(t):null})}catch(t){const n=t;e({...n,message:`[RNSVG] Couldn't parse SVG, reason: ${n.message}`})}}render(){const{props:t,state:{ast:n}}=this;return e.createElement(c,{ast:n,override:t.override||t})}}class f extends t.Component{state={xml:null};componentDidMount(){this.fetch(this.props.uri)}componentDidUpdate(t){const{uri:e}=this.props;e!==t.uri&&this.fetch(e)}async fetch(t){try{this.setState({xml:t?await(0,n.fetchText)(t):null})}catch(t){console.error(t)}}render(){const{props:t,state:{xml:n}}=this;return e.createElement(u,{xml:n,override:t,onError:t.onError})}}const p=(t,e)=>e.toUpperCase(),d=t=>t.replace(/[:-]([a-z])/g,p);function h(t){const e={},n=t.split(';').filter(t=>t.trim()),{length:r}=n;for(let t=0;tb(' ',t.length);function v(t,e){const n=t.split('\n'),r=n.length;let o=e,s=0;for(;s=t))break;o-=t}const c=t.slice(0,e).replace(/^\t+/,y),i=/(^|\n).*$/.exec(c),l=i&&i[0]||'',u=t.slice(e),f=/.*(\n|$)/.exec(u);return{line:s,column:o,snippet:`${l}${f&&f[0]}\n${b(' ',l.length)}^`}}const E=/[a-zA-Z0-9:_-]/,O=/ - + + @@ -42,12 +45,12 @@
The Anchorage
- + -

Opening The Anchorage · Staff…

+

Opening Anchorage Staff…